Beruflich Dokumente
Kultur Dokumente
Portals for different tasks
Actions for the selected portal
Selection panel for the selected action
Change to the project view
Display of the project that is currently open
Introduction to the TIA Portal
6.1 User interface and operation
STEP 7 Basic V12.0
164 System Manual, 01/2013,
Portals
The portals provide the basic functions for the individual task areas. The portals that are
provided in the portal view depends on the products that have been installed.
Actions for the selected portal
Here, you will find the actions available to you in the portal you have selected. You can call up
the help function in every portal on a context-sensitive basis.
Selection panel for the selected action
The selection panel is available in all portals. The content of the panel adapts to your current
selection.
Change to the project view
You can use the "Project view" link to change to the project view.
Display of the project that is currently open
Here, you can obtain information about which project is currently open.
See also
Project tree (Page 168)
Basics of the work area (Page 171)
Inspector window (Page 179)
Basics on task cards (Page 181)
Details view (Page 185)
6.1.2.3 Project view
Purpose of the project view
The project view is a structured view of all components of the project.
Introduction to the TIA Portal
6.1 User interface and operation
STEP 7 Basic V12.0
System Manual, 01/2013, 165
Layout of the project view
The following figure shows an example of the components of the project view:
1
13
2
3
5
4
6
7
8
8
9
10 11 12
Title bar
Menu bar
Toolbar
Project tree (Page 168)
Reference projects (Page 183)
Details view (Page 185)
Work area (Page 181)
Dividers
Inspector window (Page 179)
Changing to the Portal view (Page 164)
Editor bar
Status bar with progress display
Task cards (Page 181)
Introduction to the TIA Portal
6.1 User interface and operation
STEP 7 Basic V12.0
166 System Manual, 01/2013,
Title bar
The name of the project is displayed in the title bar.
Menu bar
The menu bar contains all the commands that you require for your work.
Toolbar
The toolbar provides you with buttons for commands you will use frequently. This gives you
faster access to these commands.
Dividers
Dividers separate individual components of the program interface. The arrows on the dividers
allow you to display and hide the adjacent sections of the user interface.
Changing to the portal view
You can use the "Portal view" link to change to the portal view.
Editor bar
The Editor bar displays the open editors. If you have opened a lot of editors, they are shown
grouped together. You can use the Editor bar to change quickly between the open elements.
Status bar with progress display
In the status bar, you will find the progress display for processes that are currently running in
the background. This also includes a progress bar that shows the progress graphically. Hover
the mouse pointer over the progress bar to display a tooltip providing additional information
on the active background process. You can cancel the background processes by clicking the
button next to the progress bar.
If no background processes are currently running, the status bar displays the last generated
alarm.
See also
Basics of the work area (Page 171)
6.1.2.4 Library view
Function of the library view
The library view provides an overview of the elements in the project library and the open global
libraries. You can switch to the library view using the "Libraries" task card.
Introduction to the TIA Portal
6.1 User interface and operation
STEP 7 Basic V12.0
System Manual, 01/2013, 167
See also: Overview of the library view (Page 301)
6.1.2.5 Project tree
Function of the project tree
Using the project tree features gives you access to all components and project data. You can
perform the following tasks in the project tree:
Add new components
Edit existing components
Scan and modify the properties of existing components
You can select the objects of the project tree either with the mouse or via the keyboard by
typing the first letter of the desired object. If more than one object begins with the same letter,
the next lower object is selected. The project tree must be the focused user interface element
in order for you to select an object with its initial letter.
Introduction to the TIA Portal
6.1 User interface and operation
STEP 7 Basic V12.0
168 System Manual, 01/2013,
Layout of project tree
The following figure shows an example of the project tree components:
1
2
3
4
5
6
7
8
9
Introduction to the TIA Portal
6.1 User interface and operation
STEP 7 Basic V12.0
System Manual, 01/2013, 169
Title bar
Toolbar
Project
Devices
Common data
Documentation settings
Languages & resources
Online access
Card Reader / USB memory
Title bar
The title bar of the project tree has a button for automatically and manually collapsing the
project tree. Once it is collapsed manually, the button is "Reduced" to the left-hand margin. It
changes from an arrow pointing left to one that is pointing right, and can now be used to reopen
the project tree. You can use the "Reduce automatically" button collapse to project tree
automatically when you do not need it.
See also: Maximizing and minimizing the work area (Page 173)
Toolbar
You can do the following tasks in the toolbar of the project tree:
Create a new user folder; for example, in order to group blocks in the "Program blocks"
folder.
Navigate forward to the source of a link and back to the link itself.
There are two buttons for links in the project tree. You can use these to navigate from the
link to the source and back.
Show an overview of the selected object in the work area.
When the overview is displayed, the lower-level objects and actions of the elements in the
project tree are hidden.
Project
You will find all the objects and actions related to the project in the "Project" folder, e.g.:
Devices
Languages & resources
Online access
Device
There is a separate folder for each device in the project, which has an internal project name.
Objects and actions belonging to the device are arranged inside this folder.
Introduction to the TIA Portal
6.1 User interface and operation
STEP 7 Basic V12.0
170 System Manual, 01/2013,
Common data
This folder contains data that you can use across more than one device, such as common
message classes, logs, scripts and text lists.
Documentation settings
In this folder, you can specify the layout for project documentation to be printed at a later point.
Languages & resources
You can determine the project languages and texts in this folder.
Online access
This folder contains all the interfaces of the programming device / PC, even if they are not
used for communication with a module.
Card Reader / USB memory
This folder is used to manage all card readers an other USB storage media connected to the
programming device / PC.
See also
Portal view (Page 164)
Project view (Page 165)
Basics of the work area (Page 171)
Inspector window (Page 179)
Basics on task cards (Page 181)
Details view (Page 185)
6.1.2.6 Work area
Basics of the work area
Function of the work area
The objects that you can open for editing purposes are displayed in the work area. These
objects include, for example:
Editors and views
Tables
You can open several objects. However, normally it is only possible to see one of these at a
time in the work area. All other objects are displayed as tabs in the Editor bar. If, you would
Introduction to the TIA Portal
6.1 User interface and operation
STEP 7 Basic V12.0
System Manual, 01/2013, 171
like to view two objects at the same time when performing certain tasks, you can tile the work
area either horizontally or vertically or undock elements of the work area. If no objects are
open, the work area will be empty.
Layout of the work area
The following figure shows an example of a vertically split work area:
1
2
3
4
Title bar of left-hand editor
Work area of left-hand editor
Title bar of right-hand editor
Work area of right-hand editor
Introduction to the TIA Portal
6.1 User interface and operation
STEP 7 Basic V12.0
172 System Manual, 01/2013,
See also
Maximizing and minimizing the work area (Page 173)
Splitting the work area (Page 175)
Floating the work area elements (Page 175)
Using grouped elements of the work area (Page 176)
Minimizing and maximizing elements of the work area (Page 178)
Switching between the elements in the work area (Page 178)
Saving a layout of editors and tables (Page 192)
Save user interface layout (Page 189)
Maximizing and minimizing the work area
You have the option to adapt the work area to make it as large as possible. You can use the
following function for this:
Maximizing the work area
You can close the task cards, project tree and inspector window with a single click. This
increases the size of the work area. You can minimize the work area again at any time in
order to return to the previous view.
Collapsing task cards, project tree, and Inspector window automatically
You can use the "Collapse automatically" option for the task cards, project tree, and
Inspector window. This function causes these items to collapse automatically when you
don't need them.
Maximizing and minimizing the work area
To maximize the work area, follow these steps:
1. Open an element such as an editor or a table.
The element appears in the work area.
2. Click the "Maximize" button in the title bar of the element.
The task cards, project tree and inspector window collapse, and the work area is shown
with its maximum dimensions.
To minimize the work area again, follow these steps:
Introduction to the TIA Portal
6.1 User interface and operation
STEP 7 Basic V12.0
System Manual, 01/2013, 173
1. Click the "Embed" button in the title bar of the displayed element.
This restores the view that existed before the work area was maximized. That is, if the task
cards, project tree, or Inspector window were expanded before, they will be expanded
again.
Collapsing task cards, project tree, and Inspector window automatically
To collapse the task cards automatically, follow these steps:
1. Click "Collapse automatically" in the title bar of the task cards.
The task cards collapse when you click anywhere outside the task cards.
2. To use the task cards, click the collapsed task cards.
3. The task cards expand and are available for use. The "Collapse automatically" option
remains enabled.
To collapse the project tree automatically, follow these steps:
1. Click "Collapse automatically" in the title bar of the project tree.
The project tree collapses when you click anywhere outside the project tree.
2. To use the project tree, click the collapsed project tree.
The project tree expands and is available for use. The "Collapse automatically" option
remains enabled.
To collapse the Inspector window automatically, follow these steps:
1. Click "Collapse automatically" in the title bar of the Inspector window.
The Inspector window collapses when you click anywhere outside the Inspector window.
2. To use the Inspector window, click the collapsed Inspector window.
The Inspector window expands and is available for use. The "Collapse automatically" option
remains enabled.
To disable the automatic collapse option, follow these steps:
1. Click "Expand permanently" again in the relevant window.
The Collapse automatically" option is disabled, and the window remains expanded.
See also
Basics of the work area (Page 171)
Splitting the work area (Page 175)
Floating the work area elements (Page 175)
Using grouped elements of the work area (Page 176)
Minimizing and maximizing elements of the work area (Page 178)
Switching between the elements in the work area (Page 178)
Saving a layout of editors and tables (Page 192)
Introduction to the TIA Portal
6.1 User interface and operation
STEP 7 Basic V12.0
174 System Manual, 01/2013,
Splitting the work area
You can split the work area vertically or horizontally.
Procedure
To split the work area vertically or horizontally, follow these steps:
1. In the "Window" menu, select the "Split editor space vertically" or "Split editor space
horizontally" command.
The element you have clicked and the next element in the Editor bar will be displayed either
next to one another or one above the other.
Note
If no elements are open in the work area, the "Split editor space vertically" and "Split editor
space horizontally" functions will not be available.
See also
Basics of the work area (Page 171)
Maximizing and minimizing the work area (Page 173)
Floating the work area elements (Page 175)
Using grouped elements of the work area (Page 176)
Minimizing and maximizing elements of the work area (Page 178)
Switching between the elements in the work area (Page 178)
Saving a layout of editors and tables (Page 192)
Floating the work area elements
You can float work area elements in their own separate window:
Editors
Tables
Setting windows
Task cards
Inspector window
You can embed floating elements again in the work area at any time.
Introduction to the TIA Portal
6.1 User interface and operation
STEP 7 Basic V12.0
System Manual, 01/2013, 175
Floating the work area elements
To float work area elements, follow these steps:
1. Click the "Float" button in the title bar of the element.
The element will be released from the work area and displayed in its own window. You can
now place the window wherever you wish. If you have minimized the window, you can
restore it via the editor bar.
Embedding elements in the work area
To embed elements in the work area again, follow these steps:
1. Click the "Embed" button in the title bar of the element.
The element will appear in the work area again.
See also
Basics of the work area (Page 171)
Maximizing and minimizing the work area (Page 173)
Splitting the work area (Page 175)
Using grouped elements of the work area (Page 176)
Minimizing and maximizing elements of the work area (Page 178)
Switching between the elements in the work area (Page 178)
Saving a layout of editors and tables (Page 192)
Using grouped elements of the work area
If you open more than five elements of the same type, e.g., editors or tables, they are grouped
in the editor bar. You can use these groups as follows:
Displaying individual elements of a group
Displaying all elements of a group in separate windows
Embedding all displayed elements of a group in the work area
Minimizing all displayed elements
Closing all elements of a group
Displaying individual elements of a group
To display individual elements of a group, follow these steps:
1. In the editor bar, click the group containing the element you want to display.
All list of all available elements of the group is displayed.
2. Click the element that you want to display.
Introduction to the TIA Portal
6.1 User interface and operation
STEP 7 Basic V12.0
176 System Manual, 01/2013,
Displaying all elements of a group in separate windows
To display all elements of a group in separate windows, follow these steps:
1. In the editor bar, right-click the group whose elements you want to display.
2. Select "Restore group" in the shortcut menu.
All elements of the group are displayed in separate, overlapping windows. Move the
windows in order to see the individual element, or choose an element via the group in the
editor bar.
Embedding all displayed elements of a group in the work area
To embed all elements of a group displayed in separate windows in the work area again, follow
these steps:
1. In the editor bar, right-click the group whose elements you want to embed.
2. Select "Embed group" in the shortcut menu.
All elements of the group are embedded in the work area again.
Minimizing all displayed elements
To minimize all elements of a group, follow these steps:
1. In the editor bar, right-click the group whose elements you want to minimize.
2. Select "Minimize group" in the shortcut menu.
All elements of the group are minimized. However, the minimized elements remain open
and can be quickly maximized again via the group in the editor bar.
Closing all elements of a group
To close all elements of a group, follow these steps:
1. In the editor bar, right-click the group whose elements you want to close.
2. Select "Close group" in the shortcut menu.
All elements of the group are closed. The group is removed.
See also
Basics of the work area (Page 171)
Maximizing and minimizing the work area (Page 173)
Splitting the work area (Page 175)
Floating the work area elements (Page 175)
Minimizing and maximizing elements of the work area (Page 178)
Switching between the elements in the work area (Page 178)
Saving a layout of editors and tables (Page 192)
Introduction to the TIA Portal
6.1 User interface and operation
STEP 7 Basic V12.0
System Manual, 01/2013, 177
Minimizing and maximizing elements of the work area
You can minimize the elements that are open in the work area, such as editors or tables, as
needed. However, an element remains open even if it has been minimized, and can quickly
be maximized again using the editor bar.
Minimizing elements in the work area
To minimize elements in the work area, follow these steps:
1. Click the "Minimize" button in the title bar of the element.
The element is minimized, but can still be accessed via the editor bar.
To minimize all elements at the same time, follow these steps:
1. In the "Window" menu, select the "Minimize all" command.
Maximizing elements in the work area
To maximize elements in the work area again, follow these steps:
1. Click the required element in the editor bar.
The element is maximized and appears in the work area.
See also
Basics of the work area (Page 171)
Maximizing and minimizing the work area (Page 173)
Splitting the work area (Page 175)
Floating the work area elements (Page 175)
Using grouped elements of the work area (Page 176)
Switching between the elements in the work area (Page 178)
Saving a layout of editors and tables (Page 192)
Switching between the elements in the work area
You can switch between the elements in the work area at any time.
Introduction to the TIA Portal
6.1 User interface and operation
STEP 7 Basic V12.0
178 System Manual, 01/2013,
Switching between the elements in the work area
To switch to the previous or next editor, follow these steps:
1. In the "Window" menu, select the "Next editor" or "Previous editor" command.
The next or previous editor will be displayed.
See also
Basics of the work area (Page 171)
Maximizing and minimizing the work area (Page 173)
Splitting the work area (Page 175)
Floating the work area elements (Page 175)
Using grouped elements of the work area (Page 176)
Minimizing and maximizing elements of the work area (Page 178)
Saving a layout of editors and tables (Page 192)
6.1.2.7 Inspector window
Function of the Inspector window
Additional information on an object selected or on actions executed are displayed in the
inspector window.
Layout of the Inspector window
The following figures show the components of the Inspector window:
"Properties" tab
"Info" tab
"Diagnostics" tab
Navigation within the tabs:
Area navigation within the "Properties" tab
Lower-level tabs in the "Info" and "Diagnostics" tabs
"Properties" tab
This tab displays the properties of the object selected. You can change editable properties
here.
"Info" tab
This tab displays additional information on the object selected, as well as alarms on the actions
executed (such as compiling).
"Diagnostics" tab
This tab provides information on system diagnostics events, configured alarm events, and
connection diagnostics.
Navigation within the tabs
You can use area navigation and the lower-level tabs to display the information you require
within the tabs.
Introduction to the TIA Portal
6.1 User interface and operation
STEP 7 Basic V12.0
180 System Manual, 01/2013,
See also
Project tree (Page 168)
Basics of the work area (Page 171)
Portal view (Page 164)
Project view (Page 165)
Basics on task cards (Page 181)
Details view (Page 185)
6.1.2.8 Task cards
Basics on task cards
Function of task cards
Depending on the edited or selected object, task cards that allow you perform additional actions
are available. These actions include:
Selecting objects from a library or from the hardware catalog
Searching for and replacing objects in the project
Dragging predefined objects to the work area
The task cards available can be found in a bar on the right-hand side of the screen. You can
collapse and reopen them at any time. Which task cards are available depends on the products
installed. More complex task cards are divided into panes that you can also collapse and
reopen.
Introduction to the TIA Portal
6.1 User interface and operation
STEP 7 Basic V12.0
System Manual, 01/2013, 181
Layout of task cards
The following figure shows an example of the bar with the task cards:
Title bar
Content of the selected object
Title bar
The arrow for closing the details view is located in the title bar of the details view. After it has
closed, the direction in which the arrow is pointing changes from left to right. It can now be
used to reopen the details view.
Objects
The displayed content varies depending on the selected object. You can move the content of
objects from the details view to the required location using drag-and-drop.
Introduction to the TIA Portal
6.1 User interface and operation
STEP 7 Basic V12.0
System Manual, 01/2013, 185
See also
Project tree (Page 168)
Basics of the work area (Page 171)
Inspector window (Page 179)
Basics on task cards (Page 181)
Portal view (Page 164)
Project view (Page 165)
6.1.2.11 Overview window
Overview window
Functions of the Overview window
The Overview window supplements the project tree. The Overview window shows the contents
of the folder currently selected in the project tree.
In addition, you can perform the following actions in the Overview window:
Open objects
Display and edit the properties of objects in the Inspector window
Rename objects
Call object-specific actions from the shortcut menu
Compare objects side by side
Perform various object operations, such as inserting objects from the library via drag-and-
drop and moving, copying, pasting, and deleting objects
Introduction to the TIA Portal
6.1 User interface and operation
STEP 7 Basic V12.0
186 System Manual, 01/2013,
Layout of the Overview window
The following figure shows the components of the Overview window:
5 6 6
7
1
2 3 4
Overview window
Switch to the Details view
Switch to the List view
Switch to the Icon view
Move to higher level
Split the overview window in two. Either the right or left half of the overview window is synchronized. Clicking again
cancels the split.
Contents of the object selected in the project tree.
Introduction to the TIA Portal
6.1 User interface and operation
STEP 7 Basic V12.0
System Manual, 01/2013, 187
Display forms of the Overview window
The content of the Overview window can be displayed as follows:
Details view
The objects are displayed in a list with additional information, such as the date of the last
change.
List view
The objects are displayed in a simple list.
Icon view
The objects are displayed as icons according to category.
See also
Comparing objects in the overview window (Page 188)
Sorting the detail view of the overview window (Page 188)
Overview of the library view (Page 301)
Comparing objects in the overview window
You can display the contents of two folders or objects side by side in the Overview window.
The Overview window is split in half and you can display different contents on the left and right
sides.
In addition, you can use a drag-and-drop operation to move objects between the split windows.
Thus, for example, you can move contents from one window to the other.
Procedure
To split the Overview window in half or cancel the split, follow these steps:
1. In the toolbar, click on the "Synchronize left side" or "Synchronize right side" icon to split
the overview window. Either the left or the right side of the overview window synchronized
with the contents of the selected object in the project tree.
2. To cancel the split, click again on the previously selected icon.
See also
Overview window (Page 186)
Sorting the detail view of the overview window
In the details view of the overview window, you can display more columns containing additional
information on an object and then hide them again. The columns available depend on the
selected object. You can also sort the table by the individual columns in ascending or
descending order.
Introduction to the TIA Portal
6.1 User interface and operation
STEP 7 Basic V12.0
188 System Manual, 01/2013,
Showing or hiding columns
To show or hide additional table columns, follow these steps:
1. Right-click the title bar of the table.
2. Select the "Show/Hide" command in the shortcut menu, and select the columns you want
to display.
Sorting a table in ascending or descending order
To sort the table by a column in ascending or descending order, follow the steps below:
1. Click the table header of a column if you want to sort the column in ascending order.
2. Click again on the same column of the table header to sort the column in descending order.
3. Click a third time on the table header of the same column to cancel the sorting.
See also
Overview window (Page 186)
6.1.2.12 User interface layout
Save user interface layout
Options for saving the user interface layout
When you make a change to the user interface, this is retained even after a restart of the TIA
portal. A change to the user interface layout includes, for example, moving a window or
adjusting the size of an editor.
In addition to the automatic saving of the user interface layout, you have the option of saving
certain layouts:
Saving the window layout
You can save the layouts of the windows and editors of the TIA portal manually and restore
these at a later time. It is possible to call five window layouts using a key combination.
Use this function, for example, if you are work with a notebook which you connect to an
external monitor when necessary. You can create a window layout for mobile use on the
notebook display and another layout for when you work at the office with an external monitor.
Save the layout within editors
With some editors, you can adjust the display. You can, for example, adjust the width of
tables or show or hide individual table columns.
Introduction to the TIA Portal
6.1 User interface and operation
STEP 7 Basic V12.0
System Manual, 01/2013, 189
See also
Save window layout (Page 190)
Load window layout (Page 190)
Managing window layouts (Page 191)
Saving a layout of editors and tables (Page 192)
Resetting the user interface layout (Page 192)
Basics of the work area (Page 171)
Save window layout
You can save the current window layout in order to call it again in the same form at a later time.
Procedure
To save a window layout, follow these steps:
1. Arrange all windows in the way in which you want to save them.
2. In the "Window" menu, select the "Save window layout as" command.
The "Save window layout" dialog box appears.
3. Enter a name for the window layout in the "Name" field.
4. Enter a description of the window layout in the "Description" field in order to be able to
identify the window layout more easily later.
5. Click "Save".
Result
The new window layout is saved in the last position after the existing saved window layouts.
The first five window layouts can be called using a key combination.
See also
Save user interface layout (Page 189)
Load window layout
If you have already saved a window layout, you can load this, allowing you to quickly adjust
your work environment to the respective conditions. You can load the first five window layouts
using quick access via the "Window" menu or via a key combination.
If you load a window layout and then make changes to the arrangement of the window, you
can restore the originally saved window layout.
Introduction to the TIA Portal
6.1 User interface and operation
STEP 7 Basic V12.0
190 System Manual, 01/2013,
Using quick access to load window layouts 1 to 5
To load one of the first five saved window layouts, follow these steps:
1. In the "Window" menu, select a window layout or select the key combination <Alt+Shift+[1 ...
5]>.
Loading additional window layouts
To load a window layout that is not among the first five window layouts, follow these steps:
1. In the "Window" menu, select the "Additional window layouts" command.
The "Manage window layouts" dialog box appears.
2. Select the desired window layout.
3. Click "OK".
Restore window layout
To go back to a saved window layout, follow these steps:
1. In the "Window" menu, select the "Restore window layout" command or select the key
combination <Alt+Shift+0>.
See also
Save user interface layout (Page 189)
Managing window layouts
You can carry out the following actions with existing window layouts:
Changing the order of window layouts
The order of the window layouts is important, as the first five window layouts can be called
directly via the "Window" menu and via a key combination.
Select a window layout
If a window layout is not one of the first five window layouts, you can call it using the "Manage
window layouts" dialog box.
Deleting window layouts
Procedure
To manage the existing window layouts, follow these steps:
1. In the "Window" menu, select the "Manage window layouts" command.
The "Manage window layouts" dialog box appears.
2. Select the window layout which you want to modify.
3. Click the "Up" or "Down" symbol to move the window layout up or down.
Introduction to the TIA Portal
6.1 User interface and operation
STEP 7 Basic V12.0
System Manual, 01/2013, 191
4. Click the "Delete" symbol to delete the selected window layout.
5. Click "OK".
The selected window layout is activated.
See also
Save user interface layout (Page 189)
Saving a layout of editors and tables
You have the option of adapting editors and tables to meet your requirements. For example,
you can hide columns in tables that you don't need. You can then save your customized view.
Procedure
To save the layout of editors and tables in the work area, follow these steps:
1. Adapt the editor or table according to your requirements.
2. Click the "Remember Layout" button in the editor or table.
Result
The layout is saved. When you reopen the editor or table, this layout will be used.
See also
Basics of the work area (Page 171)
Maximizing and minimizing the work area (Page 173)
Splitting the work area (Page 175)
Floating the work area elements (Page 175)
Using grouped elements of the work area (Page 176)
Minimizing and maximizing elements of the work area (Page 178)
Switching between the elements in the work area (Page 178)
Save user interface layout (Page 189)
Resetting the user interface layout
Every change you make to the layout of the user interface is saved. The changes are thus
available even after a restart of the TIA Portal. For example, if you change the height and width
of a text editor or the division of a table, your changes are retained so that you don't have to
re-customize elements every time.
In some cases, however, it may be helpful to restore the original layout settings; for example,
if another user prefers a different arrangement of the user interface.
Introduction to the TIA Portal
6.1 User interface and operation
STEP 7 Basic V12.0
192 System Manual, 01/2013,
Procedure
To reset the user interface settings to the default, follow these steps:
1. Select the "Settings" command in the "Options" menu.
The "Settings" window is displayed in the work area.
2. Select the "General" group in the area navigation.
3. Click the "Reset to default" button under "Reset to default > Editor layout".
Result
The default settings for the user interface are restored.
See also
Overview of the program settings (Page 159)
Save user interface layout (Page 189)
6.1.3 Keyboard operation in the TIA Portal
6.1.3.1 Operating the TIA Portal with the keyboard
You can navigate through the TIA Portal using the keyboard, for example if you do not have
a mouse available at the given moment. Many functions are also accessible via keyboard
shortcuts. You can find an overview of all keyboard shortcuts in the settings for the TIA Portal.
In the following sections, you will learn how to navigate in the TIA Portal using the keyboard,
edit objects and customize the TIA Portal to your needs.
See also
Displaying an overview of all keyboard shortcuts (Page 193)
6.1.3.2 Displaying an overview of all keyboard shortcuts
You can display an overview of all keyboard shortcuts.
Procedure
To display an overview of all available keyboard shortcuts, follow these steps:
1. Select the "Settings" command in the "Options" menu.
The settings of the TIA Portal are displayed.
2. Open the "Keyboard shortcuts" entry in the area navigation.
You can see an overview of all keyboard shortcuts, which are valid for the currently installed
products.
Introduction to the TIA Portal
6.1 User interface and operation
STEP 7 Basic V12.0
System Manual, 01/2013, 193
6.1.3.3 Basic functions of the TIA Portal
Below, you will learn how you can use the basic functions of the TIA Portal using only your
keyboard.
Operating basic functions of the TIA Portal with a keyboard
The following table shows how you can access basic functions of the TIA Portal with keyboard
shortcuts:
Function Keyboard shortcuts Menu command
Switch between the project view and the portal view <Alt+F7>
Open the Help system
If you need help on the TIA Portal, press <F1>.
<F1> Help > Show help
Cancel the current action <Esc>
Find <Ctrl+F>
Replace an object <Ctrl+H>
Find next
If you have started a search, you can jump to the next hit with <F3>
<F3>
Print object <Ctrl+P> Project > Print
Operating menus
The following table shows how you can navigate through menus using the keyboard:
Function Keyboard shortcuts
Start keyboard operation in the menu
You can access the menu using the <Alt> key and then continue to navigate with the arrow keys
to scroll through the menu. Confirm your selection of the menu command with <Return>.
<Alt>
Go directly to a specific menu
You can go directly to an individual menu command by holding down the <Alt> key. There is an
underlined letter for each menu command. Press the <Alt> key along with the underlined letter.
<Alt+underlined letter in
respective menu>
Open shortcut menu of an object
With the shortcut menu key (on Microsoft Windows compatible keyboards), you can open the
shortcut menu of the selected object. Alternatively, you can use <Shift+F10> if you are not using
a Microsoft Windows compatible keyboard. You can use the arrow keys to scroll through the
shortcut menu and select a menu command with <Return>.
<Shortcut menu key>
Alternative: <Shift+F10>
Introduction to the TIA Portal
6.1 User interface and operation
STEP 7 Basic V12.0
194 System Manual, 01/2013,
Operating expandable elements
The following table shows how you can operate expandable elements using the keyboard:
Function Keyboard shortcuts
Expand a folder in a tree
With <Arrow right>, for example, you expand a folder in the project tree.
<Arrow right>
Close a folder in a tree
With <Arrow left>, for example, you collapse a folder in the project tree.
<Arrow left>
Open a drop-down list
You can open drop-down lists with <F4> and then navigate with the arrow keys to scroll through
the drop-down list. Finally, press the <Return> key to confirm your selection.
<F4>
Open autocompletion <Ctrl+Space>
<Ctrl+I>
Show parameter list <Ctrl+Shift+Space>
Show object selection <Ctrl+J>
6.1.3.4 Using project-related functions
Editing a project
Function Keyboard shortcuts Menu command
Open a project <Ctrl+O> Project > Open
Close a project <Ctrl+W> Project > Close
Save a project <Ctrl+S> Project > Save
Save a project under a different name <Ctrl+Shift+S> Project > Save as
Delete a project <Ctrl+E> Project > Delete project
Print project <Ctrl+P> Project > Print
Undo last action <Ctrl+Z> Edit > Undo
Redo last action <Ctrl+Y> Edit > Redo
Calling up the help function
Function Keyboard shortcuts Menu command
Calling up the help function <F1> or <Shift+F1> Help > Show help
6.1.3.5 Arranging windows
Below, you will learn how to open and close individual windows of the TIA Portal and save
window layouts using the keyboard .
Introduction to the TIA Portal
6.1 User interface and operation
STEP 7 Basic V12.0
System Manual, 01/2013, 195
Opening and closing windows
The following table shows how you can open and close windows with keyboard shortcuts:
Function Keyboard shortcuts Menu command
Open/close project tree <Ctrl+1> View > Project tree
Opening/closing the detailed view <Ctrl+4> View > Details view
Opening/closing the overview <Ctrl+2> View > Overview
Opening/closing a task card <Ctrl+3> View > Task card
Open libraries <Ctrl+Shift+L>
Open hardware catalog
If you are in the device or network view, the hardware
catalog opens.
<Ctrl+Shift+C>
Open/close inspector window <Ctrl+5> View > Inspector window
Open the "Properties" tab in the inspector window <Ctrl+6>
Open the "Info" tab in the Inspector window <Ctrl+7>
Open the "Diagnostics" tab in the Inspector window <Ctrl+8>
Display or hide reference projects <Ctrl+9>
Display the on-screen keyboard
You can display a keyboard on the screen, for example,
to operate with a touch screen.
<Ctrl+Shift+K>
Close all editors <Ctrl+Shift+F4> Window > Close all
Using saved window layouts
You can save individual window arrangements and restore them at a later point in time. The
following table shows how you to access saved window layouts with keyboard shortcuts:
Function Keyboard shortcuts Menu command
Restore active window layout
If you use a saved window layout and have made
changes to the program interface in the meantime, you
can restore the original state of the active window layout
with <Alt+Shift+0>.
<Shift+Alt+0> Window > Restore window
layout
Load window layout
You can use <Alt+Shift+[number of the window layout]>
to activate the first of the five saved window layouts.
<Shift+Alt+[Number of the
window layout]>
Window > Window layout 1 to
5
6.1.3.6 Navigating through the program interface
The TIA Portal is divided into several interface areas, for example, individual windows, toolbars
and editors. If you want to work with the keyboard within an interface area, you first have to
place the focus on it. Below, you will learn how to place the focus on individual interface areas
using the keyboard. You will also learn how to move within an interface area in the TIA Portal
using the keyboard.
Introduction to the TIA Portal
6.1 User interface and operation
STEP 7 Basic V12.0
196 System Manual, 01/2013,
Switching between interface areas and editors
The following table shows how to move between individual interface areas of the TIA Portal:
Function Keyboard shortcuts
Move clockwise between the interface areas
You can use the <F6> key to move clockwise between the various interface areas of the
TIA Portal. The interface area currently in focus is highlighted with a blue title bar. If you
are in the project tree, for example, and press the <F6> key, you jump to the currently
open editor. If you press <F6> again, and the task cards are in focus.
If you press <Shift+F6>, on the other hand, you move counterclockwise between the work
areas.
<F6>
Move counter-clockwise between the interface areas
With <Shift+F6> you move counter-clockwise between the interface areas of the TIA Portal.
<Shift+F6>
Go to the next open editor
With <Ctrl+Alt+Arrow right> you move to the next open editor. You can see the open editors
in the editor toolbar.
<Ctrl+Alt+Arrow right>
Alternative: <Ctrl+F6>
Go to the previously open editor
With <Ctrl+Alt+Arrow left> you move to the most recently open editor.
<Ctrl+Alt+Arrow left>
Alternative: <Ctrl+Shift+F6>
Go to the next higher section of the interface area
With <Shift+Esc>, you move to the next higher section of the program interface. If, for
example, you have selected a device in the project tree and you press <Shift+Esc>, the
entire project navigation is put into focus.
<Shift+Esc>
Alternative: <Alt+Arrow up>
Go to the next lower section of the interface area
With <Return>, you place the focus on the next lower section of the program interface. For
example, if you have just opened the properties of a device in the Inspector window in
order to assign parameters to the device, press <Return> to go one level deeper in the
program interface. You can then navigate to the desired parameter using the Tab key.
<Return>
Alternative: <Alt+Arrow down>
Navigation within interface areas and editors
The following table shows how you can navigate within an interface area using the keyboard:
Function Keyboard shortcuts
Jump to the next element within an interface area
You can use the Tab key to jump from one element to the next within a work area. If, for
example, you have opened the properties of a device and want to jump from one field to
the next, press the Tab key. Any changes you have made to the current text box are applied
in this case.
<Tab>
Jump to the previous element within an interface area
With <Shift+Tab>, you can jump to the previous element in a work area, for example, a
previous text box. Any changes you have made to the current text box are applied in this
case.
<Shift+Tab>
Move to the next tab within an interface area
If an interface area is divided into separate tabs, you can move between the tabs with the
shortcut keys <Ctrl+Tab>. If, for example, you are in the "Properties" tab of the Inspector
window and you want to jump to the "Info" tab, press the shortcut keys <Ctrl+Tab>.
<Ctrl+Tab>
Introduction to the TIA Portal
6.1 User interface and operation
STEP 7 Basic V12.0
System Manual, 01/2013, 197
Function Keyboard shortcuts
Go to the previous tab
With <Ctrl+Shift+Tab>, you move to the most recently open tab within an interface area.
<Ctrl+Shift+Tab>
Jumping to the toolbar of an editor
You can use the <Alt+F10> key to jump to the toolbar of an editor. For example, if you
have opened the print preview and want to switch to the next page of the printout in the
toolbar, press <Alt+F10>. Then, use the arrow keys to navigate to the appropriate icon in
the toolbar and confirm the selection with <Return>.
<Alt+F10>
Use arrows on the divider to display or hide user interface components
The table in the work area can be minimized and maximized. First, navigate to the work
area and use the Tab key to place the focus on one of the little arrows on the separator
line above the table. The arrows have the focus as soon as they are highlighted in blue.
Then, press the space bar to minimize or maximize the table.
<Space>
6.1.3.7 Customizing editors
Below, you will learn how to arrange editors using the keyboard. You will also learn how to
select the display size and the area within a graphical editor.
Arranging and customizing editors
The following table shows how to arrange open editors above and below each other or side-
by-side, and how to close an open editor:
Function Keyboard shortcuts Menu command
Close active editor <Ctrl+F4>
Split editor space vertically
If, for example, you have opened the overview window and the
network view and want to display them side-by-side, press the
<F12> key.
<F12> Window > Split editor space
vertically
Split editor space horizontally
You can display two open editors in the work area above and below
each other.
<Ctrl+F12> Window > Split editor space
horizontally
Remove window split
If you have displayed two editors in the work area horizontally or
vertically in split mode, you can remove the split with <Alt+Shift
+F12>.
<Alt+Shift+F12> Window > Unsplit editor space
Introduction to the TIA Portal
6.1 User interface and operation
STEP 7 Basic V12.0
198 System Manual, 01/2013,
Customizing the display in an editor
The following table shows how you how to zoom in and out in graphical editors and how to
move the area selection in an editor:
Function Keyboard shortcuts
Zoom in step-by-step in an editor
With <Ctrl> and the <Plus> key on the numeric keypad of the keyboard, you can zoom in
on the display of the editor.
<Ctrl+Plus>
Alternative: <Ctrl+mousewheel
up>
Zoom out step-by-step in an editor
Use the <Ctrl> and the <Minus> key on the numeric keypad of the keyboard to zoom out
of the display of the editor.
<Ctrl+Minus>
Alternative: <Ctrl+mousewheel
down>
Set view in editor to 100%
You can zoom in or out of the display in a graphical editor to set the current view to 100%
by pressing <Ctrl+0>.
<Ctrl+0>
Moving the area selection of the editor
If you hold down the spacebar, you can move the displayed section of an editor using the
mouse.
<Space>
6.1.3.8 Editing objects
Selecting objects
The following table shows how to select individual objects, for example, devices in the project
tree:
Function Keyboard shortcuts Menu command
Select an object located at the left, right, above or below <Arrow keys>
Jump to the first object within the current interface area
The first object in the interface area currently in focus is selected.
In the project tree, this would be the project node at the top, for
example.
<Home>
Jump to the last object within the current interface area
The last object in the interface area currently in focus is selected,
for example, the last item in the project tree.
<End>
Select all objects in an area
All objects in the work area currently in focus are selected.
<Ctrl+A> Edit > Select all
Select multiple objects
If you want to select several objects that are not located directly
next to each other, you first have to move the focus (gray outline
of an object) to the next desired object using <Ctrl+Arrow keys>.
The current selection is maintained. Then, press the space bar to
select the new focused object as well. Repeat this process until all
desired objects are selected.
<Ctrl+Arrow keys> +
<Space>
Introduction to the TIA Portal
6.1 User interface and operation
STEP 7 Basic V12.0
System Manual, 01/2013, 199
Editing objects
The following table provides an overview of all the keyboard shortcuts required for editing
objects:
Function Keyboard shortcuts Menu command
Insert new object
A new object is inserted depending on your current context. If, for
example, you are in the device view, the "Add Device" dialog opens
for creating a new device.
<Ctrl+N>
Open object <Return>
Rename an object <F2> Edit > Rename
Copy an object <Ctrl+C>
Alternative: <Ctrl+Ins>
Edit > Copy
Cut an object <Ctrl+X>
Alternative: <Shift+Del>
Edit > Cut
Paste an object <Ctrl+V>
Alternative: <Shift+Ins>
Edit > Paste
Delete an object <Del> Edit > Delete
Compile an object <Ctrl+B> Edit > Compile
Open properties of an object
Many objects in the TIA Portal have editable properties. Press the
shortcut keys <Alt+Enter> to display the properties of an object.
<Alt+Return> -
6.1.3.9 Text editing
Below, you will learn how to operate text editing functions using only the keyboard.
Editing text
The following table shows the basic editing functions for text:
Function Keyboard shortcuts
Switch to insert or overwrite mode <Insert>
Exit edit mode <Esc>
Delete <Del>
Delete characters <Backspace>
Confirm entry in a text box and leave the text box <Return>
Line break in a multiline text box
In a multiline text box, hold down the <Shift> button to create a line break.
<Shift+Return>
Reset input in a text box
If you are in an text box and press <Esc>, you exit the box and the changes are discarded.
<Esc>
Introduction to the TIA Portal
6.1 User interface and operation
STEP 7 Basic V12.0
200 System Manual, 01/2013,
Navigating within a text area
The following table shows how to navigate in a text area with the keyboard:
Function Keyboard shortcuts
Jump to start of line <Home>
Jump to end of line <End>
Jump to start of text <Ctrl+Home>
Jump to end of text <Ctrl+End>
Jump to the previous page <PgUp>
Jump to the next page <PgDn>
Confirm entry in a text box and leave the text box <Return>
Line break in a multiline text box <Shift+Return>
Reset input in a text box
If you are in an text box and press <Esc>, you exit the box and the changes are discarded.
<Esc>
Selecting text
The following table shows how to select text with the keyboard:
Function Keyboard shortcuts
Expand selection to the word at the left or right
The text or current text selection is marked up to the end of word. If you are at the beginning or
end of a word, the previous or next word is selected.
<Ctrl+Shift+Arrow left or
Arrow right>
Expand selection to beginning of line <Shift+Home>
Expand selection to end of line <Shift+End>
Expand selection to beginning of text
The text is selected up to the beginning or the end.
<Ctrl+Shift+Home>
Expand selection to end of text
The text is selected up to the beginning or the end.
<Ctrl+Shift+End>
6.1.3.10 Editing tables
Below, you will learn how to navigate with the keyboard in tables, edit individual fields, and
select parts of tables.
General keyboard operation in tables
The following table shows how you can edit tables using only the keyboard:
Function Keyboard shortcuts
Place a cell in edit mode <F2> or <Return>
Confirm entry and exit edit mode <Return>
Cancel editing and discard changes <Esc>
Introduction to the TIA Portal
6.1 User interface and operation
STEP 7 Basic V12.0
System Manual, 01/2013, 201
Function Keyboard shortcuts
Open drop-down list in a cell
Open the drop-down list with <F4>. Use the arrow keys to
select the desired entry and then confirm the selection with
<Return>.
<F4>
Close drop-down list in a cell and discard changes <Esc>
Navigate in tables
The following table shows how you can navigate within a table using the keyboard:
Function Keyboard shortcuts
Go to the next cell <Arrow keys>
Go to the next editable cell on the right <Tab>
Go to the next editable cell on the left <Shift+Tab>
Move a screen upwards <PgUp>
Move a screen downwards <PgDn>
Go to the first cell in the row <Home>
Go to the last cell in the row <End>
Go to the first cell in the table <Ctrl+Home>
Go to the last cell in the table <Ctrl+End>
Go to the top cell in the column <Ctrl+Arrow up>
Go to the bottom cell in the column <Ctrl+Arrow down>
Selecting areas in tables
The following table shows how you can select areas within a table using the keyboard:
Function Keyboard shortcuts
Select column <Ctrl+Space>
Select line <Shift+Space>
Select all cells <Ctrl+A>
Expand selection by one cell <Shift+arrow keys>
Extend selection up one page <Shift+PgUp>
Extend selection down one page <Shift+PgDn>
Expand selection up to the first row <Ctrl+Shift+Arrow up>
Expand selection down to the last row <Ctrl+Shift+Arrow down>
Expand selection to the first cell in the row <Ctrl+Shift+Arrow left>
Expand selection to the last cell in the row <Ctrl+Shift+Arrow right>
Introduction to the TIA Portal
6.1 User interface and operation
STEP 7 Basic V12.0
202 System Manual, 01/2013,
6.1.3.11 Using online functions
Controlling online functions with the keyboard
The following table provides an overview of the shortcut keys that you can use for the online
functions of the TIA Portal:
Function Keyboard shortcuts Menu command
Establish an online connection <Ctrl+K> Online > Go online
Go offline <Ctrl+M> Online > Go offline
Download project data to the device <Ctrl+L> Online > Download to
device
Show accessible devices
This opens a dialog showing all devices that are connected to the PG/
PC interface of the PG/PC.
<Ctrl+U> Online > Show
accessible devices
Start CPU
The CPU is set to "RUN" mode. The CPU must be online for this.
<Ctrl+Shift+E> Online > Start CPU
Stop CPU
The CPU is set to "STOP" mode. The CPU must be online for this.
<Ctrl+Shift+Q> Online > Stop CPU
Start simulation
The hardware and software of the project can be tested in a simulated
online environment, without the modules actually being online.
<Ctrl+Shift+X> Online > Simulation >
Start
6.1.3.12 Using the on-screen keyboard
Introduction
When working with the TIA portal, you also have the Microsoft on-screen keyboard available.
Displaying the on-screen keyboard
To display the on-screen keyboard, follow these steps:
1. In the "View" menu, select the "Screen keyboard" command.
Introduction to the TIA Portal
6.1 User interface and operation
STEP 7 Basic V12.0
System Manual, 01/2013, 203
Exiting the on-screen keyboard
To exit the on-screen keyboard, follow these steps:
1. In the "File" menu of the on-screen keyboard, select the "Exit" command.
6.1.4 Special features specific to the operating system
6.1.4.1 Influence of user rights
Restrictions when user rights are limited
The software provides several functions that require direct access to the hardware of the
programming device / PC and therefore also to the installed operating system. To make full
use of the range of functions, the software must cooperate closely with the operating system.
To ensure problem-free interaction, you should therefore be logged on to the operating system
with adequate user rights.
In particular, you may not be able to use functions requiring an online connection or those that
change the settings of interface cards if you work with limited user rights.
Recognizing restricted functions
You can recognize functions requiring special rights as follows:
A shield icon is displayed beside the function.
The function can be used but is regulated by the user account control.
A box is grayed out and cannot be accessed.
You require administrator privileges to access the box. In some operating system
environments, you can obtain administrator privileges by entering an administrator
password.
Note
A box being grayed out does not necessarily mean a lack of rights. You should also check
the additional information in the tooltip cascades to find out the conditions for editing the box.
Introduction to the TIA Portal
6.1 User interface and operation
STEP 7 Basic V12.0
204 System Manual, 01/2013,
6.1.4.2 Expanding user rights
Counteracting restrictions due to user rights
Certain functions may not be available if you are not logged on to the operating system with
adequate rights. You can counteract these restrictions in the following ways:
Enabling of extended rights using Windows user account control
Logging on to the operating system with administrator privileges
Using temporary administrator rights
Enabling extended rights using the Windows user account control
To be able to use a function indicated by the shield icon of the Windows user account control,
follow these steps:
1. Click on the box or button with the shield icon.
The security prompt of the Windows user account control opens.
2. Follow the instructions of the Windows user account control and, when prompted enter an
administrator password, if possible.
The function can now be used once without restrictions.
Logging on to the operating system with administrator privileges
To be able to use a function that is disabled due to lack of user rights, follow these steps:
1. Close the software.
2. Log off from the operating system.
3. Log on to the operating system with administrator privileges.
4. Restart the software.
Using temporary administrator rights
To obtain administrator privileges temporarily, follow these steps:
1. Click the "Change settings" button. You will find this button in dialogs that allow the
temporary assignment of administrator privileges.
An operating system dialog box for entering an administrator password opens.
2. Enter an administrator password.
The settings can be temporarily changed. When you call the dialog again, the procedure must
be repeated.
Note
This function is not supported by all operating systems. If no "Change settings" button is
present or the button is grayed out, you will need to log on to the operating system with
administrator privileges instead.
Introduction to the TIA Portal
6.1 User interface and operation
STEP 7 Basic V12.0
System Manual, 01/2013, 205
6.2 Help on the information system
6.2.1 General remarks on the information system
Quick answers to your questions
A comprehensive Help system is available for solving your tasks. It describes basic concepts,
instructions and functions. While working with the program, you also receive the following
support:
Roll-out for correct inputs in dialog boxes
Tooltips for information on elements of the user interface, for example text boxes, buttons
and icons. Some of the tooltips are supplemented by cascades containing more precise
information.
Help on the current context, on menu commands for example when you click on the keys
<F1> or <Shift+F1>.
The following figure shows an example of a cascading tooltip (top) and a roll-out (bottom):
Help
The Help system describes concepts, instructions and functions. It also contains reference
information and examples. The help opens in a separate window.
A navigation pane appears on the left side of the help window. You can also hide the navigation
pane to make room on the screen. The navigation pane provides you with the following
functions:
Table of contents
Search in the index
Full text search of the entire Help
Favorites
Introduction to the TIA Portal
6.2 Help on the information system
STEP 7 Basic V12.0
206 System Manual, 01/2013,
Identification of the topics in the Help according to the type of information
The help topics are identified by different symbols depending on the type of information they
contain.
Symbol Information type Explanation
Operating instructions Describes the steps to follow in order to carry out a particular task.
Example Contains a concrete example to explain the task.
Factual information Contains background information that you need to know to carry
out a task.
Reference Contains comprehensive reference information to refer back to.
Identification of the topics in the Help according to the target system
Depending on the products that are installed, the help system may contain sections that apply
only to specific devices. To be able to recognize such sections at a glance, you will find a note
in brackets in the table of contents. The search results in the full text search and in the index
are marked in the same way if they only apply to a specific device.
Roll-out
Certain text boxes offer information that rolls out and helps you to enter valid parameters and
values. The roll-out informs you about permissible value ranges and data types of the text
boxes.
The following figure shows a roll-out (yellow) and a roll-out error message (red), which indicates
an invalid value:
Tooltip
Interface elements offer you a tooltip for easier identification.
Introduction to the TIA Portal
6.2 Help on the information system
STEP 7 Basic V12.0
System Manual, 01/2013, 207
Tooltips, which have an arrow icon on the left, contain additional information in tooltip
cascades. If you position the mouse pointer briefly over the tooltip or click the arrow icon, this
information is displayed. The automatic display of tooltip cascades can be disabled.
If additional information is contained in the Help system, a link appears to the corresponding
Help topic in the cascade. If you click on the link, the corresponding topic opens in Help.
The following figure shows a tooltip with opened cascade:
See also
Configuring the display of tooltips and tooltip cascades (Page 212)
Introduction to the TIA Portal
6.2 Help on the information system
STEP 7 Basic V12.0
208 System Manual, 01/2013,
6.2.2 Opening the Help system
Opening the Help system
You can open the Help system in the following ways:
1. In the "Help" menu, select the "Show help" command or press <F1> to display the
corresponding help for the current context.
Or
1. Click on the link in a tooltip cascade to go directly to an additional point in the Help system.
6.2.3 Searching the Help system for keywords
Searching for keywords in the help text
To search the help topics for predefined keywords, follow these steps:
1. Click the "Show/hide table of contents" button in the help toolbar to display the table of
contents.
The table of contents is displayed and the "Index", "Search" and "Favorites" tabs are visible.
2. Open the "Index" tab.
3. Enter the search term in the input box or select the search term from the list of key words.
4. Click "Display".
6.2.4 Full-text searches
Full-text searches
To search the entire text for specific words, follow these steps:
1. Click the "Show/hide table of contents" button in the help toolbar to display the table of
contents.
The table of contents is displayed and the "Index", "Search" and "Favorites" tabs are visible.
2. Open the "Search" tab.
3. Type in your search term in the text box.
4. Refine your search if necessary using additional criteria:
Select "Search previous results" to start an additional search operation of your last
search results only.
Select "Search for similar words" to find words that differ only slightly from your search
term.
Select "Search titles only" to obtain only results that contain your search term in the title.
The contents of the Help topics are ignored during the search.
Introduction to the TIA Portal
6.2 Help on the information system
STEP 7 Basic V12.0
System Manual, 01/2013, 209
5. Click on the arrow button to the right of the search field to use logic operations. The following
logic operations are available:
Combine two or more search terms using the "AND" operator to find only Help topics
that contain all the search terms in the text.
Combine two or more search terms using the "OR" operator to find only Help topics that
contain one or more of the search terms in the text.
Combine two or more search terms using the "NEAR" operator to find only Help topics
that contain terms in close proximity to each other (eight words).
Precede a word with the "NOT" operator to exclude Help topics from the search that
contain this word.
6. Click on "List topics" to start the search.
The results are now listed with title, position and ranking. The "Position" column shows the
section in which the Help topic found is located. Sorting according to ranking is based on
the position of the Help topics found in the table of contents and based on the number of
hits in the Help topics.
6.2.5 Using favorites
Using favorites
You can save individual help topics as favorites. This saves you searching for the help topic
a second time.
Saving favorites:
To save a page as a favorite, follow these steps:
1. Open the help topic or the chapter you want to save as a favorite.
2. Click the "Show/hide table of contents" button in the help toolbar to display the table of
contents.
The table of contents is displayed and the "Index", "Search" and "Favorites" tabs are visible.
3. Open the "Favorites" tab.
4. Click the "Add" button.
The help topic or chapter is saved as a favorite and is available the next time you open the
help system.
Calling up favorites:
To call up a page from the favorites, follow these steps:
1. Click the "Show/hide table of contents" button in the help toolbar to display the table of
contents.
The table of contents is displayed and the "Index", "Search" and "Favorites" tabs are visible.
2. Open the "Favorites" tab.
Introduction to the TIA Portal
6.2 Help on the information system
STEP 7 Basic V12.0
210 System Manual, 01/2013,
3. Select the topic you want to open from the list.
4. Click the "Display" button.
Deleting favorites
To delete an entry from the favorites, proceed as follows:
1. Click the "Show/hide table of contents" button in the help toolbar to display the table of
contents.
The table of contents is displayed and the "Index", "Search" and "Favorites" tabs are visible.
2. Open the "Favorites" tab.
3. Select the topic you want to remove from the list.
4. Click the "Remove" button.
6.2.6 Printing help topics
Printing information
You can either print all the contents of the Help system or individual topics only.
Procedure
To select the topics you would like to print, follow these steps:
1. Click the "Display printing dialog" button.
The table of contents opens in a separate window.
2. Select the check boxes for the folders and help topics to be printed in the "Print help topics"
dialog.
3. Click the "Print" button to print the selected information.
The "Print" dialog opens.
4. Select the printer on which you want print the help topics.
5. Click "Properties" if you want to make additional printer settings.
6. Confirm your entries with "OK".
The help topics are printed out on the selected printer.
Introduction to the TIA Portal
6.2 Help on the information system
STEP 7 Basic V12.0
System Manual, 01/2013, 211
6.2.7 Configuring the display of tooltips and tooltip cascades
Configuration options for tooltips and tooltip cascade
You can customize the display of tooltips and tooltip cascades to suit your needs. You can
make the following settings:
Display or hide truncated text
Sometimes texts may be too long for a text field. The texts are then fully displayed in a
tooltip when you hover your mouse over the text field. You can enable or disable this
function.
Enable or disable tooltips
Tooltips provide more detailed information about an element of the user interface. You can
also have tooltips displayed in a cascade. If you disable the tooltips, the cascade with
context-sensitive help is also no longer displayed. However, you have the option of
manually displaying the tooltip for the currently active interface element by pressing <F1>.
Enable or disable automatic opening of tooltip cascades
By keeping the mouse pointer over a tooltip for a brief time, any available cascades are
displayed automatically. You can enable or disable the automatic display of cascades.
When automatic display is disabled, you must open the cascade manually if necessary. To
do this, click on the arrow icon in the tooltip.
Procedure
To configure the display of tooltips and tooltip cascades, follow these steps:
1. Select the "Settings" command in the "Options" menu.
2. Select the "General" group in the area navigation.
3. Select or clear the individual check boxes in the "Tooltips" area to suit your needs. The
"Open cascade automatically in tooltips" check box is only available if you have enabled
the display of tooltips.
See also
General remarks on the information system (Page 206)
6.2.8 Safety Guidelines
Safety guidelines
This Help manual contains notices you have to observe in order to ensure your personal safety,
as well as to prevent damage to property. The notices referring to your personal safety are
highlighted in the manual by a safety alert symbol, notices referring only to property damage
Introduction to the TIA Portal
6.2 Help on the information system
STEP 7 Basic V12.0
212 System Manual, 01/2013,
have no safety alert symbol. These notices shown below are graded according to the degree
of danger.
DANGER
indicates that death or severe personal injury will result if proper precautions are not taken.
WARNING
indicates that death or severe personal injury may result if proper precautions are not taken.
CAUTION
with a safety alert symbol, indicates that minor personal injury can result if proper precautions
are not taken.
NOTICE
without a safety alert symbol, indicates that property damage can result if proper precautions
are not taken.
Note
indicates that an unintended result or situation can occur if the corresponding information is
not taken into account.
If more than one degree of danger is present, the warning notice representing the highest
degree of danger will be used. A notice warning of injury to persons with a safety alert symbol
may also include a warning relating to property damage.
Qualified Personnel
The device/system may only be set up and used in conjunction with this documentation.
Commissioning and operation of a device/system may only be performed by qualified
personnel. Within the context of the safety notes in this documentation qualified persons are
defined as persons who are authorized to commission, ground and label devices, systems and
circuits in accordance with established safety practices and standards.
Prescribed Usage
Note the following:
WARNING
This device 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. Correct, reliable operation of the
product requires proper transport, storage, positioning and assembly as well as careful
operation and maintenance.
Introduction to the TIA Portal
6.2 Help on the information system
STEP 7 Basic V12.0
System Manual, 01/2013, 213
Trademarks
All names identified by are registered trademarks of the Siemens AG. The remaining
trademarks in this publication may be trademarks whose use by third parties for their own
purposes could violate the rights of the owner.
Disclaimer of Liability
We have reviewed the contents of this publication to ensure consistency with the hardware
and software described. Since variance cannot be precluded entirely, we cannot guarantee
full consistency. However, the information in this publication is reviewed regularly and any
necessary corrections are included in subsequent editions.
6.2.9 Assembling customized documentation
Customized documentation
In the Service and Support section of the Siemens Website, you can assemble customized
documentation that is tailored to your needs. All configurable manuals and operating
instructions of the Service and Support section are available to you for this purpose. You can
select the parts that are of interest to you and combine them into in a library to form personal
documentation. You can organize the documentation using folders in the library. The folders
will later become the individual chapters of your custom documentation.
You can open your personal library here (https://www.automation.siemens.com/mdm/?
guiLanguage=en).
Requirement
The manuals or operating instructions used must be configurable. You can recognize
configurable manuals by the suffix "configurable" in their name.
In order to use all functions, you have to register in the Siemens Support Portal and log on.
Documentation in different languages
You can change the language of the assembled documentation to German, French, Spanish,
Italian and Chinese. This gives you the possibility, for example, to gather relevant information
for a specific project and make it available to colleagues who speak other languages.
Export function in the documentation
You can perform an export at any part of your library in various formats (PDF, XML, RTF).
Introduction to the TIA Portal
6.2 Help on the information system
STEP 7 Basic V12.0
214 System Manual, 01/2013,
Help on creating documentation
You can find more help on creating and using custom documentation on the Service and
Support Website (https://www.automation.siemens.com/mdm/_help/en/
mdm_reference_manual_de-DE.htm).
Introduction to the TIA Portal
6.2 Help on the information system
STEP 7 Basic V12.0
System Manual, 01/2013, 215
Editing projects
7
7.1 The basics of projects
Introduction
Projects are used to organize the storage of data and programs resulting from the creation of
an automation solution. The data that makes up a project includes the following:
Configuration data on the hardware structure and parameter assignment data for modules
Project engineering data for communication over networks
Project engineering data for the devices
Logs for important events in the life cycle of the project
Project hierarchy
Data is stored in a project in the form of objects. Within the project, the objects are arranged
in a tree structure (project hierarchy).
The project hierarchy is based on the devices and stations along with the configuration data
and programs belonging to them.
Common data of the project and online access, for example, are also displayed in the project
tree.
See also
Creating a new project (Page 219)
Opening projects (Page 219)
Saving projects (Page 222)
Deleting projects (Page 224)
Using logs (Page 218)
STEP 7 Basic V12.0
System Manual, 01/2013, 217
7.2 Using logs
For some operations within the TIA Portal, logs are created automatically in the background.
These logs document changes in the project. For example, logs are automatically created
during migration of projects and programs.
Logs are displayed in the "Common data" folder in the project tree. They are stored together
with the project in the project folder and can therefore be read independently of the
programming device/PC used as soon as you have opened the project.
In addition to displaying them in the TIA Portal, logs can also be printed.
Opening logs
To open a log, follow these steps:
1. Open the "Common data > Logs" folder in the project tree.
2. Double-click the desired log in the list.
The contents of the log are displayed in the work area.
Deleting logs
To delete a log, follow these steps:
1. Select the log in the project tree.
2. Press <Del>.
The selected log is deleted from the project directory and removed from the project tree.
Editing projects
7.2 Using logs
STEP 7 Basic V12.0
218 System Manual, 01/2013,
7.3 Creating and managing projects
7.3.1 Creating a new project
Procedure
To create a new project, follow these steps:
1. Select the "New" command in the "Project" menu.
The "Create a new project" dialog opens.
2. Enter your project name and path or accept the proposed settings.
3. Click the "Create" button.
Result
The new project is created and displayed in the project tree.
See also
The basics of projects (Page 217)
Opening projects (Page 219)
Saving projects (Page 222)
Deleting projects (Page 224)
7.3.2 Opening projects
Procedure
To open an existing project, follow these steps:
1. Select the "Open" command in the "Project" menu.
The "Open project" dialog opens and includes the list of most recently used projects.
2. Select a project from the list and click "Open".
3. If the project you require is not included in the list, click the "Browse" button. Navigate to
the desired project folder, and open the project file.
Projects in TIA Portal V12 have the extension ".ap12". Older projects of the TIA Portal have
the extension ".ap[version number]". For projects of the TIA Portal V11, for example, the
extension might be ".ap11".
Result
The project opens in the project view.
Editing projects
7.3 Creating and managing projects
STEP 7 Basic V12.0
System Manual, 01/2013, 219
See also
Notes on compatibility (Page 220)
The basics of projects (Page 217)
Creating a new project (Page 219)
Saving projects (Page 222)
Deleting projects (Page 224)
7.3.3 Notes on compatibility
With the TIA Portal V12, you can open projects that were not created with the same version
or that were created with another installation scope. In the following, you will learn what to
consider in this case.
Opening projects from older versions of the TIA Portal
You can open projects from previous versions of the TIA Portal. However, some peculiarities
in projects from earlier versions of the TIA Portal must be taken into consideration:
Projects from TIA Portal V10 and V10.5
Projects from versions V10.0 or V10.5 can be opened with the TIA Portal V12. They are
converted into a TIA Portal V12 project when you open them.
Projects from TIA Portal V11
Projects from version V11 are opened and remain unchanged. The range of functions is
limited to the capabilities of TIA Portal V11. Projects therefore remain backwards
compatible and can still be edited with the previous version of the TIA Portal. If you want
to continue working on a project that you saved in TIA Portal V12 in TIA Portal V11, the
most recent version of TIA Portal V11 must be installed. Service Pack 2 and all additional
updates must be installed for TIA Portal V11.
If you want to use all the functions of the current version in a project from TIA Portal V11,
you need to upgrade the project. When you upgrade, the project is converted in the format
of TIA Portal V12 and the full functionality of the TIA Portal V12 becomes available.
Opening projects from newer versions of TIA Portal
If you want to open a project from a newer version, this is possible if the following conditions
are met:
The project was created with a different version of TIA Portal V12, for example, a version
with an installed service pack.
The project does not contain any data that is incompatible with the current installation.
Editing projects
7.3 Creating and managing projects
STEP 7 Basic V12.0
220 System Manual, 01/2013,
Opening projects created with add-on products
If the project to be opened contains data that was created with optional software, but the
corresponding software product is not installed, the following cases can occur:
Software components are missing, but none of them are essential:
A dialog appears listing the missing software components. After the project is opened, its
properties are displayed. You now have the opportunity to install the missing products. All
the devices contained in the project are available even if you do not install the missing
products. However, you can only work with the devices that are supported by the currently
installed software.
If devices are not supported because software is missing, they are marked with the following
symbol in the project tree:
At least one software package is required in order to open the project:
A dialog appears listing the missing software components. The essential package(s) are
marked. The project can only be opened if you install the missing components.
See also
Opening projects (Page 219)
Upgrading projects (Page 221)
7.3.4 Upgrading projects
You can open and edit projects from TIA Portal V11 in the current version. The range of
functions remains limited to the capabilities of version V11, however. This ensures backward
compatibility of the project and allows the project continue to work with the previous version
of the TIA Portal.
If you want to use the full functionality of TIA Portal V12, you must upgrade the project.
If you want to continue using global libraries of TIA Portal V11, you have to upgrade these as
well. This does not take place automatically when you upgrade the project to prevent unwanted
changes to global libraries.
Procedure
To upgrade a project, follow these steps:
1. Open the project from an earlier version of the TIA Portal.
2. Select the "Upgrade" command in the "Project" menu.
A security prompt appears.
3. Click "Yes" to confirm.
Result
The original project is closed and will remain stored in its original state. A new version is created
from the original project. The new version of the project opens.
Editing projects
7.3 Creating and managing projects
STEP 7 Basic V12.0
System Manual, 01/2013, 221
See also
Notes on compatibility (Page 220)
Opening projects (Page 219)
Continue using libraries from TIA Portal V11 (Page 316)
7.3.5 Displaying properties of the project
You can display the properties of a project. Properties include the following:
Metadata for the project
This includes the following information: creation time, author, file path, project size,
copyright , project languages, etc. Many of the attributes can be changed.
Project history
The project history contains an overview with important events in the project life cycle. Here,
for example, you can see the version of the TIA Portal used to create a project and whether
it has been converted into another version in the meantime. If a project was created during
a migration, for example, this is also indicated in the project history table with the date and
time of the migration. If a log was created for an event, you can also call the log directly.
Support packages in the project
An overview of the add-on software needed to work with all devices in the project is
displayed. In addition, installed GSD files are listed (device description files for other devices
in the hardware catalog).
Software products in the project
You can display an overview of all installed software products needed for the project.
Procedure
To display the project properties, follow these steps:
1. Select the open project in the project tree.
2. Select "Properties" in the shortcut menu of the project.
The dialog with the properties of the project opens.
3. Select the project properties in the area navigation that you want to have displayed.
7.3.6 Saving projects
You can save the project at any time either under the same or a different name. You can even
save a project when it still contains elements with errors.
Editing projects
7.3 Creating and managing projects
STEP 7 Basic V12.0
222 System Manual, 01/2013,
Saving a project
To save a project, follow these steps:
1. Select the "Save" command in the "Project" menu.
All changes to the project are saved under the current project name. If you are editing a
project from an earlier version of the TIA Portal, the file extension of the project is also
retained and you can continue to edit the project in the earlier version of the TIA Portal.
Project Save as
To save a project under another name, follow these steps:
1. Select the "Save as" command in the "Project" menu.
The "Save current project as" dialog opens.
2. Select the project folder in the "Save in" box.
3. Enter the new project name in the "File name" box.
4. Confirm your entry with "Save".
The project is saved under the new name and opened.
See also
The basics of projects (Page 217)
Creating a new project (Page 219)
Opening projects (Page 219)
Deleting projects (Page 224)
Upgrading projects (Page 221)
Notes on compatibility (Page 220)
7.3.7 Closing projects
Procedure
To close a project, follow these steps:
1. Select the "Close" command in the "Project" menu.
If you have made changes to the project since the last time you saved it, a message is
displayed.
2. Decide whether or not you want to save the changes.
Editing projects
7.3 Creating and managing projects
STEP 7 Basic V12.0
System Manual, 01/2013, 223
7.3.8 Deleting projects
Note
When you delete a project, the entire project data is removed from the storage medium.
Requirement
The project you want to delete is not open.
Procedure
Follow the steps below to delete an existing project:
1. Select the "Delete project" command in the "Project" menu.
The "Delete project" dialog opens and includes the list of most recently used projects.
2. Select a project from the list.
If the project you require is not included in the list, click the "Browse" button. Navigate to
the desired project folder, and open the project file.
3. Click the "Delete" button.
4. Click "Yes" to confirm. This starts the deletion of the project.
Result
The entire project folder is deleted from the file system.
See also
The basics of projects (Page 217)
Creating a new project (Page 219)
Opening projects (Page 219)
Saving projects (Page 222)
7.3.9 Working with multi-language projects
7.3.9.1 Project text basics
Texts in different languages in the project
When you enter texts while working on a project, you would normally do this in your own
language. If you then pass on the project to someone else who does not know this language,
this person will require a translation of the relevant texts to a language they know. This is why
Editing projects
7.3 Creating and managing projects
STEP 7 Basic V12.0
224 System Manual, 01/2013,
all texts can be translated. In this way, you can ensure that anyone who is subsequently
confronted with the texts sees the texts in his/her language of choice.
Project language
Project languages are all languages in which a project will later be used. Based on the editing
language, all the texts can be translated to the various project languages. You specify the
languages that will be available in the project tree under "Languages & Resources > Project
languages".
Editing language
Every project has an editing language. When you enter texts, these are always created in the
editing language. You should therefore make sure that the editing language set is the language
in which you enter the texts. This avoids problems if you translate the texts later.
The editing language does not depend on the language of the user interface. You could, for
example, set English as the user interface language, but use Italian as the editing language.
If you enter texts, these will be created in this case in the project language "Italian", although
the user interface of the TIA Portal displays English.
You set the editing language in the project tree under "Languages & Resources > Project
languages > Editing language".
Reference language
The reference language is used as a template for translation. The text is displayed in the
reference language for each text box in the "Tasks > Languages and resources" task card.
You therefore know which text that belongs in a text box, even when no text is entered in the
currently selected editing language.
User texts and system texts
For clarification purposes, a distinction is made between user texts and system texts:
User texts are texts that the user created.
System texts are texts that are created automatically according to the configuration in the
project.
You manage the project texts in the project tree under "Languages & Resources > Project
texts".
Examples of multilingual project texts
You can, for example, manage the following project texts in more than one language:
Block titles and block comments
Network titles and network comments
Comments in tables
Alarm texts
Editing projects
7.3 Creating and managing projects
STEP 7 Basic V12.0
System Manual, 01/2013, 225
Operator-relevant texts
Text lists
Labels of buttons
Display names of recipes
Translating texts
There are three ways of translating texts.
Translate all texts used in the project in tabular form
You can enter the translations for the individual project languages directly in the "Project
texts" table. You will find this in the project tree under "Languages & Resources > Project
texts".
Specify text assigned to individual objects in the Inspector window
In the Inspector window, you can translate the texts that are assigned to the currently
selected objects. Columns are displayed in a table for all available project languages. You
can enter the translations for each text there.
Translating texts using reference texts
You can change the editing language for shorter texts. All the text cells are filled again with
the default values and can be filled in the current language. As orientation, you can display
what you last entered in the box in the reference language. To do this, select the "Tasks"
task card and open the "Languages & resources".
Exporting texts and translating them externally
With larger volumes of text, you can export the texts to an Office Open XML file and translate
them with a normal table calculation program. You then import the translated texts again
into the TIA Portal.
Note
Using Asian project languages
East Asian project languages are only displayed correctly in Windows XP, if the option "Install
files for East Asian languages" is selected on the Languages tab of Regional and Language
Options in the Control Panel of Windows XP Professional.
See also
Overview of the program settings (Page 159)
Changing the settings (Page 163)
Application examples for multilanguage projects (Page 231)
7.3.9.2 Select project languages
All the texts can be displayed within a project in the same language that you selected for your
software user interface. This means that all project texts must exist in the corresponding
language. You can select the available project languages yourself.
Editing projects
7.3 Creating and managing projects
STEP 7 Basic V12.0
226 System Manual, 01/2013,
Requirement
You are in the project view.
A project is open.
Procedure
To select the project languages, follow these steps:
1. Click on the arrow symbol to the left of "Languages & Resources" in the project tree.
The elements below this are displayed.
2. Double-click on "Project languages".
In the work area, you will see a list of languages that you can select.
3. Select the required languages.
Result
All texts can be displayed in the activated languages if there is already a translation for these
languages.
7.3.9.3 Setting the editing language
All the texts in the project are created in the editing language when they are entered. If you
change the editing language, all future text input will be stored in the new editing language.
Requirement
You are in the project view.
A project is open.
Procedure
To change the editing language, follow these steps:
1. Click on the arrow symbol to the left of "Languages & Resources" in the project tree.
The lower-level elements are displayed.
2. Double-click on "Project languages".
The possible settings for the project languages are displayed in the work area.
3. Select the editing language in "General > Editing language".
7.3.9.4 Translating all project texts in tabular form
You can display and edit all project text used in the currently open project in a list. User and
system texts are separated into two different lists for clarity. Both lists contain a separate
column for each project language in which you can enter the translations for text.
Editing projects
7.3 Creating and managing projects
STEP 7 Basic V12.0
System Manual, 01/2013, 227
Requirement
You are in the project view.
You have selected at least one further project language.
Procedure
To translate text in the project-wide list, follow these steps:
1. Click on the arrow symbol to the left of "Languages & Resources" in the project tree.
The elements below this are displayed.
2. Double-click "Project texts".
A list with the user texts in the project is displayed in the work area.
3. Click on "System texts" if you you want to edit the list of system texts rather than the user
texts.
4. You can improve the clarity of the lists if you have a lot of texts.
To group identical texts and to translate them all at once, click the "Switch on/off
grouping" button in the toolbar.
To hide texts that do not have a translation, click the "Filter for empty texts on/off" button
in the toolbar.
To further limit the displayed project texts to certain devices, select the devices for which
you want to display project texts in the drop-down list.
5. Enter the translation of the project texts in the relevant column.
7.3.9.5 Translating text associated with individual objects
If you want to edit the text of individual objects, it would be too difficult to locate the matching
text in the table with all project texts. For this reason, there is a table in the Inspector window
in which only the texts assigned to the currently selected objects are displayed. In the table,
you can add missing translations for individual project languages or change existing texts.
Requirement
Text must be entered in at least one project language for the texts to be translated.
Procedure
To edit the text of the currently selected object, follow these steps:
1. Select the object whose text you want to edit.
2. Open the "Properties" tab in the Inspector window.
3. Open the lower-level "Texts" tab in the inspector window.
A table with all the texts that belong to the selected objects is displayed. It contains one
column for the currently selected editing language and the reference language, as well as
additional columns for the other project languages.
4. Add or change the entries in the table for each project language.
Editing projects
7.3 Creating and managing projects
STEP 7 Basic V12.0
228 System Manual, 01/2013,
See also
Application examples for multilanguage projects (Page 231)
7.3.9.6 Translating texts using reference texts
Introduction
After changing the editing language, all texts are shown in input boxes in the new editing
language. If there is not yet a translation available for the newly set language, the input boxes
are empty or filled with default values.
If you enter text in an input box, this is saved in the current editing language. Following this,
the texts exist in two project languages for this input field, in the previous editing language and
in the current editing language. This makes it possible to create texts in several project
languages.
You can display existing translations for an input box in other project languages. These serve
as a comparison for text input in the current editing language and they are known as the
reference language.
Note
The display of reference texts depends on the installed products and is not supported by
every editor.
Requirement
There is at least one translation into a different project language for an input field.
Procedure
To display the translation of an input cell in a reference language, follow these steps:
1. In the "Tasks" task card, select the "Languages & Resources" pane.
2. Select a reference language from the "Reference language" drop-down list.
Result
The reference language is preset. If you click in a text box, translations that already exist in
other project languages are shown in the "Tasks > Languages & Resources" task card.
7.3.9.7 Exporting and importing project texts
You can export project texts for translation and then reimport them. The texts are exported to
an Office Open XML file with the extension ".xlsx". This can be edited in Microsoft Excel or a
number of other spreadsheet programs.
The following export options are available:
Editing projects
7.3 Creating and managing projects
STEP 7 Basic V12.0
System Manual, 01/2013, 229
Exporting individual project texts
Exporting all user texts or system texts at once
In this case, the export can be additionally limited by categories.
Note
Row limit in Microsoft Excel
Note that spreadsheet programs may be able to process only a certain number of rows.
Microsoft Excel 2003 supports a maximum of 65536 rows, for example. Later versions of
Microsoft Excel support significantly more rows.
Exporting individual project texts
To export individual project texts, follow these steps:
1. Open the "Languages & Resources" folder in the project tree.
The lower-level elements are displayed.
2. Double-click "Project texts".
The project texts editor opens.
3. Choose the "User texts" or "System texts" tab in the editor, depending on which texts you
want to export.
4. Select the project texts you want to export.
5. Click the "Export project texts" icon in the toolbar of the editor.
The "Export" dialog box opens.
6. Choose the language you want to translate from in the "Source language" drop-down list.
7. Choose the language you want to translate to in the "Target language" drop-down list. The
drop-down list contains the project languages you specified previously. If the required
language is missing, you must first specify it in the project languages editor.
8. Specify a file path and a file name for the export file in the "Select file for export" input box.
9. Click "Export".
Exporting all system or user texts
To export all project texts, follow these steps:
1. Select the "Export project texts" command in the "Tools" menu.
The "Export" dialog box opens.
2. Choose the language you want to translate from in the "Source language" drop-down list.
3. Choose the language you want to translate to in the "Target language" drop-down list. The
drop-down list contains the project languages you specified previously. If the required
language is missing, you must first specify it in the project languages editor.
4. In "Select content", select the check box "User texts" to export user texts. To export system
texts, select "System texts". To export both user texts and system texts, select both check
boxes.
Editing projects
7.3 Creating and managing projects
STEP 7 Basic V12.0
230 System Manual, 01/2013,
5. In "Select content", select the required text categories for the user texts or the system texts.
6. In the "Export file" input field, specify a file name for the export file.
7. In the "Path" input field, select a path in the data system to which the export file is to be
saved.
8. Click "Export".
Importing project texts
To import a file containing project texts, follow these steps:
1. Select the "Import project texts" command in the "Tools" menu.
The "Import" dialog box opens.
2. Select the path and the file name of the import file from the "Select file for import" field.
3. Select the "Import base language" check box if you have made changes to the base
language in the export file and you want to overwrite the entries in the project with the
changes.
4. Click "Import".
See also
Application examples for multilanguage projects (Page 231)
7.3.9.8 Application examples for multilanguage projects
Introduction
Let us assume you are working in a team with colleagues some of whom speak English, some
French and some German. You have created a project with the TIA Portal and have already
created a functioning configuration.
To allow your other colleagues to be able to keep track of the project, you would like all devices
being used to have comments in English and German. First, you would like to enter the
comments in German. Following this, to save time and costs, you want to have the texts
translated into English in a spreadsheet program by an external translation office.
In addition to this, you also want a single comment for a particular device in French so that
your French-speaking colleague can continue working on this device.
The section below describes an example of how you can achieve this with the tools of the TIA
Portal.
Editing projects
7.3 Creating and managing projects
STEP 7 Basic V12.0
System Manual, 01/2013, 231
Translating the project into English
To enter the comments in German and to have them translated into English later, follow these
steps:
1. Set the editing language to "German" and fill all the comment boxes with the relevant texts
in German.
On the device selected from the French-speaking colleague, enter, for example "Unser
neues Gert" in German first.
All the comments are now stored in German.
2. Export all user texts to an Office Open XML file with the extension ".xlsx".
3. Have the user texts contained in the file translated into English in a spreadsheet program
such as Microsoft Excel.
4. Import the file into the TIA Portal after it has been translated.
All texts are now available in German and English.
Translating a single comment field to French
To translate an individual comment field to French, follow these steps:
1. Open the comment box for the device on which the French-speaking colleague will be
working.
2. Open the "Languages & Resources" pane in the "Tasks" task card.
3. Set "French" as the editing language in the "Languages & Resources" pane. As the
reference language, set, for example, "English".
Since no translation has yet been installed in French, the comment box is empty. In the
"Languages & Resources" pane, the English translation "Our new device" is displayed as
a reference.
4. Orientating yourself on the English reference text enter "Notre nouvel appareil" in the
comment box.
The comment for this device is now available in the languages German, English and French.
See also
Project text basics (Page 224)
Exporting and importing project texts (Page 229)
Translating text associated with individual objects (Page 228)
Editing projects
7.3 Creating and managing projects
STEP 7 Basic V12.0
232 System Manual, 01/2013,
7.3.10 Archiving and retrieving projects
7.3.10.1 Working with project archives
Archiving and transferring projects
If you work for a long time with a project, large files may result, especially with extensive
hardware configurations. Therefore, you may want to reduce the size of the project, for
example, when you archive it to an external hard drive, or when you send it via e-mail and
require a smaller file size.
Options for reducing the size of the project
There are two ways to reduce the size of the project:
TIA Portal project archives
TIA Portal project archives are compressed files, each containing an entire project,
including the entire folder structure of the project. Before the project directory is compressed
into the archive file, all files are reduced to their essential components to further decrease
the size of the project. Project archives are therefore well suited for sending via e-mail.
Project archives of a project that was created with TIA Portal V11 have the file extension
". zap11". Projects created with TIA Portal V12 have the file extension ". zap12".
To open a project archive, you need to retrieve the project. Here, the archive file is extracted
into the original project directory structure with the included project files to a location you
have selected.
Minimized TIA Portal project
You can leave out the additional compression in an archiving file, and instead create a copy
of the project directory. The included files can be reduced to the essential elements of the
project. This minimizes the required storage space. The full functionality of the project is
maintained and you can open the project as usual.
A minimized TIA Portal project is especially well suited for archiving, for example, on an
external medium.
See also
Retrieving projects (Page 235)
Archiving projects (Page 234)
Editing projects
7.3 Creating and managing projects
STEP 7 Basic V12.0
System Manual, 01/2013, 233
7.3.10.2 Archiving projects
You can reduce the storage space required for the currently open project by compressing the
project into a file, or by reducing the project files to their essential components. You can do
both of these with the archiving function of the TIA Portal.
Note
The most recent saved state of the project is used for archiving. Therefore, save the project
before using the archiving function. This will ensure that your most recent changes are
included in the archived project.
Procedure
To archive a project, follow these steps:
1. Select the "Archive" command in the "Project" menu.
The "Archive current project as..." dialog opens.
2. Select the directory where you want to save the archive file or the new project directory.
3. Select the file type from the "File type" drop-down list:
TIA Portal project archive, if you want to create a compressed file of the project.
Minimized TIA Portal project, if you only want to create a copy of the project directory
with minimal storage space.
4. Enter a file name in the "File name" field if you are creating an archive file. If you are creating
a minimized project directory instead, enter the name of the new project directory to be
created in the "File name" box.
5. Click "Save".
Result
When you have created a project archive, a compressed file is generated with the extension
".zap11" (for projects created with version V11 of the TIA Portal) or ".zap12" (for projects
created with version V12 of the TIA Portal). The file contains the complete project directory.
The individual files of the project are also reduced to the essential components in order to save
space.
If you have created a minimized TIA Portal project, only a copy of the original project directory
is created at the desired location. The files contained within it are reduced to their essential
components in order to save space.
See also
Working with project archives (Page 233)
Retrieving projects (Page 235)
Editing projects
7.3 Creating and managing projects
STEP 7 Basic V12.0
234 System Manual, 01/2013,
7.3.10.3 Retrieving projects
You can unpack projects that have been compressed with the archiving function of the TIA
Portal. This restores the project directory structure including all project files.
Requirement
No project should be open.
Procedure
To unpack a project archive, follow these steps:
1. Select the "Restore from archive" command in the "Project" menu.
The "Retrieve archived project" dialog opens.
2. Select the project archive.
3. Click "Open".
4. The "Find folder" dialog opens.
5. Select the target directory to which the archived project should be extracted.
6. Click "OK".
Result
The project is extracted to the selected directory and opened immediately.
See also
Working with project archives (Page 233)
Editing projects
7.3 Creating and managing projects
STEP 7 Basic V12.0
System Manual, 01/2013, 235
7.4 Using reference projects
7.4.1 Basics of reference projects
Introduction
You can open other projects as a reference in addition to the current project. You can use
these reference projects as follows:
You can drag individual objects from a reference project into the current project and then
edit them.
You can open specific objects, for example, code blocks from a reference project as read-
only. But this is not possible for all elements.
You can use an offline/offline comparison to compare devices of the reference project to
devices from the current project.
Note that reference projects are read-only. You cannot change the objects of a reference
project.
See also
Comparing reference projects (Page 237)
Opening and closing a reference project (Page 236)
Reference projects (Page 183)
7.4.2 Opening and closing a reference project
Opening a reference project
To open a reference project, follow these steps:
1. In the "Reference projects" palette of the project tree, click on "Open reference project" in
the toolbar.
The "Open reference project" dialog box opens.
2. Navigate to the desired project folder, and open the project file. TIA Portal V12 projects
have the extension ".ap12". Older projects of the TIA Portal have the extension ".ap[version
number]".
3. Click "Open".
The selected project is opened as a read-only reference project.
Editing projects
7.4 Using reference projects
STEP 7 Basic V12.0
236 System Manual, 01/2013,
Closing a reference project
To close a reference project, follow these steps:
1. In the "Reference projects" palette of the project tree, select the reference project you want
to close.
2. Click on "Close reference project" in the toolbar.
The selected reference project is closed.
See also
Basics of reference projects (Page 236)
Comparing reference projects (Page 237)
Reference projects (Page 183)
7.4.3 Comparing reference projects
Introduction
You can compare devices from reference projects with devices from both the current project
as well as from the same or another reference project or from a library.
Note
Please note the following:
You cannot specify actions for the comparison objects, since the reference projects are
write-protected.
You can perform a detailed comparison for the comparison objects, if the type of
comparison object generally allows a detailed comparison.
When comparing reference projects, you can always switch between automatic and
manual comparison.
Procedure
To compare the objects of a reference project to the device data of the current project, follow
these steps:
1. In the project tree, select the device whose data you want to compare to the data of a
reference project and which allows offline/offline comparison.
2. Select "Compare > Offline/Offline" from the shortcut menu.
The compare editor opens with the selected device displayed in the left area.
3. Open the "Reference projects" palette in the project tree.
Editing projects
7.4 Using reference projects
STEP 7 Basic V12.0
System Manual, 01/2013, 237
4. Select the device of a reference project that you want to compare to the device data from
the current project.
5. Drag the device from the reference project into the right drop area of the compare editor.
You can identify the status of the objects based on the symbols in the status and action
area. When you select an object, the object's properties and the corresponding object of
the associated device is clearly shown in the properties comparison.
You can drag a library or other devices from a reference project from the current project
into drop areas at any time and thus start a new comparison. It does not matter which device
you drag into the drop area.
See also
Basics of reference projects (Page 236)
Reference projects (Page 183)
Opening and closing a reference project (Page 236)
Carrying out offline/offline comparisons (Page 246)
Using the comparison editor (Page 247)
Editing projects
7.4 Using reference projects
STEP 7 Basic V12.0
238 System Manual, 01/2013,
7.5 Editing project data
7.5.1 Compiling and loading project data
7.5.1.1 Compiling project data
General information on compiling project data
Compiling project data
During compilation, project data is converted so that it can be read by the device. Hardware
configuration data and program data can be compiled separately or together. You can compile
the project data for one or more target systems at the same time.
The following project data must be compiled prior to loading:
Hardware project data, for example, configuration data of the devices or networks and
connections
Software project data, for example, program blocks or process screens
Note
While a device is being compiled, no additional compiling process can be started. Note in
this regard that you can not only perform a compiling process manually, but you can also
trigger it automatically for HMI devices.
Scope of the compilation
When you compile project data, you have the following options depending on the device
involved:
Hardware and software (only changes)
Hardware (only changes)
Software (only changes)
Software (rebuild all blocks)
Software (reset memory reserve)
See also
Compiling project data (Page 240)
Editing projects
7.5 Editing project data
STEP 7 Basic V12.0
System Manual, 01/2013, 239
Compiling project data
The following section describes the general procedure for compiling project data in the project
tree. You will find details of how certain objects are compiled and any special points to note in
the online help of the product.
Procedure
To compile project data, follow these steps:
1. In the project tree, select the devices whose project data you want to compile.
2. Select the option you require in "Compile" submenu of the shortcut menu.
Note
Note that the options available to you depend on the selected device.
The project data is compiled. You can check whether or not the compilation was successful
in the Inspector window with "Info > Compile".
See also
General information on compiling project data (Page 239)
7.5.1.2 Downloading project data
General information on loading
Introduction
In order to set up your automation system, you must download the project data you generated
offline to the connected devices. This project data is generated, for example when configuring
hardware, networks, and connections or when programming the user program or when
creating recipes. The first time you download, the entire project data is downloaded. During
later loading operations, only changes are downloaded. You can download the project data to
devices and memory cards.
Note
While a device is being compiled, no additional download process can be started. Note in
this regard that you can not only perform a compiling process manually, but you can also
trigger it automatically for HMI devices.
Depending on the object you want to download, you have the following options:
Editing projects
7.5 Editing project data
STEP 7 Basic V12.0
240 System Manual, 01/2013,
Hardware and software
Both hardware configuration as well as software are downloaded to the destination.
Hardware configuration
Only the hardware configuration is downloaded to the destination.
Software (only changes)
Only the objects that differ online and offline are downloaded to the destination.
Load PLC program to device and reset
All the blocks are loaded to the destination and all values are reset to their initial state. Be
aware that this also applies to retentive values.
You can also upload project data already contained in a device back to your project. You have
the following options:
Uploading a complete device
All relevant data of the device is uploaded to the project.
Uploading blocks and parameters
Only the blocks and parameters from the device are uploaded to the project.
See also
Creating a backup of a device (Page 3754)
Downloading project data to a device (Page 241)
Downloading project data to a memory card (Page 242)
Uploading project data from a device (Page 243)
Downloading project data to a device
The following section describes the general procedure for downloading project data to a device.
You will find details of how certain objects are downloaded and any special points to note in
the online help of the product.
Requirement
The project data is consistent.
Each device to which you want to download is accessible via an online access.
Procedure
To download the project data to the selected devices, follow these steps:
1. Select one or more devices systems in the project tree.
2. Right-click on a selected element.
The shortcut menu opens.
Editing projects
7.5 Editing project data
STEP 7 Basic V12.0
System Manual, 01/2013, 241
3. Select the option you require in the shortcut menu of the "Download to device" submenu.
Note
Note that the options available to you depend on the selected device.
When necessary, the project data is compiled.
If you had previously established an online connection, the "Load preview" dialog opens.
This dialog displays messages and proposes actions necessary for downloading.
If you had not previously established an online connection, the "Extended download to
device" dialog opens, and you must first select the interfaces via which you want to
establish the online connection to the device.
See also: Establishing and canceling an online connection (Page 3750)
4. Check the messages in the "Load preview" dialog, and select the actions in the "Action"
column, if necessary.
Note
Performing the proposed actions while the plant is in operation can cause serious bodily
injury and property damage in the event of malfunctions or program errors.
Make sure that no dangerous situations can arise before you start the actions!
As soon as loading becomes possible, the "Load" button is enabled.
5. Click the "Load" button.
The loading operation is performed. The "Load results" dialog then opens. In this dialog,
you can check whether or not the loading operation was successful and take any further
action that may be necessary.
6. Click the "Finish" button.
Result
The selected project data was downloaded to the devices.
See also
General information on loading (Page 240)
Downloading project data to a memory card (Page 242)
Uploading project data from a device (Page 243)
Downloading project data to a memory card
Requirement
The memory card is displayed.
See also: Accessing memory cards (Page 295)
Editing projects
7.5 Editing project data
STEP 7 Basic V12.0
242 System Manual, 01/2013,
Procedure
To download project data to a memory card, follow these steps:
1. Use a drag-and-drop operation in the project tree to take the project data you want to
download and move it to the memory card.
The "Load preview" dialog opens. This dialog displays messages and proposes actions
necessary for downloading.
2. Check the messages, and select the actions in the "Action" column, if necessary.
As soon as loading becomes possible, the "Load" button is enabled.
3. Click the "Load" button.
The loading operation is performed. The "Load results" dialog then opens. In this dialog,
you can check whether or not the loading operation was successful and take any further
action that may be necessary.
4. Click the "Finish" button.
See also
General information on loading (Page 240)
Downloading project data to a device (Page 241)
Uploading project data from a device (Page 243)
Uploading project data from a device
The following section describes the general procedure for uploading project data from a device.
Which project data you can upload from a device depends on the products installed.
You have the following basic options for uploading project data from a device to your project:
Uploading a device to a programming device or PC
You can use this option to start with an empty project and upload existing project data
directly from a device.
Uploading from device
Only certain project data are uploaded from the device to the project. You will find the project
data that can be downloaded in the online help of the product.
Requirement
A project is open.
The hardware configuration and software to be downloaded have to be compatible with the
TIA Portal. If the data on the device was created with a previous program version or with
a different configuration software, please make sure they are compatible.
Editing projects
7.5 Editing project data
STEP 7 Basic V12.0
System Manual, 01/2013, 243
Uploading a device to a programming device or PC
To upload the complete device to your project, follow these steps:
1. Select the project name in the project tree.
The "Upload device to PG/PC" command in the "Online" menu is then enabled.
2. In the "Online" menu, select the "Upload device to PG/PC" command.
The "Upload device to PG/PC" dialog opens.
3. Select the type of interface you want to use for the load operation in the "Type of the PG/
PC interface" drop-down list.
4. Select the interface to be used from the "PG/PC interface" drop-down list.
5. Click the "Configure interface" button to the right of the "PG/PC interface" drop-down list to
adapt the settings for the selected interface.
See also: Establishing and canceling an online connection (Page 3750)
6. In the accessible devices table, select the device from which you want to upload project
data.
7. Click on "Load".
Depending on the selected device, a dialog appears in which you have to enter additional
information, such as the position of the module rack.
The project data of the device is uploaded to the project. You can edit it offline and then
download it to the device again.
Uploading from device
To upload only certain project data from a device to your project, follow these steps:
1. Establish an online connection to the device from which you want to download the project
data.
See also: Establishing and canceling an online connection (Page 3750)
2. Select an element in the project tree that allows uploading of project data.
As a result, the "Upload from device" command in the "Online" menu becomes enabled.
3. Select the "Upload from device" command in the "Online" menu.
The "Upload preview" dialog box opens.
4. Check the messages in the "Upload preview" dialog, and select the necessary actions in
the "Action" column.
As soon as uploading becomes possible, the "Upload from device" button is enabled.
5. Click the "Upload from device" button.
The loading operation is performed.
See also
Displaying accessible devices (Page 3745)
General information on loading (Page 240)
Downloading project data to a device (Page 241)
Downloading project data to a memory card (Page 242)
Editing projects
7.5 Editing project data
STEP 7 Basic V12.0
244 System Manual, 01/2013,
7.5.2 Comparing project data
7.5.2.1 Basics of project data comparison
Function
You can compare project data of the same type in order to determine possible differences. In
principle, the following comparison methods are available:
Online/offline comparison
With this type of comparison, the objects of a device are compared to the objects of a
project. This is only possible when you establish an online connection to the device.
Offline/offline comparison
With this type of comparison you can compare objects from projects or libraries. You can
decide whether the comparison should be performed automatically for all objects or whether
you want to compare individual objects manually.
Detailed comparison
For some objects, for example, blocks, you can also perform a detailed comparison in
addition to the online/offline and offline/offline comparison. This involves opening the blocks
to be compared beside each other and highlighting the differences.
A simple online/offline comparison is performed as soon as you establish an online connection.
During this process, comparable objects in the project tree are marked with icons that represent
the result of the comparison.
The normal online/offline and offline/offline comparison is performed in the compare editor.
You can also select actions for non-identical objects in the comparison editor.
Note
Not all objects allow all types of comparison. Which comparison method you can use for
which project data depends on the products installed.
See also
Carrying out an online/offline comparison (Page 245)
Carrying out offline/offline comparisons (Page 246)
Using the comparison editor (Page 247)
Running a detailed comparison (Page 252)
7.5.2.2 Carrying out an online/offline comparison
Requirement
The project tree is open.
Editing projects
7.5 Editing project data
STEP 7 Basic V12.0
System Manual, 01/2013, 245
Procedure
To perform an online/offline comparison, follow these steps:
1. Select a device in the project tree that allows online/offline comparison.
2. Select the "Compare > Offline/online" command in the shortcut menu.
3. If you have not already established an online connection to this device, the "Go online"
dialog opens. In this case, set all the necessary parameters for the connection and click
"Connect".
The online connection is established and compare editor opens.
Result
All objects that exist online and offline are displayed. The symbols in the comparison editor
and in the project tree show you the status of the objects. In the compare editor, you can now
define certain actions for the objects, depending on their status.
See also
Basics of project data comparison (Page 245)
Carrying out offline/offline comparisons (Page 246)
Using the comparison editor (Page 247)
Running a detailed comparison (Page 252)
Establishing and canceling an online connection (Page 3750)
7.5.2.3 Carrying out offline/offline comparisons
With an offline/offline comparison, you can compare project data of two devices within one
project or from different projects or from the library. You can decide whether the comparison
should be performed automatically for all objects or whether you want to compare individual
objects manually.
You can drag any other device to the drop area at any time to perform further comparisons.
Requirement
The project tree is open.
Editing projects
7.5 Editing project data
STEP 7 Basic V12.0
246 System Manual, 01/2013,
Performing automatic offline/offline comparisons
To perform an automatic offline/offline comparison, follow these steps:
1. Select a device in the project tree that allows offline/offline comparison.
2. Select the "Compare > Offline/offline" command in the shortcut menu.
The compare editor opens and the selected device is displayed in the left area.
3. Drag-and-drop an additional device to the drop area of the right pane. The device to be
compared can originate from the same project, a reference project or the library.
All existing objects of the selected devices are displayed depending on the settings of the
compare editor. You can identify the status of the objects based on the symbols in the
compare editor. You can define certain actions depending on the status of the objects.
Performing manual offline/offline comparisons
To perform a manual offline/offline comparison, follow these steps:
1. Select a device in the project tree that allows offline/offline comparison.
2. Select the "Compare > Offline/offline" command in the shortcut menu.
The compare editor opens and the selected device is displayed in the left area.
3. Drag-and-drop an additional device to the drop area of the right pane. The device to be
compared can originate from the same project, a reference project or the library.
4. In the status and action area, click on the button for switching between automatic and
manual comparison.
5. Select the objects that you want to compare.
The properties comparison is displayed. You can identify the status of the objects based
on the symbols. You can define certain actions depending on the status of the objects.
See also
Basics of project data comparison (Page 245)
Carrying out an online/offline comparison (Page 245)
Using the comparison editor (Page 247)
Running a detailed comparison (Page 252)
7.5.2.4 Using the comparison editor
Overview of the comparison editor
Function
The comparison editor gives an overview of the results of online/offline and offline/offline
comparisons in a table. You can also define which actions are to be carried out for non-identical
objects compared.
Editing projects
7.5 Editing project data
STEP 7 Basic V12.0
System Manual, 01/2013, 247
Components of the comparison editor
The following figure shows the components of the compare editor using a manual offline/offline
comparison as an example:
Editing projects
7.5 Editing project data
STEP 7 Basic V12.0
268 System Manual, 01/2013,
Toolbar
The toolbar provides the following tools (from left to right):
Arrow tool
Enables object selection.
Navigation tool
Allows shifting of the partial page.
Zoom-in button
Magnifies the page display incrementally.
Zoom-out button
Reduces the page display incrementally.
Selecting a zoom factor
Adapts the page size to the area selected with the lasso zoom tool.
Dynamic zoom
Adapts the page width to the work area.
Work area
You can design the cover page or frame in the work area.
"Toolbox" task card
The "Toolbox" task card contains various types of placeholders that you can use on
the cover sheet or frame. The placeholders can be placed in the work place using
a drag-and-drop operation.
Properties in the Inspector window
You can display and modify the properties of the currently selected object in the
"Properties" tab of the Inspector window. For example, you can modify the properties
of the page, format text, specify the position of objects on the page, etc.
Editing projects
7.5 Editing project data
STEP 7 Basic V12.0
System Manual, 01/2013, 269
Operation in the documentation editor
The following basic functions are available in the documentation editor:
Drag-and-drop functionality
The documentation editor is a graphic editor, which means you can place objects anywhere
with the mouse. An image of the page is displayed in the work area. This image corresponds
to the ultimate print layout.
If you want to select objects on the page in order to move them or modify their properties,
the arrow tool must be activated in the toolbar.
Zoom function
You can use the zoom function to change the size of the page display. You have two options
for changing the page size:
Via the buttons in the toolbar
Select the "Zoom in" or "Zoom out" magnifying glass button in the toolbar of the
documentation editor. Then click on the page in order to magnify (zoom in) or reduce
(zoom out) the page incrementally.
To zoom in on a particular area, select the "Select zoom factor" tool and use the mouse
to drag an outline around the area you want to focus on.
To continuously zoom in or zoom out of the work area, use the "Dynamic zoom" tool.
To magnify the page display, click anywhere on the work area, and then hold down the
mouse button while dragging the mouse toward the top of the page. To reduce the page
display, drag the mouse toward the bottom of the page.
Via the zoom bar
You can also use the zoom bar (located in the bottom right corner of the work area) to
change the display size. Choose a percentage value from the drop-down list or enter a
percentage value. Alternatively, you control the display size using the slider.
Navigation over the page
In addition to scrolling, you the option of changing the partial page with the navigation tool.
To change the partial page with the navigation tool, select the Hand button in the toolbar.
Then, click anywhere on the page and hold the mouse button down while moving the page
to the desired position.
Using and adapting the positioning aids
You have various aids at your disposal to help you position elements on the page:
Rulers
Rulers are affixed to the page margins in the work area.
Page grid
A grid is placed underneath the page in the work area.
You can display, hide or adapt the positioning aids in the Inspector window under "Properties
> Rulers and grid". You can make the following settings:
Units:
Specify the unit of measurement for the grid and the rulers.
Grid steps:
Specify the width of the grid.
Show grid:
Specify whether the grid is to be displayed or hidden.
Editing projects
7.5 Editing project data
STEP 7 Basic V12.0
270 System Manual, 01/2013,
Snap to grid:
Specify whether objects are to be aligned automatically to the grid. If the option is selected,
the grid lines function like a "magnet".
Show rulers:
Specify whether the rulers are to be displayed.
See also
Editing cover pages and frames (Page 267)
Specifying the print area (Page 271)
Inserting placeholders for metadata (Page 271)
Specifying the print area
An area within the frame is provided for the actual printed contents. The project data is then
always inserted inside this defined and uniformly consistent area within the frame. You can
adjust the size of the print area.
Requirement
A frame is open in the documentation editor.
Procedure
To define an area for the printed contents, follow these steps:
1. Click on the slightly darker area within the page display in the documentation editor to select
the area for the print content.
This opens the properties of the area to be printed in the Inspector window.
2. Enter the position of the print area on the X and Y axes in the Inspector window.
3. Specify the width and height of the print area in cm in the Inspector window.
Alternatively, you can change the width and position of the print area in the graphic display of
the page. To do so, use the mouse to drag the margins of the print area until the desired size
and position are achieved.
See also
Creating frames (Page 265)
General operation of the documentation editor (Page 268)
Inserting placeholders for metadata
You can provide placeholders on the cover page and in a frame. The placeholders are
automatically filled with metadata from documentation information during printing, if they are
placeholders for text. Alternatively, you can add non-modifiable data, such as free text or an
image.
Editing projects
7.5 Editing project data
STEP 7 Basic V12.0
System Manual, 01/2013, 271
All elements are arranged in numbered Z-Orders. If objects overlap, you can determine in
which sequence these are to be arranged.
Types of placeholders
The following types of placeholders are available to you:
Text field
The text field stands as a placeholder for a text element from a document information. In
the properties of the text field, you set which text from a document information should be
automatically inserted during printing.
Field for date and time
A date and time is inserted instead of the placeholder when printing. This can be the date
of creation or the point in time when the last change was made to the project. In the
properties of the Inspector window, you specify which date or time is printed.
Page number
The correct page number is automatically applied when printing.
Free text
You can enter freely selectable text in the properties of the text field. The text is static and
is not influenced by the document information selected at the time of printing.
Image
Select the image file in the properties of the placeholder in the Inspector window. Images
in the formats BMP, JPEG, PNG, EMF or GIF are possible.
Requirement
An cover page or frame is open in the documentation editor.
Procedure
To insert placeholders for metadata on the cover sheet or in a frame, follow these steps:
1. Drag a field from the "Toolbox > Elements" task card to the work area of the documentation
editor.
The placeholder is inserted. The placeholder properties are shown in the Inspector window
and can be edited there.
2. Select the metadata to be inserted during printing from the "Text" drop-down list in the
Inspector window under "Properties > General > Text box". Alternatively, you have the
option of entering free text or selecting an image depending on the type of placeholder.
3. In the Inspector window under "Properties > General > Position and size", specify the
position of the placeholder on the X and Y axis and enter the width and height of the text
box in cm. You specify the sequence of the objects in the "Z-Order" field, if these overlap.
The smaller the value, the further down an object is located.
4. In the Inspector window, go to "Properties > View" and select the font formatting and the
orientation of the text as well as the alignment of the text. You cannot make this setting for
images.
Editing projects
7.5 Editing project data
STEP 7 Basic V12.0
272 System Manual, 01/2013,
See also
General operation of the documentation editor (Page 268)
Displaying print preview
Creating a print preview
Creating a print preview
You can create a preview of the printout. Document information can be chosen for this, in the
same way as as for the actual printout. In this way, you preview the selected frame and, if
applicable, the cover sheet. The settings are retained for later printing.
Procedure
To create a print preview and to set the scope of the later printout, follow these steps:
1. Select the "Print preview" command in the "Project" menu.
The "Print preview" dialog opens.
2. Select the frame layout you want to use for the printout.
In the "Document information" drop-down list, select the documentation information you
want to use later for the printout.
Select the "Print cover page" check box to print the cover page, which is specified in the
selected document information.
Select the "Print table of contents" check box to add a table of contents to the printout.
The check boxes for printing the cover page and the table of contents can only be selected
if you have started the printout in the project tree.
3. Under "Print objects/area", select what is to be printed. The selection is only possible if you
have started the printout from an editor that supports this function.
Choose "All" to print out the entire content of the editor.
Choose "Selection" to print only the objects currently selected in the editor.
Editing projects
7.5 Editing project data
STEP 7 Basic V12.0
System Manual, 01/2013, 273
4. Select the print scope under "Properties".
Choose "All" to print all configuration data of the selected objects.
Choose "Visible" to print the information of an editor that is currently visible on the
screen. This option can only be chosen if you have started the printout from an editor
that supports this function.
Choose "Compact" to print out an abbreviated version of the project data.
5. Click "Preview" to generate the preview.
A print preview is created in the work area.
Note
Wait time for extensive documents
It can take several minutes to generate the print preview in the case of very extensive
projects. You can continue working normally in the meantime on systems with adequate
resources. The progress of the print preview is shown in the status bar.
See also
Operation within the print preview (Page 275)
Editing projects
7.5 Editing project data
STEP 7 Basic V12.0
274 System Manual, 01/2013,
Operation within the print preview
Functions within the print preview
The print preview shows an exact image of the subsequent printout. You can use the buttons
in the toolbar to modify the print preview display. The following functions are available (from
left to right):
Navigation mode
Allows shifting of the partial page.
To change the partial page with the navigation tool, select the arrow button in the toolbar.
Then, click anywhere on the page and hold the mouse button down while moving the page
to the desired position.
Zoom function
"Zoom in" and "Zoom out"
Magnifies or reduces the page display.
To zoom in or zoom out the display incrementally, select the corresponding button. Then
click on the page in order to magnify (zoom in) or reduce (zoom out) the page
incrementally.
To zoom in on a particular area, select the "Lasso zoom" button and use the mouse to
drag an outline around the area you want to focus on.
To select an area to focus on, select the button "Zoom in / zoom out with rectangle".
With the mouse, drag a border around the area to focus on it.
To zoom dynamically through the page, select the button "Zoom in / zoom out
dynamically". With pressed mouse button, scroll down over the page to zoom in. Scroll
up to zoom out.
Percentage value in the drop-down list
Specifies the display size of the page in percent.
Enter a percentage value or select a percentage value from the drop-down list.
Alternatively, choose the the "Fit to page" option from the drop-down list to adapt the
page size to the work area. Or, choose "Fit to width" to adapt the page width to the work
area.
Editing projects
7.5 Editing project data
STEP 7 Basic V12.0
System Manual, 01/2013, 275
"Forward" and "Backward":
Each change in the partial page, the page count, or the display size is saved in a history in
the background. You can use the "Forward" or "Backward" button to return to the previous
view or the next view.
Page navigation
"First page"
Jumps back to the first page.
"Previous page"
Goes one page back.
"Page number" input field
Shows the current page. To jump directly to a page, enter the page number of the page
you want to view.
"Next page"
Goes to the next page.
"Last page"
Jumps to the last page.
See also
Creating a print preview (Page 273)
Printing project data
You have two options for printing out project data:
Print immediately using default settings by means of the "Print" button in the toolbar.
The button is only active if a printable object is selected.
Printout with additional setting options with the "Project > Print" menu command.
For example, you can choose a different printer or specific documentation information or
you can specify whether a cover page and table of contents are to be printed. In addition,
you can specify the print scope or display a print preview prior to printing.
Requirement
At least one printer is configured.
The objects to be printed are not protected.
The print scope for protected objects is limited. Disable the know-how protection to print
the objects in full.
Editing projects
7.5 Editing project data
STEP 7 Basic V12.0
276 System Manual, 01/2013,
Printing project data
To print out data from the current project or the entire project with additional setting options,
follow these steps:
1. Select the entire project in the project tree in order to print out the entire project. To print
only individual elements within a project, select them in the project tree.
2. Select the "Print" command in the "Project" menu.
The "Print" dialog opens.
3. Select the printer in the "Name" box.
4. Click "Advanced" to modify the Windows printer settings.
5. Select the frame layout you want to use for the printout.
Select the documentation information in the "Document information" drop-down list.
The frame stored in the document information is used for the printout. All placeholders
within the chosen frame are filled with the metadata from the selected document
information.
Select the "Print cover page" check box to print the cover page, which is stored in the
selected document information.
Select the "Print table of contents" check box to add a table of contents to the printout.
The check boxes for printing the cover page and the table of contents can only be selected
if you have started the printout in the project tree.
6. Under "Print objects/area", select what is to be printed. The selection is only possible if you
have started the printout from an editor that supports this function.
Choose "All" to print out the entire content of the editor.
Choose "Selection" to print only the objects currently selected in the editor.
7. Select the print scope under "Properties".
Choose "All" to print all configuration data of the selected objects.
Choose "Visible" to print the information of an editor that is currently visible on the
screen. This option can only be chosen if you have started the printout from an editor.
Choose "Compact" to print out an abbreviated version of the project data.
8. Click "Preview" to generate a print preview in advance.
A print preview is created in the work area.
9. Click "Print" to start the printout.
Note
Scope of the "Print" dialog
The options available in the "Print" dialog vary depending on the elements to be printed.
Editing projects
7.5 Editing project data
STEP 7 Basic V12.0
System Manual, 01/2013, 277
Result
The project data is prepared in the background for printing and then printed on the selected
printer. The status bar shows the progress of the print operation. You can continue working
normally while data is being prepared for printing.
The print results and any errors or warnings are listed in the Inspector window under "Info" at
the conclusion of the print job.
Canceling a print job
To cancel an active print job, follow these steps:
1. Click the red "X" in the status bar next to the progress display for the printout.
The printout is cancelled promptly.
See also
Protection concept for project data (Page 257)
Revoking access rights for devices (Page 258)
Printout of project contents (Page 260)
Designing cover pages and frames (Page 267)
7.5.4.2 Printing module labels
Print function for module labels
Printing of module labels for hardware modules
You can print labels for the modules in your project with the help of the TIA Portal. The labels
are custom-fit to each module and can contain the following printed information:
Symbolic name of the input or output
Absolute address of the input or output
Symbolic name and additionally the absolute address of the input or output. The order of
the information can be specified.
The modules are displayed graphically in the device view. If you set the zoom level in the
device view to at least 200%, the labels for the individual modules will be visible. The printout
on the labels corresponds to the representation of the labeling in the device view.
The following figure shows an example of two modules in the device view on which the labeling
of the inputs and outputs is visible:
Editing projects
7.5 Editing project data
STEP 7 Basic V12.0
278 System Manual, 01/2013,
Export and further editing as Microsoft Word file
Before you can print them, the labels are first exported as a Microsoft Word file (.docx). This
file can be further edited with commonly available word processing programs such as Microsoft
Word 2010. The individual labels are represented as a table in the .docx file. You can format
the text or the backgrounds of the individual cells as desired.
The character spacing of the text within the table is adapted by default, so that texts are not
truncated. If you want to prevent this from stretching or compressing the text too much, change
the character spacing of the text in the table cell properties.
Print media
You can print the labels either on ready-made print sheets or on standard DIN A4 paper. You
can separate the individual labels from the ready-made print sheets and insert them in the
designated labeling areas of your modules. If you print on standard paper, the individual labels
must be cut out. Cut marks are automatically included on the printout and serve as aids.
Because the paper feeds of different printers differ slightly, the printout may be slightly offset
on the paper. When the labels are printed on ready-made print sheets, printing that is accurate
to the millimeter is important, because otherwise the text will not be custom-fit inside the
stamped area. In addition, if the printing is imprecise, the labeling of an input or output may
no longer be congruent with the channel status displays of the module. For this reason, you
can enter an offset value for your printer in the TIA Portal to ensure precise printing. For
information on how to determine the proper offset value for your printer, refer to Chapter
"Determining the print area offset (Page 281)".
Editing projects
7.5 Editing project data
STEP 7 Basic V12.0
System Manual, 01/2013, 279
See also
Printing labels (Page 280)
Determining the print area offset (Page 281)
Documentation settings (Page 258)
Printing labels
You can print labels for the modules in your project if provision has been made for attaching
labels to the utilized modules. The labels are first exported to a Microsoft Word file (.docx). A
separate .docx file is created for each module family (for example, for all selected S7-1500
modules). You can then modify the labels according to your wishes. The labels are always
printed from the word processing program.
If no provision has been made for printing labels, the corresponding shortcut menu command
is inactive. If you have selected multiple modules for printing of labels and at least one of the
modules does not support this, a message is shown on the "Info > General" tab of the Inspector
window. The message lists all unsupported modules, and the export of the print file is continued
for the supported modules.
Requirement
The chosen modules must support the printing of labels.
A word processing program that supports Microsoft Word .docx files must be installed, e.g.,
Microsoft Word 2010.
You need the ready-made labels for your modules or commercially available DIN A4 paper.
Procedure
To print labels for hardware modules, follow these steps:
1. In the project tree, select the modules for which you want to print labels.
You can select one or more stations in order to print out labels for all modules plugged
into these stations.
Or, select the desired modules below the stations in the "Local modules" folder.
2. Right-click on one of the devices, and select the "Export labels" command from the shortcut
menu.
The "Export labels" dialog box opens.
3. In the "Content of label" area, select which data are to be printed on the label.
Choose "Symbolic name" in order to print the symbolic name of the input or output
(corresponds to the contents of the "Name" column in the IO tag table).
Choose "Absolute address" in order to print the absolute address of the input or output
(corresponds to the contents of the "Address" column in the IO tag table).
Choose "Absolute and symbolic address" or "Symbolic and absolute address" in order
to print both addresses. The print order corresponds to the indicated order.
Editing projects
7.5 Editing project data
STEP 7 Basic V12.0
280 System Manual, 01/2013,
4. Select which paper you plan to print on in the "Paper type" area.
Choose "Print on SIEMENS label sheet" if you want to print on a ready-made label sheet
for your modules.
Choose "Print on standard paper" if you want to print on standard DIN A4 paper.
5. In the "Offset print area" area, select correction values for your printer, if required, for proper
orientation of the print area. This is only necessary if you are printing on ready-made labels.
Enter a correction value, in millimeters, in the "Vertical offset" field. A negative value
shifts the print area upward. A positive value shifts the print area downward.
Enter a correction value, in millimeters, in the "Horizontal offset" field. A negative value
shifts the print area to the left. A positive value shifts the print area to the right.
6. In the "Path" field, select the path to which the exported .docx files should be stored.
7. Click the "Export" button to start the export to a .docx file.
The .docx files are created.
8. Open the .docx files with a conventional word processing program, such as Microsoft Word
2010, and change the design of the labels if necessary.
9. Print out the labels from your word processing program. To do so, use the paper that you
specified in the Export dialog box.
10.If you are using ready-made sheets, separate the labels at the stamped lines provided for
that purpose. When standard DIN A4 paper is used, you must cut out the labels.
See also
Determining the print area offset (Page 281)
Determining the print area offset
If you are using a ready-made label sheet, the printing on it must be applied precisely so that
the text is properly oriented on the prestamped labels and will have the proper fit relative to
the channel status displays of the module. However, the paper feeds vary slightly from one
printer to another. For this reason, you must enter a suitable correction value for your printer
in the TIA Portal, if necessary. The print area is then shifted in the exported .docx file in such
a way that the printing fits precisely on the ready-made label sheet.
The settings for shifting the print area are stored for the specific Windows user. If you log on
to Windows using a different user name, you have to enter the correction values again.
The procedure for determining the correction value for your printer is described below.
Requirement
You require a ready-made label sheet.
You must have access to the actual printer that you will use subsequently for the printout.
The printer must be made ready for printing on standard DIN A4 paper.
Editing projects
7.5 Editing project data
STEP 7 Basic V12.0
System Manual, 01/2013, 281
Procedure
To determine the correction value for your printer, follow these steps:
1. Print out a label sheet on standard DIN A4 paper, as described in Chapter "Printing labels
(Page 280)".
2. Compare the printout on the DIN A4 paper with the ready-made label sheet.
3. If the print area is offset, you must use correction values.
Using a ruler, measure the horizontal offset relative to the ready-made label sheet. This
will be entered later in the "Horizontal offset" field of the Export dialog box for the printing.
If the print area is offset to the right, a negative correction value must be entered. If the
print area is offset to the left , a positive correction value must be entered.
Using a ruler, measure the vertical offset relative to the ready-made label sheet. This
will be entered later in the "Vertical offset" field of the Export dialog box for the printing.
If the print area is offset downward, a negative correction value must be entered. If the
print area is offset upward, a positive correction value must be entered.
Editing projects
7.5 Editing project data
STEP 7 Basic V12.0
282 System Manual, 01/2013,
7.6 Undoing and redoing actions
7.6.1 Basics of undoing and redoing actions
Function
You can undo performed actions at any time. For this purpose, every action you perform is
saved in an action stack. When undoing actions, the stack is processed from top to bottom. In
other words, if you undo an action that lies further down in the stack, all actions located above
it in the stack will also be undone automatically.
You can redo previously undone actions until you execute a new action. Once you execute a
new action, it is no longer possible to redo previously undone actions.
Particularities for undoing
There are a few actions that empty the action stack. You cannot undo these actions or the
actions performed before these actions. The following actions empty the action stack:
Saving
Project management (creating a new project, opening project, closing a project, deleting a
project)
Compiling
Restoring blocks
Establishing an online connection
Loading
Writing to memory cards
Displaying the action stack
The "Undo" button in the toolbar is enabled as soon as you perform an action that can be
undone. This button is split; you can use the arrow down portion to open a drop-down list
containing all actions of the action stack that you can undo. If you had performed actions in
an editor other than the currently displayed editor, the corresponding editor is also displayed
as a subheading. This allows you to always identify the point at which the undo operation will
be applied. The subheadings are removed from the list when the editor responsible can no
longer undo actions.
Actions you have undone are entered in the action stack from where they can be redone. Here,
you can redo actions you have undone. The display of actions you can redo it is analogous to
the display of the actions that you can undo.
Editing projects
7.6 Undoing and redoing actions
STEP 7 Basic V12.0
System Manual, 01/2013, 283
Example of undoing actions
The figure below shows how actions performed in various editors and tables are undone:
Hardware and
network editor
Programming editor
Messages
Task planner
"Save project"
Action stack
"Undo" sequence
1
2
3
4
5
6
7
8
9
10
In this example, you cannot undo actions 1 to 3 because the project was saved. You can undo
actions 4 to 10 in the order indicated by the direction of the arrow. In other words, you must
undo action 10 first. Once you have undone action 8, you cannot then undo action 5. You must
first undo actions 7 and 6. As the final step in the sequence, you can then undo action 4. You
also have the option of undoing several actions in a single step by undoing an action located
further down in the action stack. All actions located above it in the stack will be undone
automatically.
The same principle also applies to redoing of actions.
See also
Undoing an action (Page 284)
Redoing an action (Page 285)
7.6.2 Undoing an action
The following options are available for undoing actions:
Undoing the last action only
Only the last action performed is undone.
Undoing as many actions as required
Multiple actions in the action stack are undone in a single step.
Editing projects
7.6 Undoing and redoing actions
STEP 7 Basic V12.0
284 System Manual, 01/2013,
Undoing the last action only
To undo the last action performed, follow the steps below:
1. Click the "Undo" button in the toolbar.
If the action was not performed in the currently displayed editor, a confirmation prompt
appears.
If the undo operation requires an editor containing a protected object to be opened, you
must enter the password for the object.
2. Click "Yes" to confirm.
3. Enter the password, if necessary.
The editor in which the action was performed is displayed and the action is undone.
Undoing as many actions as required
To undo multiple actions in the action stack in a single step, follow these steps:
1. Click the Down arrow next to the "Undo" button in the toolbar.
This opens a drop-down list containing all actions you can undo. Actions performed in other
editors are identified by the editor name in the subheading.
2. Click the action you want to undo.
The chosen action and all actions in the stack located above the chosen action are undone.
If the undo operation requires an editor containing a protected object to be opened, you
must enter the password for the object.
3. Enter the required passwords, if necessary.
The editors in which the actions were performed are displayed and the actions are undone.
See also
Basics of undoing and redoing actions (Page 283)
Redoing an action (Page 285)
7.6.3 Redoing an action
You have the option of redoing an action that has been undone, so that you can return to the
status present before "Undo" was performed. However, this is only possible until you perform
a new action. The following options are available for redoing actions:
Redoing the last undone action only
Only the last undone action is redone.
Redoing as many undone actions as required
Multiple undone actions in the action stack are redone in a single step.
Editing projects
7.6 Undoing and redoing actions
STEP 7 Basic V12.0
System Manual, 01/2013, 285
Redoing the last undone action only
To redo the last undone action, follow the steps below:
1. Click the "Redo" button in the toolbar.
If the action is not being redone in the currently displayed editor, a confirmation prompt
appears.
If the redo operation requires an editor containing a protected object to be opened, you
must enter the password for the object.
2. Click "Yes" to confirm.
3. Enter the password, if necessary.
The editor in which the action was undone is displayed and the action is redone.
Redoing as many undone actions as required
To redo multiple undone actions in the action stack in a single step, follow these steps:
1. Click the Down arrow next to the "Redo" button in the toolbar.
This opens a drop-down list containing all actions you can redo. Actions performed in other
editors are identified by the editor name in the subheading.
2. Click the action you want to redo.
The chosen action and all actions in the stack located above the chosen action are redone.
If the redo operation requires an editor containing a protected object to be opened, you
must enter the password for the object.
3. Enter the required passwords, if necessary.
The editors in which the actions were undone are displayed and the actions are redone.
See also
Basics of undoing and redoing actions (Page 283)
Undoing an action (Page 284)
Editing projects
7.6 Undoing and redoing actions
STEP 7 Basic V12.0
286 System Manual, 01/2013,
7.7 Finding and replacing in projects
7.7.1 Information on the search function
Find and replace
You can search for texts in the editors. The search function finds all texts containing the search
key in the currently opened editor. The results are selected in sequence in the opened editor.
You also have the following options:
Narrowing down the search with additional options
Replacing found texts
The additional options and the type of texts for which you can search depend on the installed
products and the currently open editor.
See also
Search and replace (Page 287)
7.7.2 Search and replace
Using Find
The "Find and replace" function enables you to search for or replace texts in an editor.
Additional options for searching
You can narrow down your search by selecting one of the following additional options:
Whole words only
Only whole words are found. Words that contain the search key as part of the word are
ignored.
Match case
Upper- and lowercase letters are taken into account in the search.
Find in substructures
The search also includes texts contained in another object.
Editing projects
7.7 Finding and replacing in projects
STEP 7 Basic V12.0
System Manual, 01/2013, 287
Find in hidden texts
Texts that are assigned to another text but that are currently hidden are also included in
the search.
Use wildcards
Enter an asterisk as the wildcard for any number of characters. Example: You want to
search for all words starting with "Device". Type in "Device*" in the search key box.
Enter a question mark as the wildcard, however, if you only want to leave out a single
character.
Use regular expressions (for searching in scripts only)
A regular expression is a character string used to describe sets of values and for filtering.
This allows you to create complex search patterns.
The additional options available depend on the installed products and the editor opened.
Start search
Follow these steps to start the "Find and replace" function:
1. Select the "Find and replace" command in the "Edit" menu or open the "Find and replace"
pane in the "Tasks" task card.
The "Find and replace" pane opens.
2. Enter a term in the "Find" drop-down list.
As an alternative, you can select the most recent search key from the drop-down list.
3. Select the options desired for the search.
4. Using the option buttons, select the starting point for the search and the search direction.
Select "Whole document" if you want to search through the entire editor regardless of
the current selection,
Select "From current position" if you want to start the search at the current selection.
Select "Selection" if you only want to search within the current selection.
Select "Down" to search through the editor from top to bottom or from left to right.
Select "Up" to search through the editor from bottom to top or from right to left.
5. Click "Find".
The first hit is marked in the editor.
6. Click "Find" again to display the next hit.
The next hit is marked in the editor. Repeat this process, as necessary, until you reach the
last hit.
Replacing the search key
You have the option of replacing hits individually or automatically replacing all the found texts,
if the respective editor supports this function. Follow these steps to replace terms:
1. Enter a term in the "Find" drop-down list.
As an alternative, you can select the most recent search key from the drop-down list.
2. Select the options desired for the search.
Editing projects
7.7 Finding and replacing in projects
STEP 7 Basic V12.0
288 System Manual, 01/2013,
3. Click the "Find" button to start a search for the specified search key.
The first hit is displayed in the editor.
4. In the "Replace" drop-down list, enter the text you wish to use to replace the search key.
As an alternative, you can select the most recently text specified from the drop-down list.
5. Click the "Replace" button to replace the selected hit with the specified text.
The found text is replaced and the next hit is marked in the editor.
Repeat this process until you have replaced all the hits as wanted. To skip to the next hit
without replacing the marked word, click the "Find" button instead of "Replace".
6. Click "Replace all" to automatically replace all hits at once.
See also
Information on the search function (Page 287)
Editing projects
7.7 Finding and replacing in projects
STEP 7 Basic V12.0
System Manual, 01/2013, 289
7.8 Working with text lists
7.8.1 Text lists
Introduction
You can manage texts to be referenced in alarms centrally. All the texts are stored in text lists.
Each text list has a unique name with which you can call up its content. A range of values is
assigned to each text in a text list. If a value from a range of values occurs, the corresponding
text is called up.
All the texts can be translated to all project languages. Here, you have two options available:
You can enter the translation of the texts in a list. You will find the list in the project tree
under "Languages & Resources > Project texts".
You can export all texts to a file in Office Open XML format and enter the translation in a
spreadsheet program. The translations can then be imported again.
The texts are translated into the other project languages within the framework of the project
texts. In the text lists editor, you only have to manage the assignment of individual texts to a
text list.
Each device in the project has its own text lists. For this reason, these lists are arranged under
the devices in the project tree. In addition, there are text lists that apply to all devices. These
can be found in the project tree under "Common data > Text lists".
User-defined and system-defined text lists
There are two types of text lists:
User-defined text lists
You can create user-defined text lists yourself and fill them with texts; in other words, you
can specify value ranges and the corresponding texts yourself. With user-defined text lists,
the name of the text list begins with "USER" as default. You can change this name to any
suitable name.
System-defined text lists
System-defined text lists are created by the system. These always involve texts relating to
devices. They are automatically created as soon as you insert a device in the project. With
system alarms, the name of the text list begins with "SYSTEM". The name of the text list
and the ranges of values it contains cannot be modified. You can only edit texts assigned
to individual value ranges.
User-defined text lists System-defined text lists
A user-defined text list can only be assigned to one
device.
System-defined text lists can be assigned both to
a device as well as to the entire project.
You can create new text lists and delete existing
text lists.
You cannot create new text lists or delete text lists.
Editing projects
7.8 Working with text lists
STEP 7 Basic V12.0
290 System Manual, 01/2013,
User-defined text lists System-defined text lists
You can add and delete value ranges in the text
lists.
You cannot add or delete value ranges in the text
lists.
You can specify both the value ranges as well as
the associated texts.
You can only edit the text associated with one
value range.
Device-specific and cross-device text lists
Device-specific text lists relate to only one device in the project and are therefore only valid
for this device. For this reason, they are arranged under a device in the project tree. Device-
specific text lists can be used-defined or created by the system.
If system-defined text lists are generally valid for several devices or not intended uniquely for
one device, these are grouped together in the project tree under "Common data". These text
lists are available for all devices. Cross-device text lists are always created by the system and
are used solely for system diagnostics alarms. For this reason, you cannot store any user-
defined text lists under "Common data".
See also
Exporting and importing project texts (Page 229)
7.8.2 Creating user-defined text lists
Creating text lists
You can create user-defined text lists for individual devices.
Requirement
You are in the project view.
A project is open.
The project includes a least one device.
Procedure
To create user-defined text lists, follow these steps:
1. Click on the arrow to the left of a device in the project tree.
The elements arranged below the device are displayed.
2. Double-click on "Text lists".
All the text lists assigned to the device are displayed in the work area listed in a table.
3. Double-click on the first free row in the table.
A new user-defined text list is created.
4. Enter a name for your new text list in the "Name" column.
Editing projects
7.8 Working with text lists
STEP 7 Basic V12.0
System Manual, 01/2013, 291
5. From the drop-down list in the "Selection" column, select whether you want to specify the
value ranges in decimal, binary or in bits. Depending on the device, there may be further
options available at this point.
6. Enter a comment in the "Comment" column.
A new user-defined text list has been created and you can now enter the value ranges and
texts.
7.8.3 Editing user-defined text lists
Editing user-defined text lists
You can enter value ranges and the corresponding texts in user-defined text lists. User-defined
text lists are always located below a device in the project tree.
Requirement
You are in the project view.
A project is open.
The project includes a least one device.
Adding to user-defined text lists with value ranges and texts
To add to user-defined text lists with value ranges and texts, follow these steps:
1. Click on the arrow to the left of a device in the project tree.
The elements arranged below are displayed.
2. Double-click on "Text lists".
All the text lists assigned to the device are displayed in the work area listed in a table.
3. Select a text list in the table.
The contents of the selected text list are displayed in the work area. There, you can enter
a value range and assign texts to the individual value ranges.
4. Enter the value ranges you require in the "Range from" and " Range to" columns. The entry
must be made in the numeric format selected for the text list.
5. Enter a text for each value range in the "Entry" column.
7.8.4 Editing system-defined text lists
Editing system-defined text lists
In system-defined text lists, you can only modify the individual texts assigned to a value range.
System-defined text lists are located in the project tree either below a device or under
"Common data".
Editing projects
7.8 Working with text lists
STEP 7 Basic V12.0
292 System Manual, 01/2013,
Requirement
You are in the project view.
A project is open.
The project includes a least one device.
Modifying texts in system-defined text lists
To edit texts in system-defined text lists that are assigned to a value range, follow these steps:
1. Click on the arrow to the left of a device in the project tree or the "Common data" element.
The elements arranged below are displayed.
2. Double-click on "Text lists".
All the text lists assigned to the device or used in common are displayed in the work area
listed in a table.
3. Select a text list in the table.
The contents of the selected text list are displayed in the work area. Here, you can add to
or edit the texts assigned to a value range.
4. Enter a text for each value range in the "Entry" column.
Editing projects
7.8 Working with text lists
STEP 7 Basic V12.0
System Manual, 01/2013, 293
7.9 Using memory cards
7.9.1 Basics about memory cards
Introduction
Memory cards are plug-in cards that come in a variety of types and can be used for a variety
of purposes. Depending on the device type or device family, memory cards can be used for
purposes, such as:
Load memory of a CPU
Storage medium for projects, firmware backups, or any other files
Storage medium for performing a firmware update
Storage medium for the PROFINET device name
For information regarding the technical variants of the respective memory cards and general
information on their handling, refer to the respective documentation for the device. For
information on handling memory cards in the TIA Portal, refer to the online help under keyword
"Memory Card".
NOTICE
Do not use memory cards for non-SIMATIC-related purposes, and do not use third-party
devices or Windows tools to format them. This will irrevocably overwrite the internal structure
of the memory card, rendering it unusable for SIMATIC devices!
See also
Adding a user-defined card reader (Page 294)
Accessing memory cards (Page 295)
Displaying properties of memory cards (Page 296)
7.9.2 Adding a user-defined card reader
Introduction
If your card reader is not detected automatically, you can add it manually.
Requirement
The project view is open.
Editing projects
7.9 Using memory cards
STEP 7 Basic V12.0
294 System Manual, 01/2013,
Procedure
To add a card reader, follow these steps:
1. Open the project tree.
2. Select the "Card Reader / USB memory > Add user-defined Card Reader" command in the
"Project" menu.
The "Add user-defined Card Reader" dialog opens.
3. In the drop-down list box, select the path for the card reader.
4. Confirm your entries with "OK".
See also
Basics about memory cards (Page 294)
Accessing memory cards (Page 295)
Displaying properties of memory cards (Page 296)
7.9.3 Accessing memory cards
Requirement
A memory card is inserted in the card reader.
The project view is open.
Procedure
To access memory cards, follow these steps:
1. Open the project tree.
2. Select the "Card Reader / USB memory > Card Reader / Show USB memory" command
in the "Project" menu.
The "Card reader / USB memory" folder is displayed in the project tree.
3. Open the "Card Reader / USB memory" folder.
You can now access the memory card.
Note
If data from a non-installed product is stored on the memory card, the folders that contain
these data are shown in gray. You receive an error message when you attempt to access
such a folder. Install the corresponding product if needed.
Editing projects
7.9 Using memory cards
STEP 7 Basic V12.0
System Manual, 01/2013, 295
See also
Basics about memory cards (Page 294)
Adding a user-defined card reader (Page 294)
Displaying properties of memory cards (Page 296)
7.9.4 Displaying properties of memory cards
You can display the properties for the utilized memory cards. Note that different memory cards
with different properties must be used, depending on the device.
Requirement
A memory card is inserted in the card reader.
The project view is open.
Procedure
To display the properties of a memory card, follow these steps:
1. Right-click on the memory card for which you want to display the properties.
2. Select the "Properties" command in the shortcut menu.
The "Memory Card <name of the memory card>" dialog opens. The properties are displayed
in this dialog.
See also
Basics about memory cards (Page 294)
Adding a user-defined card reader (Page 294)
Accessing memory cards (Page 295)
Editing projects
7.9 Using memory cards
STEP 7 Basic V12.0
296 System Manual, 01/2013,
7.10 Using libraries
7.10.1 Library basics
Introduction
You can store objects you want to use more than once in libraries. It is possible to reuse the
stored objects throughout a project or across projects. This means you can, for example, create
block templates for use in different projects and adapt them to the particular requirements of
your automation task.
Library types
Depending on the task, you can use one of the following library types:
Project library
Each project has its own library. Here, you store the objects you want to use more than
once in the project. This project library is always opened, saved, and closed together with
the current project.
Global libraries
You can also create other libraries in addition to the project library. Here, you store the
objects you want to use in more than one project. You can create, change, save, and
transfer these global libraries independent of projects.
In the global libraries area, you will also find libraries that ship with the software. These
include off-the-peg functions and function blocks that you can use within your project. You
cannot modify the supplied libraries.
Library objects
Libraries can accommodate a large number of objects. These include, for example:
Functions (FCs)
Function blocks (FBs)
Data blocks (DBs)
Devices
PLC data types
Watch and force tables
Process screens
Faceplates
For objects with know-how protection, this protection is also retained after the object is inserted
into a library.
Editing projects
7.10 Using libraries
STEP 7 Basic V12.0
System Manual, 01/2013, 297
Use types
You can use the library elements as either a master copy or a type. You can use master copies
to generate copies of the library element that are independent of one another. You can derive
and use instances from types. The instances are bound to their respective type. Types are
marked with a green triangle in the "Libraries" task card; their instances are marked with a
black triangle in the project tree.
Note
Please note the following:
The use as a type is not available for every object.
You can also create types in a global library. Once you derive instances, however, the
type is additionally created in the project library. The instance is then only linked to the
type in the project library.
PLC data types and block interfaces are enhanced upward compatible. This allows you
to add new parameters. However, if you rename the existing parameters, this will result
in the loss of the parameter supply in the block call.
Comparing library objects
You can compare library objects to the objects of a device. You can thereby determine, for
example, whether certain library elements were used in a project and whether the library
element has been changed.
See also
Project library basics (Page 304)
Global library basics (Page 313)
Overview of the "Libraries" task card (Page 298)
Overview of the library view (Page 301)
7.10.2 Using the "Libraries" task card
7.10.2.1 Overview of the "Libraries" task card
Function of the "Libraries" task card
The "Libraries" task card enables you to work efficiently with the project library and the global
libraries.
You can show or hide the task card as needed.
Editing projects
7.10 Using libraries
STEP 7 Basic V12.0
298 System Manual, 01/2013,
Layout of the "Libraries" task card
The "Libraries" task card consists of the following components:
Library tree
Library overview
"Library view" button
"Open or close library overview" button
Library tree
The library tree is similar to the "Libraries" task card, apart from a few minor differences. In
contrast to the task card, there is no "Elements" palette, because the elements are displayed
in the library overview. You can also close the library view and open or close the library
overview in the library tree.
See also: "Libraries" task card (Page 298)
Editing projects
7.10 Using libraries
STEP 7 Basic V12.0
302 System Manual, 01/2013,
Library overview
The library overview corresponds to the overview window and displays the elements of the
currently selected object in the library tree. You can display the elements in three different
views. In addition, you can perform the following actions in the library overview:
Renaming elements
Deleting elements
Copying elements
Moving elements
WinCC only: Editing faceplates and HMI user data types
See also: Overview window (Page 186)
See also
Opening and closing the library view (Page 303)
Library basics (Page 297)
Comparing library elements (Page 332)
Working with the project library (Page 304)
Working with global libraries (Page 313)
7.10.3.2 Opening and closing the library view
Opening the library view
To open the library view, follow these steps:
1. Open the "Libraries" task card.
2. Click the "Open library view" button in the "Libraries" task card.
The library tree opens. The "Library" task card and the project tree are closed.
3. If the library overview is not displayed, click "Open/close library overview" button in the
library tree.
The library overview opens.
Editing projects
7.10 Using libraries
STEP 7 Basic V12.0
System Manual, 01/2013, 303
Closing the library view
To close the library view, follow these steps:
1. Click the "Close library view" button in the library tree.
The library tree closes. The "Libraries" task card and the project tree are opened.
See also
Overview of the library view (Page 301)
Library basics (Page 297)
Using the "Libraries" task card (Page 298)
Working with the project library (Page 304)
Working with global libraries (Page 313)
Comparing library elements (Page 332)
7.10.4 Working with the project library
7.10.4.1 Project library basics
Function
In the project library, you can store the elements that you want to use more than once in the
project. The project library is generated and saved automatically with the project.
See also
Library basics (Page 297)
7.10.4.2 Creating folders in the project library
The library elements are stored according to their type in the "Types" and "Master copies"
folders within the project library. You can add subfolders to these folders as required.
Requirement
The "Libraries" task card is displayed or the library view is open.
Editing projects
7.10 Using libraries
STEP 7 Basic V12.0
304 System Manual, 01/2013,
Procedure
To create a new folder, follow these steps:
1. Right-click any folder within the project library.
2. Select "Add folder" from the shortcut menu.
A new folder is created.
3. Enter a name for the new folder.
See also
Project library basics (Page 304)
Adding elements to the project library (Page 305)
Using elements of the project library (Page 308)
Editing elements of a project library (Page 310)
Removing elements from the project library (Page 312)
Filtering the view (Page 312)
7.10.4.3 Adding elements to the project library
Adding master copies to the project library
If you want to add master copies to the project library, you have the following options:
You can select an element and generate a master copy from it
You can select multiple elements and generate a master copy from them
You can select multiple elements and generate a master copy from each element
Requirement
The "Libraries" task card is displayed.
Creating a master copy from one element
To create a master copy from one element and add it to the project library, follow these steps:
1. Open the project library in the "Project library" palette of the "Libraries" task card.
2. Drag-and-drop the element you want to add to the project library as a master copy into the
"Master copies" folder or any of its subfolders in the project library. Release the left mouse
button when a small plus symbol appears below the mouse pointer.
The element is inserted into the project library as a master copy. You can generate copies
from this master copy and use them wherever this is permitted in the TIA Portal.
Editing projects
7.10 Using libraries
STEP 7 Basic V12.0
System Manual, 01/2013, 305
Creating a master copy from multiple elements
To create a master copy from multiple elements and add it to the project library, follow these
steps:
1. Open the project library in the "Project library" palette of the "Libraries" task card.
2. Select the elements from which you want to create a master copy.
3. Drag the elements and drop them into the "Master copies" folder or any subfolder of "Master
copies" in the project library. Release the left mouse button when a small plus symbol
appears below the mouse pointer.
The element is inserted into the project library as a master copy. You can generate copies
from this master copy and use them wherever this is permitted in the TIA Portal.
Creating a master copy for each element among multiple elements
To create a master copy for each element among multiple elements and add them to the project
library, follow these steps:
1. Open the project library in the "Project library" palette of the "Libraries" task card.
2. Select the elements from which you want to create master copies.
3. Select the "Copy" command in the shortcut menu.
4. Right-click on the "Master copies" folder or any of its subfolders in the project tree.
5. In the shortcut menu, select "Insert as separate master copies".
The elements are inserted into the project library as separate master copies. You can
generate copies from these master copies and use them wherever this is permitted in the
TIA Portal.
See also
Library basics (Page 297)
Project library basics (Page 304)
Adding types to the project library (Page 306)
Adding types to the project library
Depending on the element that you wish to add as a type, you can use the following procedures:
Generate a type from an existing element, for example, from code blocks or PLC data types
Generate directly as a type, for example, faceplates
Requirement
Your installed products contain objects from which types can be generated.
The "Libraries" task card is displayed.
Editing projects
7.10 Using libraries
STEP 7 Basic V12.0
306 System Manual, 01/2013,
Creating types from an existing element
To add an existing element to the project library as a type, follow these steps:
1. Open the project library in the "Project library" palette of the "Libraries" task card.
2. Drag-and-drop the element you want to add to the project library as a type into the "Types"
folder or any of its subfolders in the project library. Release the left mouse button when a
small plus symbol appears below the mouse pointer.
Or:
1. Copy the element you want to add as a type.
2. Open the project library in the "Project library" palette of the "Libraries" task card.
3. Right-click the "Types" folder or any of its subfolders.
4. Select the "Paste" command in the shortcut menu.
Generating directly as a type
To add a new type to the project library, follow these steps:
1. Open the project library in the "Project library" palette of the "Libraries" task card.
2. Right-click the "Types" folder or any of its subfolders.
3. Select the "Add new type" command in the shortcut menu.
The dialog for generating types opens.
Note
If your installed products do not contain any objects from which types can be generated,
the "Add new type" command is not available. Use master copies in this case.
4. In the dialog, choose the element from which you want to generate a type.
5. Specify all other necessary data.
6. Click "OK".
Result
A new type is generated and inserted into the project library. You can generate instances from
this type and use them anywhere in the TIA Portal where it is permissible. The instances are
always bound to the respective type.
Instances of a type are assigned a small black triangle as an additional symbol. This allows
you to identify the elements that are used as instances.
See also
Library basics (Page 297)
Project library basics (Page 304)
Adding master copies to the project library (Page 305)
Editing projects
7.10 Using libraries
STEP 7 Basic V12.0
System Manual, 01/2013, 307
7.10.4.4 Using elements of the project library
Using master copies
You use the master copies you inserted into the project library in order to generate copies of
elements and insert them in the TIA Portal, where permitted. The copies are generated and
used in a single operation.
Requirement
The "Libraries" task card is displayed.
Procedure
To generate and use a copy from a master copy, follow these steps:
1. Open the "Master copies" folder or any of its subfolders in the project library so that you
looking at the master copy from which you want to generate a copy.
2. Use a drag-and-drop operation to move the master copy from the project library to the
location where you want to use it. If you are not permitted to insert it at this location, the
mouse pointer changes to a circle with a slash.
A copy based on the master copy is inserted. If there is already an element with the same
name at this location, the "Paste" dialog opens. In this dialog, you can decide whether to
replace the existing element or to insert the copy with a different name.
Note
The "Paste" dialog is not displayed for all elements. The elements for which the dialog is
available depends on the installed products.
Or:
1. Open the element view.
2. Use a drag-and-drop operation to move the master copy from the "Elements" pane to the
location where you want to use it. If you are not permitted to insert it at this location, the
mouse pointer changes to a circle with a slash.
A copy based on the master copy is inserted. If there is already an element with the same
name at this location, the "Paste" dialog opens. In this dialog, you can decide whether to
replace the existing element or to insert the copy with a different name.
Note
The "Paste" dialog is not displayed for all elements. The elements for which the dialog is
available depends on the installed products.
Result
A copy is generated from the master copy and inserted at the location where you want to use
it. You can create any number of copies from a master copy.
Editing projects
7.10 Using libraries
STEP 7 Basic V12.0
308 System Manual, 01/2013,
See also
Library basics (Page 297)
Project library basics (Page 304)
Using types (Page 309)
Using the element view (Page 301)
Using types
You use the types you inserted into the project library in order to generate instances of elements
and insert them in the TIA Portal, where permissible. The instances are generated and used
in a single operation.
Requirement
The "Libraries" task card is displayed.
Procedure
To generate and use an instance from a type, follow these steps:
1. Open the "Types" folder or any of its subfolders in the project library so that you looking at
the type from which you want to generate an instance.
2. Use a drag-and-drop operation to move the type from the project library to the location
where you want to use it. If you are not permitted to insert it at this location, the mouse
pointer changes to a circle with a slash.
The type is inserted as an instance. If there is already an element with the same name at
this location, the "Paste" dialog opens. In this dialog, you can decide whether to replace
the existing element or to insert the instance with a different name.
Note
The "Paste" dialog is not displayed for all elements. The elements for which the dialog is
available depends on the installed products.
Or:
1. Open the element view.
2. Use a drag-and-drop operation to move the type from the "Elements" pane to the location
where you want to use it. If you are not permitted to insert it at this location, the mouse
pointer changes to a circle with a slash.
The type is inserted as an instance. If there is already an element with the same name at
this location, the "Paste" dialog opens. In this dialog, you can decide whether to replace
the existing element or to insert the instance with a different name.
Note
The "Paste" dialog is not displayed for all elements. The elements for which the dialog is
available depends on the installed products.
Editing projects
7.10 Using libraries
STEP 7 Basic V12.0
System Manual, 01/2013, 309
Result
An instance is generated from the type and inserted at the location where you want to use it.
You can create any number of instances from a type. The instances are linked to their type.
See also
Library basics (Page 297)
Project library basics (Page 304)
Using master copies (Page 308)
7.10.4.5 Editing elements of a project library
You can use the following editing commands on library elements:
Copy
Cut
Paste
Move within the library
Rename
Each of these commands can always be executed via the keyboard (Page 195), menu, and
shortcut menu.
Requirement
The "Libraries" task card is displayed or the library view is open.
Copying elements
To copy a library element, follow these steps:
1. Right-click on the library element you want to copy.
2. Select the "Copy" command in the shortcut menu.
Cutting elements
To cut a library element, follow these steps:
1. Right-click on the library element you want to cut.
2. Select the "Cut" command in the shortcut menu.
Note
You can only paste previously cut library elements into the same library. In so doing, you can
only paste master copies into the "Master copies" folder or any of its subfolders. Likewise,
you can only paste types into the "Types" folder or any of its subfolders.
Editing projects
7.10 Using libraries
STEP 7 Basic V12.0
310 System Manual, 01/2013,
Pasting elements
To paste a library element, follow these steps:
1. Copy a library element.
2. Right-click the library where you want to paste the element.
3. Select the "Paste" command in the shortcut menu.
Moving elements
To move a library element, follow these steps:
1. Select the library element you want to move.
2. Use a drag-and-drop operation to move the library element to the folder where you want
to insert the element.
Note
Please note the following:
When you move an element from one library to another, the element is copied and not
moved.
You cannot move master copies into a type folder or a type into a master copies folder.
Renaming elements
To rename a library element, follow these steps:
1. Right-click the element you want to rename.
2. Select the "Rename" command in the shortcut menu.
3. Enter the new name.
See also
Library basics (Page 297)
Project library basics (Page 304)
Creating folders in the project library (Page 304)
Adding elements to the project library (Page 305)
Using elements of the project library (Page 308)
Removing elements from the project library (Page 312)
Filtering the view (Page 312)
Editing projects
7.10 Using libraries
STEP 7 Basic V12.0
System Manual, 01/2013, 311
7.10.4.6 Removing elements from the project library
Requirement
The "Libraries" task card is displayed or the library view is open.
Procedure
To remove an element from the project library, follow these steps:
1. In the "Project library" pane, maximize the folder containing the element you want to remove.
2. Right-click the element.
3. Select the "Delete" command in the shortcut menu.
Or:
1. Open the element view or the library overview.
2. Right-click the element you want to remove in the "Elements" pane.
3. Select the "Delete" command in the shortcut menu.
See also
Library basics (Page 297)
Project library basics (Page 304)
Creating folders in the project library (Page 304)
Adding elements to the project library (Page 305)
Using elements of the project library (Page 308)
Editing elements of a project library (Page 310)
Filtering the view (Page 312)
7.10.4.7 Filtering the view
To make viewing of extensive libraries more straightforward, you can use filter options to limit
the display.
Requirement
The "Libraries" task card is displayed or the library view is open.
Editing projects
7.10 Using libraries
STEP 7 Basic V12.0
312 System Manual, 01/2013,
Procedure
To filter the view, follow these steps:
1. Open either the "Project library" pane or "Global libraries" pane.
2. In the drop-down list, select the object type for which you want to display the library
elements.
Result
Only the library elements that are available for the object type are displayed. You can set the
filter to "All" at any time to revert to an unfiltered view.
See also
Library basics (Page 297)
Project library basics (Page 304)
Creating folders in the project library (Page 304)
Adding elements to the project library (Page 305)
Using elements of the project library (Page 308)
Editing elements of a project library (Page 310)
Removing elements from the project library (Page 312)
7.10.5 Working with global libraries
7.10.5.1 Global library basics
Function
You can store elements that you want to reuse in other projects in global libraries. You must
create global libraries explicitly.
Depending on the products installed, global libraries supplied by Siemens are also installed.
You can use, but not change, the elements of these libraries.
You can continue using global libraries from TIA Portal V11. But you will have to upgrade them
to the latest TIA Portal version before you can use them.
Shared work with global libraries
You can use global libraries together with other users. This requires, however, that all users
who want to access to the global library open the library as read-only.
Editing projects
7.10 Using libraries
STEP 7 Basic V12.0
System Manual, 01/2013, 313
See also
Library basics (Page 297)
Continue using libraries from TIA Portal V11 (Page 316)
7.10.5.2 Creating a new global library
Requirement
The "Libraries" task card is displayed or the library view is open.
Procedure
To create a new global library, follow these steps:
1. Click "Create new global library" in the toolbar of the "Global libraries" palette or select the
menu command "Options > Global libraries > Create new library".
The "Create new global library" dialog opens.
2. Specify the name and the storage location for the new global library.
3. Confirm your entries with "Create".
Result
The new global library is generated and inserted into the "Global libraries" palette. A folder
with the name of the global library is created in the file system at the storage location of the
global library. This actual library file is given the file name extension ".al12".
Editing projects
7.10 Using libraries
STEP 7 Basic V12.0
314 System Manual, 01/2013,
See also
Library basics (Page 297)
Global library basics (Page 313)
Opening a global library (Page 315)
Displaying properties of global libraries (Page 317)
Saving a global library (Page 318)
Closing a global library (Page 320)
Deleting a global library (Page 320)
Creating folders in the global libraries (Page 321)
Editing elements of a global library (Page 328)
Removing elements from a global library (Page 330)
Adding elements to a global library (Page 322)
Using elements of a global library (Page 325)
Using a supplied global library (Page 330)
Filtering the view (Page 331)
7.10.5.3 Opening a global library
Requirement
The "Libraries" task card is displayed or the library view is open.
Procedure
To open a global library, follow these steps:
1. Click "Open global library" in the toolbar of the "Global libraries" palette or select the menu
command "Options > Global libraries > Open library".
The "Open global library" dialog box is displayed.
2. Select the global library you want to open. You identify the library file by its file extension
".al12" or ".al11" (global libraries from TIA Portal V11).
Editing projects
7.10 Using libraries
STEP 7 Basic V12.0
System Manual, 01/2013, 315
3. Write protection is activated for the library. If you want to modify the global library, disable
the "Open as read-only".
Note
Note the following:
If you open the library as read-only, you cannot add any additional elements in the
global library.
All users have to open the library as read-only if multiple users want to access the
library. This is a requirement for shared access to the library.
4. Click "Open".
The selected global library is opened and inserted into the "Global libraries" palette.
Note
Using global libraries from TIA Portal V11
If you want to continue using global libraries from TIA Portal V11, you have to upgrade them
to the latest TIA Portal version.
See also
Continue using libraries from TIA Portal V11 (Page 316)
Library basics (Page 297)
Global library basics (Page 313)
Creating a new global library (Page 314)
Displaying properties of global libraries (Page 317)
Saving a global library (Page 318)
Closing a global library (Page 320)
Deleting a global library (Page 320)
Creating folders in the global libraries (Page 321)
Adding elements to a global library (Page 322)
Using elements of a global library (Page 325)
Editing elements of a global library (Page 328)
Removing elements from a global library (Page 330)
Using a supplied global library (Page 330)
Filtering the view (Page 331)
7.10.5.4 Continue using libraries from TIA Portal V11
If you want to use elements of a global library that was created with TIA Portal V11, you will
first have to upgrade the library. This step ensures that all used elements are compatible with
Editing projects
7.10 Using libraries
STEP 7 Basic V12.0
316 System Manual, 01/2013,
the latest version of the TIA Portal. The original library will remain unchanged and a copy is
created that can be used for the latest version of the TIA Portal.
An exception are those projects you created with TIA Portal V11 and that have not yet been
updated to the latest version of the TIA Portal. You can continue using global libraries from
TIA Portal V11 without restrictions in such a project.
Requirement
You have loaded a global library that was created with TIA Portal V11.
The library is not write-protected because it is located in a write-protected folder, for
example, or because it is simultaneously accessed by another installation of the TIA Portal.
Procedure
To upgrade global libraries for use in the current TIA Portal version, follow these steps:
1. Right-click on the global library you want to upgrade.
2. Select the "Upgrade library" command in the shortcut menu.
The "Upgrade" dialog opens.
3. Confirm with "Yes".
Result
The library is upgraded and saved as copy. The old library is closed and the new library is
uploaded.
See also
Opening a global library (Page 315)
Global library basics (Page 313)
Upgrading projects (Page 221)
7.10.5.5 Displaying properties of global libraries
You can display the properties of global libraries. Properties include the following:
General information about the library
This includes the following information: creation time, author, file path, file size, copyright,
etc. Many of the attributes can be changed.
Library history
The library history contains an overview of the migrations performed. Here you can also
call the log file for the migrations.
Editing projects
7.10 Using libraries
STEP 7 Basic V12.0
System Manual, 01/2013, 317
Support packages in the library
You can display an overview of the additional software needed to work with all devices in
the project.
Software products in the library
You can display an overview of all installed software products needed for the project.
Requirement
The "Libraries" task card is displayed or the library view is open.
Procedure
To display the properties of a global library, follow these steps:
1. Right-click the global library whose properties you want to display.
2. Select the "Properties" command in the shortcut menu.
A dialog containing the properties of the global libraries opens.
3. Select the properties in the area navigation that you want to have displayed.
See also
Opening a global library (Page 315)
Library basics (Page 297)
Global library basics (Page 313)
Creating a new global library (Page 314)
Saving a global library (Page 318)
Closing a global library (Page 320)
Deleting a global library (Page 320)
Creating folders in the global libraries (Page 321)
Adding elements to a global library (Page 322)
Using elements of a global library (Page 325)
Editing elements of a global library (Page 328)
Removing elements from a global library (Page 330)
Using a supplied global library (Page 330)
Filtering the view (Page 331)
7.10.5.6 Saving a global library
You can save changes made to global libraries not supplied by Siemens at any time. You can
save a global library under another name using the "Save library as" command.
Editing projects
7.10 Using libraries
STEP 7 Basic V12.0
318 System Manual, 01/2013,
Requirement
The "Libraries" task card is displayed or the library view is open.
The global library is not write protected.
Saving changes
To save a global library, follow these steps:
1. Right-click on the global library you want to save.
2. Select the "Save library" command in the shortcut menu.
Saving a global library under another name
To save a global library under another name, follow these steps:
1. Right-click the global library that you want to save under a different name.
2. Select the "Save library as" command in the shortcut menu.
The "Save global library as" dialog opens.
3. Select the storage location and enter the file name.
4. Confirm your entries with "Save".
The library is saved in the specified location under the new name. The original library is
retained.
See also
Library basics (Page 297)
Global library basics (Page 313)
Creating a new global library (Page 314)
Opening a global library (Page 315)
Displaying properties of global libraries (Page 317)
Closing a global library (Page 320)
Deleting a global library (Page 320)
Creating folders in the global libraries (Page 321)
Adding elements to a global library (Page 322)
Using elements of a global library (Page 325)
Editing elements of a global library (Page 328)
Removing elements from a global library (Page 330)
Using a supplied global library (Page 330)
Filtering the view (Page 331)
Editing projects
7.10 Using libraries
STEP 7 Basic V12.0
System Manual, 01/2013, 319
7.10.5.7 Closing a global library
Global libraries are independent of projects. This means that they are not closed together with
your project. You must therefore close global libraries explicitly.
Requirement
The "Libraries" task card is displayed or the library view is open.
Procedure
To close a global library, follow these steps:
1. Right-click on the global library you want to close.
2. Select the "Close library" command in the shortcut menu.
3. If you make changes to the global library, a dialog box opens where you can choose whether
you want to save the changes to the global library. Click "Yes" or "No", depending on
whether or not you would like to save your changes.
The global library is closed.
See also
Creating a new global library (Page 314)
Opening a global library (Page 315)
Displaying properties of global libraries (Page 317)
Saving a global library (Page 318)
Library basics (Page 297)
Global library basics (Page 313)
Deleting a global library (Page 320)
Creating folders in the global libraries (Page 321)
Adding elements to a global library (Page 322)
Using elements of a global library (Page 325)
Editing elements of a global library (Page 328)
Removing elements from a global library (Page 330)
Using a supplied global library (Page 330)
Filtering the view (Page 331)
7.10.5.8 Deleting a global library
You can delete global libraries that were not supplied by Siemens. Note, however, that this
action causes deletion of the entire library directory in the file system of your programming
device or PC.
Editing projects
7.10 Using libraries
STEP 7 Basic V12.0
320 System Manual, 01/2013,
Requirement
The "Libraries" task card is displayed or the library view is open.
Procedure
To delete a global library, follow these steps:
1. Right-click the global library you want to delete.
2. Select the "Delete" command in the shortcut menu.
3. Click "Yes" to confirm.
Result
The global library is removed from the "Global libraries" pane and deleted from the file system.
See also
Library basics (Page 297)
Global library basics (Page 313)
Creating a new global library (Page 314)
Opening a global library (Page 315)
Displaying properties of global libraries (Page 317)
Saving a global library (Page 318)
Closing a global library (Page 320)
Creating folders in the global libraries (Page 321)
Adding elements to a global library (Page 322)
Using elements of a global library (Page 325)
Editing elements of a global library (Page 328)
Removing elements from a global library (Page 330)
Using a supplied global library (Page 330)
Filtering the view (Page 331)
7.10.5.9 Creating folders in the global libraries
The library elements are stored according to their type in the "Types" and "Master copies"
folders within global libraries. You can add subfolders to these folders as required.
Requirement
The "Libraries" task card is displayed or the library view is open.
The global library is not write protected.
Editing projects
7.10 Using libraries
STEP 7 Basic V12.0
System Manual, 01/2013, 321
Procedure
To create a new folder, follow these steps:
1. Right-click any folder within the global library.
2. Select "Add folder" from the shortcut menu.
A new folder is created.
3. Enter a name for the new folder.
See also
Global library basics (Page 313)
Library basics (Page 297)
Creating a new global library (Page 314)
Opening a global library (Page 315)
Displaying properties of global libraries (Page 317)
Saving a global library (Page 318)
Closing a global library (Page 320)
Deleting a global library (Page 320)
Adding elements to a global library (Page 322)
Using elements of a global library (Page 325)
Editing elements of a global library (Page 328)
Removing elements from a global library (Page 330)
Using a supplied global library (Page 330)
Filtering the view (Page 331)
7.10.5.10 Adding elements to a global library
Adding master copies to a global library
If you want to add master copies to a global library, you have the following options:
You can select an element and generate a master copy from it
You can select multiple elements and generate a master copy from them
You can select multiple elements and generate a master copy from each element
Requirement
The "Libraries" task card is displayed.
The global library is not write protected.
Editing projects
7.10 Using libraries
STEP 7 Basic V12.0
322 System Manual, 01/2013,
Creating a master copy from one element
To create a master copy from one element and add it to a global library, follow these steps:
1. In the "Global libraries" palette of the "Libraries" task card, open the global library to which
you want to add the master copy.
2. Drag-and-drop the element you want to add as a master copy into the "Master copies" folder
or any of its subfolders in the global library. Release the left mouse button when a small
plus symbol appears below the mouse pointer.
The element is inserted into the global library as a master copy. You can generate copies
from this master copy and use them wherever this is permitted in the TIA Portal.
Creating a master copy from multiple elements
To create a master copy from multiple elements and add it to a global library, follow these
steps:
1. In the "Global libraries" palette of the "Libraries" task card, open the global library to which
you want to add the master copy.
2. Select the elements from which you want to create a master copy.
3. Drag-and-drop the elements to the "Master copies" folder or any of its subfolders in the
global library. Release the left mouse button when a small plus symbol appears below the
mouse pointer.
The element is inserted into the global library as a master copy. You can generate copies
from this master copy and use them wherever this is permitted in the TIA Portal.
Creating a master copy for each element among multiple elements
To create a master copy for each element among multiple elements and add them to a global
library, follow these steps:
1. In the "Global libraries" palette of the "Libraries" task card, open the global library to which
you want to add master copies.
2. Select the elements from which you want to create master copies.
3. Select the "Copy" command in the shortcut menu.
4. Right-click on the "Master copies" folder or any of its subfolders in the global library.
5. In the shortcut menu, select "Insert as separate master copies".
The elements are inserted into the global library as separate master copies. You can
generate copies from these master copies and use them wherever this is permitted in the
TIA Portal.
See also
Library basics (Page 297)
Global library basics (Page 313)
Adding types to a global library (Page 324)
Editing projects
7.10 Using libraries
STEP 7 Basic V12.0
System Manual, 01/2013, 323
Adding types to a global library
Depending on the element that you wish to add as a type, you can use the following procedures:
Generate a type from an existing element, for example, from code blocks or PLC data types
Generate directly as a type, for example, faceplates
If you derive an instance from a type in a global library, the type is also inserted into the project
library. The instance is then only linked to the type in the project library.
Requirement
Your installed products contain objects from which types can be generated.
The "Libraries" task card is displayed.
Creating types from an existing element
To add an existing element to a global library as a type, follow these steps:
1. In the "Global libraries" palette of the "Libraries" task card, open the global library to which
you want to add a type.
2. Drag-and-drop the element you want to add as a type into the "Types" folder or any of its
subfolders in the global library. Release the left mouse button when a small plus symbol
appears below the mouse pointer.
Or:
1. Copy the element you want to add as a type.
2. In the "Global library" palette of the "Libraries" task card, open the global library to which
you want to add a type.
3. Right-click the "Types" folder or any of its subfolders.
4. Select the "Paste" command in the shortcut menu.
Generating directly as a type
To add a new type to a global library, follow these steps:
1. In the "Global libraries" palette of the "Libraries" task card, open the global library to which
you want to add a type.
2. Right-click the "Types" folder or any of its subfolders.
3. Select the "Add new type" command in the shortcut menu.
The dialog for generating types opens.
Note
If your installed products do not contain any objects from which types can be generated,
the "Add new type" command is not available. Use master copies in this case.
4. In the dialog, choose the element from which you want to generate a type.
Editing projects
7.10 Using libraries
STEP 7 Basic V12.0
324 System Manual, 01/2013,
5. Specify all other necessary data.
6. Click "OK".
Result
The type is inserted in the global library. You can generate instances from this type and use
them anywhere in the TIA Portal where it is permissible. The instances are always bound to
the respective type.
Instances of a type are assigned a small black triangle as an additional symbol. This allows
you to identify the elements that are used as instances.
See also
Library basics (Page 297)
Global library basics (Page 313)
Adding master copies to a global library (Page 322)
7.10.5.11 Using elements of a global library
Using master copies
You use the master copies you inserted into the global library in order to generate copies of
elements and insert them in the TIA Portal, where permitted. The copies are generated and
used in a single operation.
Requirement
The "Libraries" task card is displayed.
Procedure
To generate and use a copy from a master copy, follow these steps:
1. Open the "Master copies" folder or any of its subfolders in the global library so that you
looking at the master copy from which you want to generate a copy.
2. Use a drag-and-drop operation to move the master copy from the global library to the
location where you want to use it. If you are not permitted to insert it at this location, the
mouse pointer changes to a circle with a slash.
A copy based on the master copy is inserted. If there is already an element with the same
name at this location, the "Paste" dialog opens. In this dialog, you can decide whether to
replace the existing element or to insert the copy with a different name.
Note
The "Paste" dialog is not displayed for all elements. The elements for which the dialog is
available depends on the installed products.
Editing projects
7.10 Using libraries
STEP 7 Basic V12.0
System Manual, 01/2013, 325
Or:
1. Open the element view.
2. Use a drag-and-drop operation to move the master copy from the "Elements" palette or the
"Info" palette to the location where you want to use it. If you are not permitted to insert it at
this location, the mouse pointer changes to a circle with a slash.
A copy based on the master copy is inserted. If there is already an element with the same
name at this location, the "Paste" dialog opens. In this dialog, you can decide whether to
replace the existing element or to insert the copy with a different name.
Note
The "Paste" dialog is not displayed for all elements. The elements for which the dialog is
available depends on the installed products.
Result
A copy is generated from the master copy and inserted at the location where you want to use
it. You can create any number of copies from a master copy.
See also
Library basics (Page 297)
Global library basics (Page 313)
Using types (Page 326)
Using the element view (Page 301)
Using types
You use the types you inserted into a global library in order to generate instances of elements
and insert them in the TIA Portal, where permissible. The instances are generated and used
in a single operation.
Requirement
The "Libraries" task card is displayed.
Editing projects
7.10 Using libraries
STEP 7 Basic V12.0
326 System Manual, 01/2013,
Procedure
To generate and use an instance from a type, follow these steps:
1. Open the "Types" folder or any of its subfolders in the global library so that you looking at
the type from which you want to generate an instance.
2. Use a drag-and-drop operation to move the type from the global library to the location where
you want to use it. If you are not permitted to insert it at this location, the mouse pointer
changes to a circle with a slash.
The type is inserted as an instance. If there is already an element with the same name at
this location, the "Paste" dialog opens. In this dialog, you can decide whether to replace
the existing element or to insert the instance with a different name.
Note
The "Paste" dialog is not displayed for all elements. The elements for which the dialog is
available depends on the installed products.
Or:
1. Open the element view.
2. Use a drag-and-drop operation to move the type from the "Elements" pane to the location
where you want to use it. If you are not permitted to insert it at this location, the mouse
pointer changes to a circle with a slash.
The type is inserted as an instance. If there is already an element with the same name at
this location, the "Paste" dialog opens. In this dialog, you can decide whether to replace
the existing element or to insert the instance with a different name.
Note
The "Paste" dialog is not displayed for all elements. The elements for which the dialog is
available depends on the installed products.
Result
An instance is generated from the type and inserted at the location where you want to use it.
You can create any number of instances from a type. The instances are linked to their type.
See also
Library basics (Page 297)
Global library basics (Page 313)
Using master copies (Page 325)
Using the element view (Page 301)
Editing projects
7.10 Using libraries
STEP 7 Basic V12.0
System Manual, 01/2013, 327
7.10.5.12 Editing elements of a global library
You can use the following editing commands on library elements:
Copy
Cut
Paste
Move within the library
Rename
Each of these commands can always be executed via the keyboard (Page 195), menu, and
shortcut menu.
Requirement
The "Libraries" task card is displayed or the library view is open.
The global library is not write protected.
Copying elements
To copy a library element, follow these steps:
1. Right-click on the library element you want to copy.
2. Select the "Copy" command in the shortcut menu.
Cutting elements
To cut a library element, follow these steps:
1. Right-click on the library element you want to cut.
2. Select the "Cut" command in the shortcut menu.
Note
You can only paste previously cut library elements into the same library. In so doing, you can
only paste master copies into the "Master copies" folder or any of its subfolders. Likewise,
you can only paste types into the "Types" folder or any of its subfolders.
Pasting elements
To paste a library element, follow these steps:
1. Copy a library element.
2. Right-click the library where you want to paste the element.
3. Select the "Paste" command in the shortcut menu.
Editing projects
7.10 Using libraries
STEP 7 Basic V12.0
328 System Manual, 01/2013,
Moving elements
To move a library element within a library, follow these steps:
1. Select the library element you want to move.
2. Drag the library element to the library where you want to insert the element.
Note
When you move an element from one library to another, the element is copied and not moved.
Renaming elements
To rename a library element, follow these steps:
1. Right-click the element you want to rename.
2. Select the "Rename" command in the shortcut menu.
3. Enter the new name.
See also
Library basics (Page 297)
Global library basics (Page 313)
Creating a new global library (Page 314)
Opening a global library (Page 315)
Displaying properties of global libraries (Page 317)
Saving a global library (Page 318)
Closing a global library (Page 320)
Deleting a global library (Page 320)
Creating folders in the global libraries (Page 321)
Adding elements to a global library (Page 322)
Using elements of a global library (Page 325)
Removing elements from a global library (Page 330)
Using a supplied global library (Page 330)
Filtering the view (Page 331)
Editing projects
7.10 Using libraries
STEP 7 Basic V12.0
System Manual, 01/2013, 329
7.10.5.13 Removing elements from a global library
Requirement
The "Libraries" task card is displayed or the library view is open.
The global library is not write protected.
Procedure
To remove an element from a global library, follow these steps:
1. In the "Global libraries" pane, maximize the folder containing the element you want to
remove.
2. Right-click the element.
3. Select the "Delete" command in the shortcut menu.
Or:
1. Open the element view or the library overview.
2. Right-click the element you want to remove in the "Elements" pane.
3. Select the "Delete" command in the shortcut menu.
See also
Library basics (Page 297)
Global library basics (Page 313)
Creating a new global library (Page 314)
Opening a global library (Page 315)
Displaying properties of global libraries (Page 317)
Saving a global library (Page 318)
Closing a global library (Page 320)
Deleting a global library (Page 320)
Creating folders in the global libraries (Page 321)
Adding elements to a global library (Page 322)
Using elements of a global library (Page 325)
Editing elements of a global library (Page 328)
Using a supplied global library (Page 330)
Filtering the view (Page 331)
7.10.5.14 Using a supplied global library
Depending on the products you install, various global libraries ship with the system.
Editing projects
7.10 Using libraries
STEP 7 Basic V12.0
330 System Manual, 01/2013,
Requirement
The "Libraries" task card is displayed.
Procedure
To use an element from a supplied global library in your project, follow these steps:
1. Open the relevant library so that you can see the elements of the library.
2. Drag the element from the "Global libraries" pane and drop it on the location where you
want to use it. If you are not permitted to insert it at this location, the mouse pointer changes
to a circle with a slash.
Or:
1. Open the element view.
2. Use a drag-and-drop operation to move the element from the "Info" palette to the location
where you want to use it. If you are not permitted to insert it at this location, the mouse
pointer changes to a circle with a slash.
See also
Library basics (Page 297)
Global library basics (Page 313)
Creating a new global library (Page 314)
Opening a global library (Page 315)
Displaying properties of global libraries (Page 317)
Saving a global library (Page 318)
Closing a global library (Page 320)
Deleting a global library (Page 320)
Creating folders in the global libraries (Page 321)
Adding elements to a global library (Page 322)
Using elements of a global library (Page 325)
Editing elements of a global library (Page 328)
Removing elements from a global library (Page 330)
Filtering the view (Page 331)
7.10.5.15 Filtering the view
To make viewing of extensive libraries more straightforward, you can use filter options to limit
the display.
Editing projects
7.10 Using libraries
STEP 7 Basic V12.0
System Manual, 01/2013, 331
Requirement
The "Libraries" task card is displayed or the library view is open.
Procedure
To filter the view, follow these steps:
1. Open either the "Project library" pane or "Global libraries" pane.
2. In the drop-down list, select the object type for which you want to display the library
elements.
Result
Only the library elements that are available for the object type are displayed. You can set the
filter to "All" at any time to revert to an unfiltered view.
See also
Library basics (Page 297)
Global library basics (Page 313)
Creating a new global library (Page 314)
Opening a global library (Page 315)
Displaying properties of global libraries (Page 317)
Saving a global library (Page 318)
Closing a global library (Page 320)
Deleting a global library (Page 320)
Creating folders in the global libraries (Page 321)
Adding elements to a global library (Page 322)
Using elements of a global library (Page 325)
Editing elements of a global library (Page 328)
Removing elements from a global library (Page 330)
Using a supplied global library (Page 330)
7.10.6 Comparing library elements
Introduction
You can compare devices from libraries with devices from both the current project as well as
from the same or another libraries or reference projects. Note, however, that reference projects
are write-protected. When comparing library elements, you can always switch between
automatic and manual comparison.
Editing projects
7.10 Using libraries
STEP 7 Basic V12.0
332 System Manual, 01/2013,
Procedure
To compare library elements with the device data of a project, follow these steps:
1. In the project tree, select the device whose data you want to compare to a library element
and which allows offline/offline comparison.
2. Select "Compare > Offline/Offline" from the shortcut menu.
The compare editor opens with the selected device displayed in the left area.
3. Open the "Libraries" task card.
4. Select the library element that you want to compare to the device data.
5. Drag the library element into the right drop area of the compare editor.
You can identify the status of the objects based on the symbols in the status and action
area. When you select an object, the object's properties and the corresponding object of
the associated device is clearly shown in the properties comparison.
You can drag a library or other devices from a reference project from the current project
into drop areas at any time and thus start a new comparison. It does not matter which device
you drag into the drop area.
See also
Using the comparison editor (Page 247)
Carrying out offline/offline comparisons (Page 246)
Using the library view (Page 301)
Library basics (Page 297)
Overview of the "Libraries" task card (Page 298)
Overview of the library view (Page 301)
Using the element view (Page 301)
Working with the project library (Page 304)
Working with global libraries (Page 313)
Editing projects
7.10 Using libraries
STEP 7 Basic V12.0
System Manual, 01/2013, 333
7.11 Using cross-references
7.11.1 Using cross-references
Introduction to cross-references
The cross-reference list provides an overview of the use of objects within the project. You can
see which objects are interdependent and where the individual objects are located. Cross-
references are therefore part of the project documentation.
You can also jump directly to the point of use of an object.
Which objects you can display and localize in the cross-reference list depends on the installed
products.
Editing projects
7.11 Using cross-references
STEP 7 Basic V12.0
334 System Manual, 01/2013,
7.12 Simulating devices
7.12.1 Simulation of devices
Introduction
You can use the TIA Portal to run and test the hardware and software of the project in a
simulated environment. The simulation is performed directly on the programming device or
PC. No additional hardware is required.
The simulation software provides a graphical user interface for monitoring and changing the
configuration. It differs according to the currently selected device.
Integration in the TIA Portal
The simulation software is fully integrated in the TIA Portal but is only supported by certain
devices. Therefore, the button for calling the simulation software is only active if the selected
device supports simulation.
The simulation software for some devices requires its own virtual interface to communicate
with the simulated devices. The virtual interface can be found in the project tree under the
"Online access" entry next to the physical interfaces of the programming device/PC.
Once you have opened the software, additional help on the simulation software is available
via a separate link.
See also
Starting the simulation (Page 335)
7.12.2 Starting the simulation
Some devices can be simulated with additional software. You therefore do not have to have
the actual devices to perform comprehensive testing of your project.
Procedure
To start the simulation software, follow these steps:
1. Select the device you want to simulate, for example, in the project tree.
2. Select the "Simulation > Start" command in the "Online" menu.
This calls the simulation software.
See also
Simulation of devices (Page 335)
Editing projects
7.12 Simulating devices
STEP 7 Basic V12.0
System Manual, 01/2013, 335
Editing devices and networks
8
8.1 Configuring devices and networks
8.1.1 Hardware and network editor
8.1.1.1 Overview of hardware and network editor
Function of the hardware and network editor
The hardware and network editor opens when you double-click on the "Devices and Networks"
entry in the project tree. The hardware and network editor is the integrated development
environment for configuring, networking and assigning parameters to devices and modules. It
provides maximum support for the realization of the automation project.
Structure of the hardware and network editor
The hardware and network editor consists of the following components:
STEP 7 Basic V12.0
System Manual, 01/2013, 337
Device view (Page 341), network view (Page 339), topology view (Page 344)
Inspector window (Page 349)
Hardware catalog (Page 351)
The hardware and network editor provides you with three views of your project. You can switch
between these three views at any time depending on whether you want to produce and edit
individual devices and modules, entire networks and device configurations or the topological
structure of your project.
The inspector window contains information on the object currently marked. Here you can
change the settings for the object marked.
Drag the devices and modules you need for your automation system from the hardware catalog
to the network, device ot topology view.
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V12.0
338 System Manual, 01/2013,
8.1.1.2 Network view
Introduction
The network view is one of three working areas of the hardware and network editor. You
undertake the following tasks here:
Configuring and assign device parameters
Networking devices with one another
Structure
The following diagram shows the components of the network view:
Selection of a module
Editing option for addresses in the device overview
Selection options in the inspector window
Editing option for addresses in the inspector window
See also
Inspector window (Page 349)
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V12.0
System Manual, 01/2013, 377
Input and output addresses in the address overview
Introduction
The currently used input and output addresses can be displayed in the address overview in a
table form. The address overview can be found in the inspector window under "Properties" of
the CPU.
Design of the address overview
With the different check boxes, you can set which objects should be displayed in the address
overview:
Inputs: Display of the input addresses
Outputs: Display of the output addresses
Address gaps: Display of open address spaces
Slot: Display of the slot number
The following information is typically shown in the address overview:
Table header Meaning
Type Indicates whether the area is an input address area or an output address
area.
Address from Start address in the address range.
Address to End address in the address range.
Module Modules using the address area.
PIP Number of the process image partition. Shows if the cyclical OB in the
process image partition.
DP Number of the master system. You can use the number to determine which
slaves are assigned to a master. The value in brackets specifies the
PROFIBUS address of the hardware component.
PN Number of the IO system. The value in brackets stands for the device
number of the hardware component.
Racks Rack number on which the hardware component is inserted.
Slot Slot number on the rack in which the hardware component is inserted.
See also
Specifying input and output addresses (Page 576)
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V12.0
378 System Manual, 01/2013,
Update module version
Explanation of terms
The terms "Module version" and "Firmware version" are explained in more detail in the
following section.
Module version: The specific version of the configuration software from which the module
description stems.
Exp.: V11.0.0.0
Firmware version: The version of the firmware of the offline configured module
Exp.: V2.0
Requirements
You have created a device configuration.
You have installed an update or an optional package at a later date. As a result of this
installation, the module version of at least one module type was updated in the hardware
catalog, whereby the new version is incompatible with the previous version.
You have used such modules in your device configuration and want to use the modified or
added properties.
Procedure
Perform the following step for each affected module type.
1. Select the affected module in the device view.
2. In the Inspector window, go to "Properties > General > Catalog Information". Click the
"Update module version" button there.
3. In the query that then appears, specify whether you want to update the module version only
for the selected module or for all modules of this type in the current project.
Result
The selected modules are replaced by the same modules with updated module version in the
the current project.
In which cases is it unnecessary to update the module version?
An updating of the module version is not necessary in the following cases:
You do not want to used the modified or added properties of the modules.
You open an existing project with a version of the configuration software that is more recent
than the version with which you created the project and the system automatically performs
a project conversion, for example from V10.5 to V11.0. In this case, all older module
versions are automatically adapted.
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V12.0
System Manual, 01/2013, 379
8.1.3 Configure networks
8.1.3.1 Networking devices
Communication and networks
Communication between devices
The basis of all types of communication is always a previously configured network. The network
configuration provides the necessary requirements for communication:
All the devices in a network are provided with a unique address
Communication of the devices with consistent transmission properties
Network configuration
The following steps are necessary when configuring networks:
Connect devices to subnet
Specify the properties/parameters for each subnet
Specify the device properties for every networked module
Download configuration data to the devices to supply interfaces with the settings resulting
from the network configuration
Document the network configuration
For Open User Communication, creating and configuring a subnet is supported by the
assignment of connection parameters.
Relation between network configuration and project
Within a project, subnets and their properties are managed. Properties result mainly from
adjustable network parameters and the quantity and communication properties of the
connected devices.
The devices to be networked must be in the same project.
Subnet name and subnet ID
Within the project, subnets are clearly identified by a subnet name and ID. The subnet ID is
saved in all components along with interconnectable interfaces. Components can then be
clearly assigned to a subnet even after uploading into a project.
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V12.0
380 System Manual, 01/2013,
Networking options
In the project, you can create and network devices with components capable of
communication. The following basic options are available for networking the devices:
You link the interfaces of the components capable of communication with one another. A
new subnet is created suitable for the type of interface.
You connect the interface of the devices capable of communication with a new or existing
subnet.
You create an Open User Communication connection. When you assign parameters to the
connection for Open User Communication, a subnet is created automatically between the
communication partners.
You use the graphic connection configuration to configure connections; missing networks
are hereby recognized and are created either automatically or via dialog.
Due to the different tasks of the devices or the span of the plant, you may need to use several
subnets. These subnets are managed in a project.
Networking devices in the network view
Options
In the graphic network view, you have an overview of the subnets of the entire system in the
project. You can use the tabular network overview for additional support.
Depending on the starting situation, there are various ways of undertaking configuration to
network the interface for a component capable of communication. The procedures are
described in the following section:
Creating an individual subnet
Creating several subnets at one time
Connecting two target devices via a new subnet
Connecting devices to existing subnet
Selecting an existing subnet from a list
Automatic networking during the configuration of the connection;
See also: Auto-Hotspot
Possible starting situations are:
A suitable subnet is not yet available.
The subnet with which you want to connect the component already exists.
Procedure - creating a single subnet
To create a subnet and to connect it to an interface, proceed as follows:
1. Select the interface of a CPU / a CP.
2. Select the "Create subnet" command in the shortcut menu of the interface.
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V12.0
System Manual, 01/2013, 381
The selected interface is connected to a new subnet. Consistent address parameters are set
automatically for the interface.
The following schematic shows an interface with outgoing line connecting to a subnet:
Procedure - creating several subnets at one time
To create several subnets at one time, proceed as follows:
1. Select several interfaces by clicking on them while pressing the <Ctrl> button.
2. Select the "Create subnet" command in the shortcut menu of the interface.
Each selected interface is connected to a new subnet. Consistent address parameters are set
automatically for the interface.
The following figure shows multiple subnets created by selecting multiple interfaces:
Procedure Connecting two target devices via a new subnet
To connect an interface with another device via a subnet that does not yet exist, proceed as
follows:
1. Position the mouse pointer over the interface for a component capable of communication
requiring networking.
2. Click with the left mouse button and hold the button down.
3. Move the mouse pointer.
The pointer now uses the networking symbol to indicate "Networking" mode. At the same
time, the mouse pointer shows the lock symbol that will only disappear when the pointer is
on a valid target.
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V12.0
382 System Manual, 01/2013,
4. Now move the pointer onto the interface of the target device. You can either keep the mouse
button pressed or release it.
5. Now release the left mouse button or press it again (depending on previous action).
A new subnet is created. The interfaces are now connected via the new subnet. Consistent
address parameters are set automatically for the interface.
The following schematic shows two networked devices:
Procedure - Connecting devices to existing subnet
To connect an interface to an existing subnet, proceed as follows:
1. Position the mouse pointer on the interface of a communications-compliant component you
want to network or on the existing subnet.
2. Click with the left mouse button and hold the button down.
3. Move the mouse pointer.
The pointer now uses the networking symbol to indicate "Networking" mode. At the same
time, the mouse pointer shows the lock symbol that will only disappear once the pointer is
moved to a valid target.
4. Now move the mouse pointer to the existing subnet or to the interface to be networked.
You can either keep the mouse button pressed or release it.
5. Now release the left mouse button or press it again (depending on previous action).
Result:
The interface and selected subnet are now connected. Consistent address parameters are set
automatically for the interface.
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V12.0
System Manual, 01/2013, 383
Procedure - selecting an existing subnet from a list
To link an interface with a subnet that has already been created, proceed as follows:
1. Select the interface of a CPU.
2. Select the "Assign to new subnet" command in the shortcut menu of the interface.
A list box containing the available subnets appears.
3. Select a subnet from the list.
The interface and selected subnet are now connected. Consistent address parameters are set
automatically for the interface.
Tabular network overview
Meaning
The tabular network overview adds the following functions to the graphic network view:
You obtain detailed information on the structure and parameter settings of the devices.
Using the "Subnet" column, you can connect components capable of communication with
created subnets.
Basic functions for tables
The network overview supports the following basic functions for editing a table:
Displaying and hiding table columns
Note: The columns of relevance to configuration cannot be hidden.
Optimizing column width
Sorting table
Displaying the meaning of a column, a row or cell using tooltips.
Networking devices in the device view
Networking in the device view
In the device view, you can check and set all the parameters of the components belonging to
a device and the interfaces in detail. Here you can also assign the interfaces to the subnets
created in the project.
Requirements
The subnet with which you want to connect an interface has already been created.
If the subnet has not yet been created, change to the network view and make the settings
required for networking.
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V12.0
384 System Manual, 01/2013,
Procedure - connecting to an existing subnet
To connect an interface to an existing subnet, proceed in the device view as follows:
1. Select the entire communications-compliant component or the interface to be networked.
The properties of the selected interface or component are displayed in the Inspector window.
2. In the Inspector window, select the parameter group for the selected interface; for example,
the "Ethernet addresses" parameter group for a PROFINET interface.
3. Select the subnet to be connected from the "Interface connected with" drop-down list.
The interface and selected subnet are now connected. Consistent address parameters are set
automatically for the interface.
Procedure - creating a new subnet
To create a subnet and to connect it to the interface, proceed as follows in the device view:
1. Select the entire communications-compliant component or the interface to be networked.
The properties of the selected interface or component are displayed in the Inspector window.
2. In the Inspector window, select the parameter group for the selected interface; for example,
the "Ethernet addresses" parameter group for a PROFINET interface.
3. In "Interface connected with", click the "Add new subnet" button.
The interface is connected to a new subnet of the appropriate subnet type. Consistent address
parameters are set automatically for the interface.
Checking or changing network parameters and interface parameters
Introduction
Communication between networked devices requires the following parameters to be
configured:
Network parameters
Network parameters identify the network within the system configuration, for example, using
a name.
Interface parameters
Interface parameters define specific properties of a component capable of communication.
Addresses and transmission characteristics are set automatically and are consistent with
the network parameters.
Note
Network parameters and interface parameters are usually set during networking such that
communication can take place for numerous applications without the parameters having
to be changed.
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V12.0
System Manual, 01/2013, 385
Procedure - checking or changing network parameters
Proceed as follows to check or change network parameters:
1. Enter the network view.
2. Select the subnet from the network view.
You can see the network parameters in the "Properties" tab in the inspector window.
3. If necessary, check or modify the network parameters in the relevant group of parameters.
Procedure - checking or changing interface parameters
You can check and modify interface parameters in the network and device view.
Proceed as follows to check or change interface parameters:
1. Enter the network view or device view.
2. Select the interface.
You can see the interface parameters in the "Properties" tab in the inspector window.
3. If necessary, check or modify the interface parameters in the relevant group of parameters.
Changing networkings
Introduction
You can cancel an interface's network connection or assign it to another subnet of the same
subnet type.
Consequences
Depending on the version, a distinction should be made between:
Canceling a network connection for an interface
The configured parameters for the interface remain unchanged.
Assigning a network connection to another subnet
If the addresses in the assigned subnet are not unique, in other words, they already exist,
they will be changed automatically to make them unique.
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V12.0
386 System Manual, 01/2013,
Procedure - disconnecting from a network
Proceed as follows to cancel the network connection for an interface:
1. Select the networked interface.
2. Select the "Disconnect from subnet" command in the shortcut menu of the interface.
The network connection is deleted, the interface addresses are, however, not changed.
Configured connections are retained; however these connections are marked red in the
connection table because they are not networked. Specified connections remain specified.
See also
Networking devices in the network view (Page 381)
Copying, cutting or deleting subnets
Introduction
You can copy subnets as individual objects or copy them along with networked devices or
other networks.
For example, you can create complex configurations to be used more than once in different
variants within the project with no additional effort.
Effects on the copied subnet
Properties that have to be assigned explicitly within a project are re-assigned appropriately
when the copied objects are copied.
For subnets, this means: The subnet ID and name are re-assigned to the copied subnet.
The configured properties are adopted in the copied subnet.
Procedure - copying a subnet
Proceed as follows to copy one or more subnets:
1. Select one or more subnets.
2. In the shortcut menu, select the "Copy" command.
3. Select the "Paste" command in the shortcut menu.
The copied subnets are shown as "orphaned" subnets in the top part of the network view.
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V12.0
System Manual, 01/2013, 387
Procedure - copying a subnet with connected devices
To copy one or more subnets with networked devices, proceed as follows:
1. Select one or more subnets with the connected devices, for example by drawing a lasso
around them.
2. In the shortcut menu, select the "Copy" command.
3. Select the "Paste" command in the shortcut menu.
Complete copies of the subnets and connected devices are created.
Configured connections are adopted and remain within the copied devices. Connections to
devices that have not been copied are interrupted and become unspecified.
MPI network configuration
Allocating MPI addresses
Note the following for devices with an MPI interface: All devices of a subnet must have different
device addresses.
CPUs with MPI address ship with the default MPI address 2. Since you can only use this
address once in the MPI subnet, you will have to change the default address in all other CPUs.
The following applies to devices with the order no. 6ES7 3xx-xxxxx-0AB0:
When planning the MPI addresses for several CPUs, you have to fill "MPI address gaps" for
FMs and CPs with separate MPI addresses to prevent addresses being assigned twice.
Only when all the modules in a subnet have different addresses and your actual structure
matches that of the network configuration produced, should you load the settings across the
network.
Rules for assigning the MPI address
Allocate the MPI addresses in ascending order.
Reserve MPI address 0 for a programming device.
You can link up to 126 (addressable) devices with one another in an MPI subnet; up to 8
devices at a transfer speed of 19.2 KB/s.
All MPI addresses in an MPI subnet must be different.
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V12.0
388 System Manual, 01/2013,
You will find other rules relating to the structure of a network in the manuals for setting up
automation systems.
PROFIBUS network configuration
PROFIBUS addresses
Rules for the network configuration
All the devices in a subnet must have a different PROFIBUS address.
Only when all the modules in a subnet have different addresses and your actual structure
matches that of the network configuration produced, should you load the settings across the
network.
You can connect devices to the PROFIBUS subnet that communicate via configured
connections or that belong to a PROFIBUS DP master system.
You can find more information on configuring a DP master system in the following sections.
Requirements
The 121xC CPU is PROFIBUS compatible as of firmware version 2.0.
Rules for assigning PROFIBUS addresses
Allocate the PROFIBUS addresses in ascending order.
Reserve the PROFIBUS address "0" for a programming device.
Allocate a unique PROFIBUS address between 0 and 126 for each device on the
PROFIBUS network and/or for each DP master and each DP slave in the PROFIBUS
network.
There are modules with which the smallest address that can be set has to be greater than
1.
All PROFIBUS addresses of a PROFIBUS subnet must be different.
You will find additional rules relating to the structure of a network in the manuals for setting up
automation systems, for example SIMATIC S7-1200.
Note
PROFIBUS address "0"
Reserve PROFIBUS address "0" for a programming device that you will briefly connect up
to the PROFIBUS network at a later date for servicing.
See also
What you need to know about PROFIBUS bus parameters (Page 390)
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V12.0
System Manual, 01/2013, 389
What you need to know about PROFIBUS bus parameters
Matching parameters to one another
The PROFIBUS subnet will only function without problem if the parameters for the bus profile
are matched to one another. You should therefore only change the default values if you are
familiar with how to configure the bus profile for PROFIBUS.
Note
It may be possible for the bus parameters to be adjusted depending on the bus profile. If the
bus parameters cannot be adjusted, they are grayed out. The offline values of the bus
parameters are always shown even if you are online and linked to the target system.
The parameters shown apply to the entire PROFIBUS subnet and are briefly explained below.
Activating cyclic distribution of the bus parameters
If the "Enable cyclic distribution of the bus parameters" check box is selected under "Bus
parameters" while PROFIBUS subnet is selected in the Inspector window, the bus parameters
are transferred cyclically during operation by the modules that support this function. This allows
a programming device, for example, to be easily connected to the PROFIBUS in runtime.
You should deactivate this function:
For a heterogeneous PROFIBUS subnet (or more accurately: when external devices are
connected whose protocol uses the DSAP 63 for Multicast)
When in constant bus cycle time mode (minimize bus cycle)
Bus parameters for the bus profile of PROFIBUS subnets
Bus parameter Adjustable? Limit values
Tslot_Init Yes Max. Tsdr + 15 <= Tslot_init <= 16.383 t_bit
Max. Tsdr Yes 35 + 2*Tset + Tqui <= Max. Tsdr <= 1.023 t_bit
Min. Tsdr Yes 11 t_bit <= Min. Tsdr <= MIN(255 t_bit, ...
... Max. Tsdr - 1, 34 + 2*Tset + Tqui)
Tset Yes 1 t_bit <= Tset <= 494 t_bit
Tqui Yes 0 t_bit <= Tqui <= MIN(31 t_bit, Min. Tsdr - 1)
GAP factor Yes 1 <= GAP factor <= 100
Retry limit Yes 1 <= Retry limit <= 15
Tslot No ---
Tid2 No Tid2 = Max. Tsdr
Trdy No Trdy = Min. Tsdr
Tid1 No Tid1 = 35 + 2*Tset + Tqui
Ttr Yes 256 t_bit <= Ttr <= 16.777.960 t_bit
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V12.0
390 System Manual, 01/2013,
Bus parameter Adjustable? Limit values
Ttr typical No This time is provided for information only and is not transferred to the
nodes.
Response monitoring 10 ms <= response monitoring (watchdog) <= 650 s
If you want to create a customized bus profile, we recommend the following settings:
Minimum target rotation time (Ttr) = 5000 x HSA (highest PROFIBUS address)
Minimum response monitoring (watchdog) = 6250 x HSA
Recalculating
You can use the "Recalculate" button to recalculate the parameters.
See also
PROFIBUS addresses (Page 389)
Description of the bus parameters (Page 391)
Description of the bus parameters
Detailed description of PROFIBUS bus parameters
Bus parameter Meaning
Tslot_Init The wait-for-reception (slot time) defines the maximum time the sender will wait
to receive a response from the addressed partner. If the influence of the line
components on message frame run times is entered in the "Cable Configuration"
parameter group, these components must also be taken into account. The
component is added to the specified Tslot_Init and the total used as Tslot.
Max. Tsdr The maximum protocol processing time defines the latest time by which the
responding node should have replied.
Min. Tsdr The minimum protocol processing time defines the earliest time by which the
responding node may reply.
Tset The trigger time is the time which may lapse between the reception of a data
message frame and the response to it in the node.
Tqui The modulator quiet time is the time which a sending node needs after the end
of the message frame to switch from sending to receiving.
GAP factor The GAP update factor defines the number of token rotations after which a newly
added, active node can be added to the logical token ring.
Retry limit This parameter defines the maximum number of attempts (message frame
repeats) made to reach a node.
Tslot The wait-for-reception time (slot time) defines the maximum time the sender will
wait to receive a response from the addressed partner.
If the influence of the bus design components on message frame run times is
entered in the "Cable Configuration" parameter group, these components must
also be taken into account. The component is added to the specified Tslot_Init
and the total used as Tslot.
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V12.0
System Manual, 01/2013, 391
Bus parameter Meaning
Tid2 Idle time 2 defines the earliest time by which a sending node may send the next
message frame after sending a message frame that has not been acknowledged.
Trdy The ready time specifies the earliest time by which a sending node may receive
a response message frame.
Tid1 Idle time 1 defines the earliest time by which a sending node may send the next
message frame after receiving a response.
Ttr The target rotation time is the maximum time made available for a token rotation.
During this time, all active nodes (DP masters etc.) have the right to send (token)
once. The difference between the target rotation time and the actual token holding
time of a node determines how much time is left over for the other active nodes
(programming device, other DP masters etc.) to send message frames.
Ttr typical The typical data cycle time is the average response time on the bus if all
configured slaves are exchanging data with the DP master. None of the slaves
report diagnostics and there is no extra message frame traffic with programming
devices or other active nodes etc. on the bus.
Response monitoring The response monitoring time is only needed for PROFIBUS-DP bus systems. It
defines the latest time by which a DP slave has to be addressed by its DP master
with a new data message frame. If this does not happen, the DP slave assumes
that the DP master has failed and resets its outputs to a secure mode.
See also
What you need to know about PROFIBUS bus parameters (Page 390)
Bus profiles with PROFIBUS
Introduction
Depending on the device types connected and protocols used on the PROFIBUS, different
profiles are available. The profiles differ in terms of the setting options and calculation of bus
parameters. The profiles are explained below.
Devices with different profiles on the same PROFIBUS subnet
The PROFIBUS subnet only functions without problem if the bus parameters of all devices
have the same values. For example, if both DP and FMS services are being used on a subnet,
the "slower" sets of bus parameters must always be set for all devices, i.e. even the "Universal
(DP/FMS)" profile for DP devices.
Profiles and transmission rates
Profiles Supported transmission speeds in Kbits/s
DP 9.6 19.2 45.45 93.75 187.5 500 1500 3000 6000 12000
Standard 9.6 19.2 45.45 93.75 187.5 500 1500 3000 6000 12000
Universal (DP-FMS) 9.6 19.2 93.75 187.5 500 1500
Customized 9.6 19.2 45.45 93.75 187.5 500 1500 3000 6000 12000
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V12.0
392 System Manual, 01/2013,
Meaning of profiles
Profile Meaning
DP Select the "DP" bus profile when the only devices connected to the PROFIBUS
subnet are those which satisfy the requirements of standard EN 50170 Volume
2/3, Part 8-2 PROFIBUS. The bus parameter setting is optimized on these
devices.
This includes devices with DP master and DP slave interfaces of the SIMATIC
S7 and distributed I/Os of other manufacturers.
Standard Compared to the "DP" profile, the "Standard" profile also offers scope for
devices of another project or devices which have not been configured here to
be taken into account when calculating the bus parameters. The bus
parameters are then calculated following a simple, non-optimized algorithm.
Universal (DP/FMS) Select the "Universal (DP/FMS)" bus profile when individual devices on the
PROFIBUS subnet use the PROFIBUS-FMS service.
This includes the following devices for example:
CP 343-5 (SIMATIC S7)
PROFIBUS-FMS devices of other manufacturers
As with the "Standard" profile, this profile allows you to take other devices into
account when calculating the bus parameters.
Customized The PROFIBUS subnet will only function without problem if the parameters for
the bus profile are matched to one another. Select the "Customized" profile
when none of the usual profiles "match" a PROFIBUS device and you need to
adapt the bus parameters to your special structure. Information on this can be
found in the documentation for the PROFIBUS device.
You should only change the default values if you are familiar with how to
configure the bus profile for PROFIBUS.
Not all combinations that can be theoretically set can be used even with this
bus profile. The PROFIBUS standard specifies several parameter limits that
depend on other parameters. For example, a responder must not respond (Min
Tsdr) before the initiator can receive the message frame (Trdy). These standard
specifications are also checked in the "Customized" profile.
Tip: The bus parameters last valid on the PROFIBUS subnet are always
automatically set as customized. For example, if the "DP" bus profile was valid
for the subnet, then the bus parameters for "DP" are set in the "Customized"
bus profile. The parameters can be modified on this basis.
The monitoring times are not automatically recalculated so that you do not put
at risk the consistency of set values, for example with configurations in other
configuration tools without realizing that you have done so.
You can also have the Ttr monitoring times and target rotation time calculated
on the basis of parameters you have set: Click here on the "Recalculate" button.
Note
Both mono-master mode and multi-master mode are possible with all PROFIBUS profiles.
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V12.0
System Manual, 01/2013, 393
What you need to know about PROFIBUS line configuration
Cable configuration and bus parameters
Information regarding the cable configuration can be taken into consideration when calculating
the bus parameters. For this purpose, you must select the "Consider cable configuration" check
box in the properties for the PROFIBUS subnet.
The remaining information then depends on the type of cable used; the following settings are
available:
Copper cable
Fiber-optic cable/optical ring
PROFIBUS line configuration, optical ring
The calculation depends on the OLM types used. The selection is made by activating the check
box (multiple activation is possible, at least one OLM type must be selected):
OLM/P12
OLM/G12
OLM/G12-EEC
OLM/G12-1300
The following bus parameter adjustments are made:
Configuration of a node not present
Note
The following restrictions apply to optical rings, even for passive nodes (DP slaves for
example):
A maximum of HSA-1 nodes may be connected to the PROFIBUS network. With an HSA
of 126, addresses 126 and 125 must not be used. A maximum of 125 nodes are possible
on the bus (No. 0 to 124).
If an HSA is less than or equal to 125, the addresses HSA and greater may not be used.
The address HSA-1 may not be used.
Increase the retry value to 3
Setting of minimum slot time needed for ring mode
Note
Short slot time values are needed for OLM/P12, average ones for OLM/G12 and OLM/
G12-EEC and long ones for OLM/G12-1300. This results in high performance for small
network lengths and average to low performance for average to large network lengths.
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V12.0
394 System Manual, 01/2013,
PROFIBUS communication load
Communication load - allowing for additional network stations
The bus parameters depend on the volume of communication between the active network
nodes. There are differences between cyclic communication (DP) and connection-based,
acyclic communication (S7 communication, Send/Receive (FDL), FMS). Unlike DP, the volume
and size of communication tasks (communication load) depends on the user program. For this
reason, the communication load cannot always be calculated automatically.
To calculate the bus times you can define a network configuration in the "Additional network
stations" parameter group that differs from the network configuration.
Taking the profile into account
The network configuration can be defined for the "Standard", "Universal (DP/FMS)", and "User-
defined" profiles. Parameters cannot be entered in the "Additional network stations" parameter
group for the "DP" profile.
Quantification of the communication load
The following settings are available in order to make allowance for the communication load.
Information regarding the number of unconfigured network stations;
Information on the communication load resulting from the user programs for FDL or S7
communication. Here you can selected from the following settings:
Low
Typically used for DP, no great data communication apart from DP.
Medium
Typically used for mixed operations featuring DP and other communication services
(such as for S7 communication), when DP has strict time requirements and for average
acyclic volumes of communication.
High
For mixed operations featuring DP and other communication services (such as for S7
communication), when DP has loose time requirements and for high acyclic volumes of
communication.
Configuring Industrial Ethernet
Rules for the network configuration
The Ethernet interfaces of the devices have a default IP address that you can change.
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V12.0
System Manual, 01/2013, 395
IP address
The IP parameters are visible if the module capable of communication supports the TCP/IP
protocol. This is usually the case for all Ethernet modules.
The IP address consists of 4 decimal figures in the range of 0 to 255. The decimal figures are
separated from one another by a dot.
Example: 140.80.0.2
The IP address consists of:
Address of the (sub) net
Address of the node (generally also called host or network node)
Subnet mask
The subnet mask splits these two addresses. It determines which part of the IP address
addresses the network and which part of the IP address addresses the node.
The set bits of the subnet mask determine the network part of the IP address.
Example:
Subnet mask: 255.255.0.0 = 11111111.11111111.00000000.00000000
In the example given for the above IP address, the subnet mask shown here has the following
meaning:
The first 2 bytes of the IP address identify the subnet - i.e. 140.80. The last two bytes address
the node, thus 0.2.
It is generally true that:
The network address results from AND linking the IP address and subnet mask.
The device address results from AND NOT linking the IP address and subnet mask.
Relation between IP address and default subnet mask
An agreement exists relating to the assignment of IP address ranges and so-called "Default
subnet masks". The first decimal number (from the left) in the IP address determines the
structure of the default subnet mask. It determines the number of "1" values (binary) as follows:
IP address (decimal) IP address (binary) Address class Default subnet mask
0 to 126 0xxxxxxx.xxxxxxxx.... A 255.0.0.0
128 to 191 10xxxxxx.xxxxxxxx... B 255.255.0.0
192 to 223 110xxxxx.xxxxxxxx... C 255.255.255.0
Note
Range of values for the first decimal point
A value of between 224 and 255 is also possible for the first decimal number of the IP address
(address class D etc). This is, however, not recommended because there is no address check
for these values.
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V12.0
396 System Manual, 01/2013,
Masking other subnets
You can use the subnet mask to add further structures and form "private" subnets for a subnet
that is assigned one of the address classes A, B or C. This is done by setting other lower points
of the subnet mask to "1". For each bit set to "1", the number of "private" networks doubles
and the number of nodes they contain is halved. Externally, the network functions like an
individual network as it did previously.
Example:
You have a subnet of address class B (for example IP address 129.80.xxx.xxx) and change
the default subnet mask as follows:
Masks Decimal Binary
Default subnet mask 255.255.0.0 11111111.11111111.00000000.
00000000
Subnet mask 255.255.128.0 11111111.11111111.10000000.
00000000
Result:
All nodes with addresses between 129.80.001.xxx and 129.80.127.xxx are on one subnet, all
nodes with addresses between 129.80.128.xxx and 129.80.255.xxx are on another subnet.
Router
The task of the routers is to connect the subnets. If an IP datagram is to be sent to another
network, it first has to be conveyed to a router. To make this possible, you have to enter the
address of the router for each node in the subnet.
The IP address of a node in the subnet and the address of the router may only differ at the
points at which there is a "0" in the subnet mask.
Network configuration of AS interface
AS-Interface consists of an AS-i master and AS-i slaves connected to each other over an AS-
i subnet.
Rules for AS interface network configuration
All the nodes in an AS-i subnet must have a different AS-i node address.
You should only load the settings over the network when all the modules in a subnet have
different addresses and when the actual structure matches that of the network configuration
you have created.
One AS-i master and up to 31 AS-i slaves can be operated on one AS-i subnet.
For more information on configuring an AS-Interface with an AS-i master and AS-i slaves, refer
to the section on AS-Interface and the documentation of the AS-i master modules.
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V12.0
System Manual, 01/2013, 397
8.1.3.2 Communication via connections
Working with connections
S7 connection
Introduction to configuring connections
Definition
A connection defines a logical assignment of two communication partners in order to undertake
communication services. A connection defines the following:
Communication partner involved
Type of connection (for example, S7 connection)
Special properties (e.g., whether a connection is established permanently or whether it is
established and terminated dynamically in the user program, and whether status messages
are to be sent)
Connection path
What you need to know about connection configuration
During connection configuration, a local connection name is assigned for an S7 connection as
a unique local identification.
In the network view, a "Connections" tab is displayed in addition to the "Network overview"
tab. This tab contains the connection table. A row in this connection table represents a
configured connection from the viewpoint of the local communication partner with its properties,
for example, between two S7-1200 CPUs.
What you need to know about using connection resources
Introduction
Each connection requires connection resources for the end point and/or transition point on the
devices involved. The number of connection resources is device-specific.
If all the connection resources of a communication partner are assigned, no new connections
can be established. This situation is apparent when a newly created connection in the
connection table has a red background. The configuration is then inconsistent and cannot be
compiled.
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V12.0
398 System Manual, 01/2013,
S7 connections
In the case of S7 connections via the PN interface, one connection resource per S7 connection
is assigned for the endpoint for the S7-1200 CPU. One connection resource is also required
for the connection partner.
You can find an overview of available and assigned connection resources for selected S7-1200
CPU in the Inspector window at "Properties > Connection Resources"
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V12.0
System Manual, 01/2013, 399
Views containing information about the configured connections
The views described below will provide you with comprehensive access to all the information
and functions regarding configuring and checking communication connections.
Connection display in the network view
Connection table
"Properties" tab for a connection in the inspector window
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V12.0
400 System Manual, 01/2013,
Benefits
The information shown in these views are always up-to-date in terms of the current user
actions. This means:
The connection table displays all connections created.
If you have selected a connection in the connection table:
When connection mode is enabled, the connection path is highlighted in the network
view.
The "Properties" tab in the Inspector window displays the parameters of this connection.
The connection table
The connection table offers the following functions:
List of all connections in the project
Selection of a connection and display of connections associated with it in the network view
(when connection mode is enabled)
Changing of connection partners
Display showing status information
"Properties" tab for a connection in the inspector window
The properties dialog has the following meaning:
Display for connection parameters
Display of connection path
Subsequent specification of connections using the "Find connection path" button
Creating a new connection
Creating a connection - alternatives
You have the following options for creating a connection in the network view:
Graphic connection configuration
Interactive connection configuration
You'll find the individual steps for this in the following chapters.
Requirement and result
In the network view, you have add devices between which the connections should be
configured.
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V12.0
System Manual, 01/2013, 401
Specifying a connection
If both partners for the connection type selected are networked on the same network, use the
graphic or interactive selection of both communication partners to create a fully specified
connection.
This connection is entered automatically in the connection table of the S7-1200 CPU. A local
connection name is assigned for this connection.
The following schematic shows a configured connection with a networked device:
Creating a new connection graphically
Graphically configuring connections
In the case of graphic connection configuration, the connection path is automatically specified
provided interfaces and resources are available. Select the devices to be connected in the
current configuration.
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V12.0
402 System Manual, 01/2013,
Automatically determining connection path
To create a connection graphically, follow these steps:
1. Click the "Connections" button.
This step activates the connection mode: You can now select the connection type you want.
You will see this from the following:
The devices that can be used for the connection type selected in your project are color-
highlighted in the network view.
2. Hold down the mouse button and drag the mouse pointer from the device from which the
connection will originate to the device at which the connection ends.
3. Release the mouse button over the destination device to create the connection between
the two devices.
Result
A specified connection is created.
The connection path is highlighted.
The connection is entered in the connection table.
Configuring a connection when there is no or no clear network assignment
Any networking not in place will if possible be created automatically when a connection is
created. A query will be made upon completion of connection configuration if unique network
assignment is not possible. You will be able to choose from the existing subnets.
Example below: A query is made upon creation of a connection between stations PLC_1 and
PLC_2, which are not yet networked.
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V12.0
System Manual, 01/2013, 403
Interactively creating a new connection
Interactively configuring connections
Define the local device and its connection partners.
Procedure
Proceed as follows to interactively create a connection:
1. Select the "Add new connection" command in the shortcut menu of a connection partner
for which you want to create a connection.
The "Create new connection" dialog appears.
2. Select the partner endpoint.
In the right pane of the dialog, a possible connection path fitting the selected endpoint is
displayed, if available. Incomplete paths, for example, for a non-specified CPU, are marked
by an exclamation mark on a red background.
3. To accept the configured connection and to configure additional connections to other
endpoints, click "Add".
To close the dialog, click "OK".
Working in the network view
Highlighting connection path and partner in the network view
To display the connection partners for all or certain connection types in the network view,
proceed as follows:
1. Click the "Connections" button.
2. Select the S7-CPU for which you want to display the connection partners in the network
view and then select the "Highlight connection partners" command in the shortcut menu.
3. Select "All connection partners" in the following menu.
The local device and the CPUs of the target devices are selected. The local connection
partner shows an arrow pointing right and the remote connection partners show an arrow
pointing left.
4. To open a list with information on the target devices, click the arrow of the local device.
This additional function is useful in complex network configurations in which some devices
are not visible.
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V12.0
404 System Manual, 01/2013,
Note
You can display one of the connection partners which cannot be seen in the current display
range of the network view. Click on the communication partner in the list that appears. Result:
The display is moved such that the connection partner becomes visible.
Working with the connection table
Basic functions for tables
The connection table supports the following basic functions for editing a table:
Changing column width
Displaying the meaning of a column, a row or cell using tooltips.
Changing column width
To adjust the width of a column to the content so that all texts in the lines are legible, follow
these steps:
1. Position the cursor in the header of the connection table to the right of the column that you
want to optimize until the cursor changes its shape to two parallel lines (as if you wanted
to change the width of the column by dragging it with the cursor).
2. Double click on this point.
or
1. Open the shortcut menu on the header of the table.
2. Click on
"Optimize column width" or
"Optimize width of all columns".
For columns that are too narrow, the complete content of specific fields is shown when you
pause with the cursor on the respective field.
Show / hide columns
You can use the shortcut menu of the header of the connection table to control the display of
the various table columns. The shortcut menu entry "Show/hide columns" provides you with
an overview of the available columns. Use the check box to control whether columns are shown
or hidden.
If you want to store the layout, width and visibility of the table columns, click on the "Remember
layout" function in the top right-hand of the network view.
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V12.0
System Manual, 01/2013, 405
Symbol Meaning
Remember layout
Saves the current table view. The layout, width and visibility of columns in the table view is
stored.
Using cursor keys to move within the connection table
You can use the UP and DOWN cursor keys to select a connection from the connection table;
the selected connection is marked and is shown highlighted in the network view.
Changing properties of connection
You can directly edit some of the parameters displayed in the connection table. The name of
the connection can, for example, only be changed in the connection table.
Changing connection partners
You can change the connection partner of a connection as follows:
1. Select the connection.
2. Select the new connection partner from the open drop-down list in the "Partner" column.
Deleting connections
You can delete configured connections using the network view or the connection table.
In the network view you can delete one highlighted connection per action. In the connection
table you can delete one or several connections per action.
Procedure
To delete a connection, follow these steps:
1. Select the connection to be deleted:
In the network view: Select the connection to be deleted.
In the connection table: Select the rows of the connections to be deleted (multiple
selection possible).
2. Open the shortcut menu with a right mouse click.
3. Select the "Delete" command.
Result
The selected connection is removed completely.
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V12.0
406 System Manual, 01/2013,
Copying connections
Introduction
Connections are not copied singly but always in context along with the project or the device.
You can copy:
Entire projects
One or more devices within a project or from one project to another
Copying a project
When you copy a project all configured connections will also be copied. No settings whatsoever
are required for the copied connections because the connections remain consistent.
Copying devices
If you copy devices for which connections have been configured, the connections are copied
as well. To complete the connection path, you must still finalize the networking.
An S7-1200 CPU with a V.10 firmware is merely a server for connections and has no
connection configuration itself. Consequently, no connections are copied along with it when
an S7-1200 CPU with a V1.0 firmware is copied.
Inconsistent connections - connections without assignment
With an inconsistent connection the structure of the connection data is destroyed or the
connection is not functional in the project context.
Inconsistent connections cannot be compiled and loaded - operation is not possible with such
a connection.
In the connection table inconsistent connections are marked in red.
Possible causes for inconsistent connections
Deletion or change of the hardware configuration.
Missing interface network links in the project, which are necessary for a connection.
Connection resources are exceeded
Connections to an unspecified connection partner without partner address information.
Detailed information regarding the reasons for the inconsistency can be found in the "Compile"
tab following compilation (Edit > Compile).
Remedies
To assign a closed connection path to an existing open connection path, expand the device
configuration in such a way that the interfaces required for the connection type are available
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V12.0
System Manual, 01/2013, 407
for both partners. At "Properties > General > Interface" in the Inspector window, you can use
the "Find connection path" button to create a connection to an existing partner.
S7 connection - general settings
General connection parameters
General connection parameters are displayed in the "General" parameter group under the
properties of the connection; these connection parameters identify the local connection end
point.
Here, you can assign the connection path and specify all aspects of the connection partner.
Local ID
The local ID of the module from which the connection is viewed is displayed here (local partner).
You can change the local ID. You may need to do this if you have already programmed
communication function blocks, and you want to use the local ID specified in those function
blocks for the connection.
Special connection properties
Display of connection properties (can be modified depending on the components used):
One-way
One-way means that the connection partner functions as a server on this connection and
cannot send or receive actively.
Active connection establishment
In the case of one-way connection, for example with a S7-1200 CPU (firmware version
V1.0), a connection partner can only be provided for the active connection establishment.
In the case of a two-way connection you can set which connection partner will assume the
active role.
Sending operating mode messages
Indicates whether or not the local partner sends operating mode messages to the
connection partner.
Address details
Displaying address details of the S7 connection. With an unspecified partner, the values for
the rack and slot can be changed. All other values are obtained from the current configuration
and cannot be changed.
S7 connection - address details
Meaning
The address details show the end points of the connection and can localize these via the
specification of rack and slot.
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V12.0
408 System Manual, 01/2013,
When a connection is established, the connection-specific resources of a module are assigned
specifically to this connection. This assignment requires that the connection resource can be
addressed. The TSAP (Transport Service Access Point) is, as it were, the address of the
resource that is formed with the help of the connection resource or, in the case of S7-1200
CPUs (firmware V2.0 or higher) with the SIMATIC-ACC (SIMATIC Application Controlled
Communication).
Configuration of TSAP for S7-1200
For S7-1200 CPU (firmare V2.0 or higher):
"SIMATIC-ACC"<nnn><mm>
nnn = Local ID
mm = any value
For S7-1200 CPU (firmare V1.0):
<xx>.<yz>
xx = Number of the connection resource
y = Rack number
z = Slot number
TSAP structure, dependent on partner
The configuration of the TSAP for S7-1200 CPUs is dependent on the respective firmware and
on the remote connection partner. When a S7-1200 CPU is connected with a S7-300/400 CPU,
a S7-1200 CPU also uses a TSAP configuration that includes the connection resource.
See the following examples for TSAPs of various connection configurations
Connection between two S7-1200 CPUs (both with firmware V2.0):
S7-1200 CPU "A" with firmware V2.0 and local ID 100:
TSAP: SIMATIC-ACC10001
S7-1200 CPU "B" with firmware V2.0 and local ID 5AE:
TSAP: SIMATIC-ACC5AE01
Connection between two S7-1200 CPUs (firmware V2.0 and V1.0):
S7-1200 CPU with firmware V2.0 and local ID 1FF:
TSAP: SIMATIC-ACC1FF01
S7-1200 CPU with firmware V1.0 (rack 0, slot 1, connection resource 03):
TSAP: 03.01
Connection between S7-1200 CPUs (firmware V2.0) and S7-300/400 CPU:
S7-1200 CPU with firmware V2.0 (rack 0, slot 1, connection resource 12):
TSAP: 12.01
S7-300/400 CPU (rack 0, slot 2, connection resource 11):
TSAP: 11.02
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V12.0
System Manual, 01/2013, 409
HMI connection
Introduction to configuring connections
Definition
A connection defines a logical assignment of two communication partners in order to undertake
communication services. A connection defines the following:
Communication partner involved
Type of connection (e.g., HMI connection)
Special properties (e.g., whether a connection is established permanently or whether it is
established and terminated dynamically in the user program, and whether status messages
are to be sent)
Connection path
What you need to know about connection configuration
During connection configuration, a local connection name is assigned for an HMI connection
as a unique local identification.
In the network view, a "Connections" tab is displayed in addition to the "Network overview"
tab. This tab contains the connection table. A line in this connection table represents a
configured connection, e.g., between an HMI device and PLC, along with its properties.
What you need to know about using connection resources
Introduction
Each connection requires connection resources for the end point and/or transition point on the
devices involved. The number of connection resources is device-specific.
If all the connection resources of a communication partner are assigned, no new connections
can be established. This situation is apparent when a newly created connection in the
connection table has a red background. The configuration is then inconsistent and cannot be
compiled.
HMI connections
For HMI connections via the integrated PN interface, one connection resource for the endpoint
per HMI connection is occupied for the HMI device.
One connection resource is also required for the connection partner (PLC).
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V12.0
410 System Manual, 01/2013,
Views containing information about the configured connections
The views described below will provide you with comprehensive access to all the information
and functions regarding configuring and checking communication connections.
Connection display in the network view
Connection table
"Properties" tab for a connection in the inspector window
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V12.0
System Manual, 01/2013, 411
Benefits
The information shown in these views are always up-to-date in terms of the current user
actions. This means:
The connection table displays all connections created.
If you have selected a connection in the connection table:
You will graphically see the connection path in the network view.
The "Properties" tab in the Inspector window displays the parameters of this connection.
The connection table
The connection table offers the following functions:
List of all connections in the project
Selection of a connection and display of connections associated with it in the network view
Changing of connection partners
Display showing status information
"Properties" tab for a connection in the inspector window
The properties dialog has the following meaning:
Display for connection parameters
Display of connection path
Subsequent specification of connections using the "Find connection path" button
Creating a new connection
Creating a connection - alternatives
You have the following options for creating a connection in the network view:
Graphic connection configuration
Interactive connection configuration
You'll find the individual steps for this in the following chapters.
Requirement and result
You have created the devices with CPUs and HMI devices between which you want to
configure connections in the network view.
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V12.0
412 System Manual, 01/2013,
Specifying a connection
If both partners for the connection type selected are networked on the same network, use the
graphic or interactive selection of both communication partners to create a fully specified
connection.
This connection is entered automatically into the connection table of the HMI device. A local
connection name is assigned for this connection.
The following schematic shows a configured connection with a networked device:
Creating a new connection graphically
Graphically configuring connections
When using the graphic connection configuration, if necessary the system asks you to define
the connection path. Select the devices to be connected in the current configuration.
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V12.0
System Manual, 01/2013, 413
Automatically determining connection path
To create a connection graphically, follow these steps:
1. Click the "Connections" button.
The connection mode for the connection type you have selected is then activated.
You will see this from the following:
The devices that can be used for the connection type selected in your project are color-
highlighted in the network view.
2. Hold down the mouse button and drag the mouse pointer from the device from which the
connection will originate to the device at which the connection ends.
3. Release the mouse button over the destination device to create the connection between
the two devices.
Result
A specified connection is created.
The connection path is highlighted.
The connection is entered in the connection table.
Interactively creating a new connection
Interactively configuring connections
Define the local device and its connection partners.
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V12.0
414 System Manual, 01/2013,
Procedure
Proceed as follows to interactively create a connection:
1. Select the "Create new connection" command in the shortcut menu of a connection partner
for which you want to create a connection.
The "Create new connection" dialog is opened.
2. Select the partner endpoint.
In the right pane of the dialog, a possible connection path fitting the selected endpoint is
displayed, if available. Incomplete paths, for example, for a non-specified CPU, are marked
by an exclamation mark on a red background.
3. To close the dialog, click "OK".
To accept the configured connection and to configure additional connections to other
endpoints, click "Apply".
Working in the network view
Highlighting connection path and partner in the network view
To display the connection partners for all or certain connection types in the network view,
proceed as follows:
1. Click the "Connections" button.
2. Select the "Highlight connection partners" command in the shortcut menu for the HMI device
whose connection partners you want to display in the network view.
3. Select "All connection partners" in the following menu.
The local device and the CPUs of the target devices are selected. The local connection
partner shows an arrow pointing right and the remote connection partners show an arrow
pointing left.
4. To open a list with information on the target devices, click the arrow of the local device.
This additional function is useful in complex network configurations in which some devices
are not visible.
Note
You can display one of the connection partners which cannot be seen in the current display
range of the network view. Click on the communication partner in the list that appears. Result:
The display is moved such that the connection partner becomes visible.
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V12.0
System Manual, 01/2013, 415
See also
Creating a new connection graphically (Page 413)
Working with the connection table
Basic functions for tables
The connection table supports the following basic functions for editing a table:
Changing column width
Displaying the meaning of a column, a row or cell using tooltips.
Changing column width
To adjust the width of a column to the content so that all texts in the lines are legible, follow
these steps:
1. Position the cursor in the header of the connection table to the right of the column that you
want to optimize until the cursor changes its shape to two parallel lines (as if you wanted
to change the width of the column by dragging it with the cursor).
2. Double click on this point.
or
1. Open the shortcut menu on the header of the table.
2. Click on
"Optimize column width" or
"Optimize width of all columns".
For columns that are too narrow, the complete content of specific fields is shown when you
pause with the cursor on the respective field.
Show / hide columns
You can use the shortcut menu of the header of the connection table to control the display of
the various table columns. The shortcut menu entry "Show/hide columns" provides you with
an overview of the available columns. Use the check box to control whether columns are shown
or hidden.
Using cursor keys to move within the connection table
You can use the UP and DOWN cursor keys to select a connection from the connection table;
the selected connection is marked and is shown highlighted in the network view.
Changing properties of connection
You can directly edit the parameters displayed in the connection table in some cases. To
change the name of a connection, you do not have to navigate to the Inspector window.
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V12.0
416 System Manual, 01/2013,
Changing connection partners
You can change the connection partner of a connection as follows:
1. Select the connection.
2. Select the new connection partner from the open drop-down list in the "Partner" column.
Deleting connections
You can delete configured connections using the network view or the connection table.
In the network view you can delete one highlighted connection per action. In the connection
table you can delete one or several connections per action.
Procedure
To delete a connection, follow these steps:
1. Select the connection to be deleted:
In the network view: Select the connection to be deleted.
In the connection table: Select the rows of the connections to be deleted (multiple
selection possible).
2. Open the shortcut menu with a right mouse click.
3. Select the "Delete" command.
Result
The selected connection is removed completely.
Copying connections
Introduction
Connections are not copied singly but always in context along with the project or the device.
You can copy:
Entire projects
One or more devices within a project or from one project to another
Copying a project
When you copy a project all configured connections will also be copied. No settings whatsoever
are required for the copied connections because the connections remain consistent.
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V12.0
System Manual, 01/2013, 417
Copying devices
If you copy devices for which connections have been configured (HMI devices), the
connections are copied as well. To complete the connection path, you must still finalize the
networking.
An S7-1200 CPU with a V.10 firmware is only a server for connections and has no connection
configuration itself. Consequently, no connections are copied along with it when an S7-1200
CPU with a V1.0 firmware is copied.
Inconsistent connections - connections without assignment
With an inconsistent connection the structure of the connection data is destroyed or the
connection is not functional in the project context.
Inconsistent connections cannot be compiled and loaded - operation is not possible with such
a connection.
In the connection table inconsistent connections are marked in red.
Possible causes for inconsistent connections
Deletion or change of the hardware configuration.
Missing interface network links in the project, which are necessary for a connection.
Connection resources are exceeded
Errors when backing up data due to insufficient memory
Connections to an unspecified connection partner without partner address information.
Detailed information regarding the reasons for the inconsistency can be found in the "Compile"
tab following compilation (Edit > Compile).
Remedies
If the connection cannot be repaired by opening the connection properties, changing them or
undoing them in the configuration, then it may be necessary to delete the connection and re-
create it.
HMI connection general settings
General connection parameters
General connection parameters are displayed in the "General" parameter group under the
properties of the connection; these connection parameters identify the local connection end
point.
Here, you can also assign the connection path and specify all aspects of the connection
partner.
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V12.0
418 System Manual, 01/2013,
Special connection properties
Display of the connection properties (cannot be changed):
Active connection establishment
The connection establishment always starts from the HMI device. This option is selected
by default if the address of the partner is specified.
One-way
One-way means that the connection partner functions as a server on this connection and
cannot send or receive actively.
Sending operating mode messages
Not relevant for HMI devices.
Address details
Displaying address details of the HMI connection. With an unspecified partner, the values for
the rack and slot can be changed. All other values are obtained from the current configuration
and cannot be changed.
Miscellaneous
Display of the access points for the online connection between HMI device and connection
partner.
Using Open User Communication
Basics of Open User Communication
Introduction
Open User Communication is the name given to a program-controlled communication process
for communicating via the integrated PN/IE interface of the S7-1200/1500 and S7-300/400
CPUs. Different connection types are available for this communication process.
The main feature of Open User Communication is its high degree of flexibility in terms of the
data structures transferred. This allows open data exchange with any communicating devices
providing they support the connection types available here. Since this communication is
controlled solely by instructions in the user program, event-driven connection establishment
and termination is possible. Connections can also be modified by the user program during
runtime.
For CPUs with an integrated PN/IE interface, the TCP, UDP, and ISO-on-TCP connection
types are available for Open User Communication. The communication partners can be two
SIMATIC PLCs or a SIMATIC PLC and a suitable third-party device.
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V12.0
System Manual, 01/2013, 419
Instructions for Open User Communication
To create the connections, you have various instructions available after opening in the program
editor in the "Instructions > Communication > Open User Communication" task card:
Compact instructions for sending or receiving data via the integrated functions for
establishing and terminating the connection (S7-1200/1500 only):
TSEND_C (connection establishment/termination, sending)
TRCV_C (connection establishment/termination, receiving)
Individual instructions for sending and receiving data or for establishing or terminating
connections:
TCON (connection establishment)
TDISCON (connection termination)
TSEND (TCP or ISO-on-TCP: Sending)
TRCV (TCP or ISO-on-TCP: Receiving)
TUSEND (UDP: Sending)
TURCV (UDP: Receiving)
Connection establishment
For Open User Communication, instructions for establishing and terminating the connection
must exist for both communication partners. One communication partner sends its data using
TSEND, TUSEND or TSEND_C while the other communication partner receives the data using
TRCV, TURCV or TRCV_C.
One of the communication partners starts the connection establishment as the active partner.
The other communication partner reacts by starting its connection establishment as the
passive partner. If both communication partners have initiated their connection establishment,
the communication connection is fully established.
Connection configuration
You can specify establishment of the connection via a connection description DB with the
TCON_Param, TCON_IP_v4, or TCON_IP_RFC structure by means of parameter assignment
as follows:
Manually create, assign parameters and write directly to the instruction.
Supported by connection configuration.
Connection configuration supports the establishment of the connection and should, therefore,
be given preference over the other methods.
You specify the following in the connection configuration:
Connection partner
Connection type
Connection ID
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V12.0
420 System Manual, 01/2013,
Connection description DB
Address details according to selected connection type
In addition, you specify here which communication partner activates the connection
establishment and which partner establishes a connection passively in response to a request
from its communication partner.
See also
Principle of operation of connection-oriented protocols (Page 433)
Connection configuration
Overview of connection configuration
Introduction
You can find the connection configuration in the Inspector window of the program editor if you
want to program Open User Communication with the communication instructions TSEND_C,
TRCV_C or TCON.
Connection configuration supports the flexible functionality of communication programming:
The parameters entered for the connection configuration are stored in an automatically
generated global DB derived from the TCON_Param, TCON_IP_v4 or TCON_IP_RFC
structure. You can modify the connection parameters in this connection description DB.
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V12.0
System Manual, 01/2013, 421
Structure of the connection configuration
The connection configuration is made up of the following components:
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V12.0
422 System Manual, 01/2013,
Toolbar
Block interface
"Favorites" pane in the "Instructions" task card and favorites in the program editor
Programming window
"Instructions" task card
"Testing" task card
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
System Manual, 01/2013, 1035
Toolbar
The toolbar allows you to access the principal functions of the program editor, such as:
Show and hide absolute operands
Showing and hiding favorites
Skip to syntax errors
Update block calls
Show and hide program status
The functions available in the toolbar can vary depending on the programming language used.
Block interface
The block interface contains the declarations for local tags used solely within the block. The
sections available depend on the block type.
Favorites
You can save frequently used instructions as favorites. These favorites are then displayed in
the "Instructions" task card and the "Favorites" pane. You can also display favorites in the
program editor using the program editor toolbar. This allows you to access your favorites even
when the "Instructions" task card is not visible.
Programming window
The programming window is the work area of the program editor. You can enter the program
code in this window. The appearance and functionality of the program window can vary
depending on the programming language used.
"Instructions" task card
The "Instructions" task card offers you easy access to all instructions available for creating
your program. The instructions are broken down by area into a number of different palettes.
You can show additional information on the instructions via the "Show column headers and
additional columns" button in the task card toolbar. You can modify the arrangement of columns
by clicking a column header and moving the column to the new position by means of drag-and-
drop.
If an instruction profile is active, the offered instructions may vary.
See also: Using instruction profiles
"Testing" task card
You can set settings in the "Testing" task card for troubleshooting using the program status.
The functions of the "Testing" task card are only available in online mode. It contains the
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
1036 System Manual, 01/2013,
following panes, which are displayed depending on the selected CPU and the configured
programming language of the block:
CPU operator panel
The CPU operator panel allows you to switch the CPU operating mode.
Breakpoints
You can test blocks you created in the textual programming languages STL and SCL in
single step mode. To do this, set breakpoints in the program code.
In the "Breakpoints" pane, you can find all breakpoints that you have set and you can
activate, delete, navigate to, or set the call environment for the individual breakpoints.
PLC register
This pane allows you to read off the values for the PLC registers and the accumulators.
Sequence control
In this pane you can set the operating mode for testing sequencers for GRAPH blocks.
Test settings
This pane allows you to specify the test settings for the GRAPH block.
Call environment
This pane allows you to specify the call environment for the block.
Call hierarchy
In this pane, you can trace the call hierarchy of the blocks. You only see the call hierarchy
during block monitoring.
See also
Layout of the block interface (Page 1053)
Enlarging the programming window (Page 1041)
Using the keyboard in the program editor
Navigating in the editor
Function Shortcut key
Open "Instructions" task card <Ctrl+Shift+C>
Open "Testing" task card <Ctrl+Shift+O>
Add new block <Ctrl+N>
Expand all networks <Alt+F11>
Collapse all networks <Alt+F12>
Navigate to the next point of use of the selected block or operand <Ctrl+Shift+F>
Navigate to the previous point of use of the selected block or
operand
<Ctrl+Shift+G>
Navigate to the next read/write access <Alt+F8>
Navigate to the previous read/write access <Alt+F9>
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
System Manual, 01/2013, 1037
Navigating in the program code (LAD/FBD)
Function Selected object Shortcut key
Navigating between objects in the network Object in the network Arrow keys
Navigate to the first element of the network Object in the network <Home>
Navigate to the last element of the network Object in the network <End>
Navigate to the next element of the network Object in the network <Tab>
Navigate to the previous element of the network Object in the network <Shift+Tab>
Insert network Any <Ctrl+R>
Navigating in the program code (STL/SCL)
Function Position of the cursor Shortcut key
Navigating in the program code Line Arrow keys
One word to the right/left Line <Ctrl+arrow keys>
Cursor to start of line Line <Home>
Cursor to end of line Line <End>
Cursor to start of code section Line <Ctrl+Home>
Cursor to end of code section Line <Ctrl+End>
To the next network (STL only) Network title <Down arrow>
To the next network (STL only) Line <Tab>
Repeat the shortcut keys
until the insertion point is
in the next network.
To the previous network (STL only) Network title <Up arrow>
To the previous network (STL only) Line <Shift+Tab>
Repeat the shortcut keys
until the insertion point is
in the previous network.
Insert network Any <Ctrl+R>
Inserting instructions (LAD)
Function Selected object Shortcut key
Insert normally open contact Current path <Shift+F2>
Insert normally closed contact Current path <Shift+F3>
Insert empty box Current path <Shift+F5>
Insert assignment Current path <Shift+F7>
"Insert "Open branch" Current path <Shift+F8>
"Insert "Close branch" Current path <Shift+F9>
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
1038 System Manual, 01/2013,
Inserting instructions (FBD)
Function Selected object Shortcut key
Insert assignment Network, input or
output
<Shift+F7>
Insert empty box Network <Shift+F5>
"Insert "Open branch" Connection line
between two boxes
<Shift+F8>
Invert RLO Network, input or
output
<Ctrl+Shift+4>
Insert input Network, input or
output
<Ctrl+Shift+3>
Enter operands (LAD/FBD)
Function Selected object Shortcut key
Activate the input field for the first operand of the
instruction
Instruction <Return>
Or
<Any letters/numbers>
An empty input field opens
on <Return>, any letters or
numbers will be entered in
the entry field.
Activate input field for the operand Operand <F2>
Delete operand Operand <Del>
Define tag Operand <Ctrl+Shift+I>
Rewire tag Operand <Ctrl+Shift+P>
Rename tag Operand <Ctrl+Shift+T>
Entering operands Input field for
operands
<Any letters/numbers>
Confirm entry of the operand Input field for
operands
<Return>
Open autocompletion
Input field for
operands
<Ctrl+I>
Discard current change Input field for
operands
<Esc>
The input field is
deactivated and the
previous contents restored.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
System Manual, 01/2013, 1039
Process instructions (STL/SCL)
Function Selected object Shortcut key
Indent line (SCL only) Line <Tab> or
<Ctrl+R>
Outdent line (SCL only) Line <Shift+Tab> or
<Ctrl+Shift+R>
Open "Call options" dialog Cursor after block call <Return>
Define tag Operand <Ctrl+Shift+I>
Rewire tag Operand <CtrlShift+P>
Rename tag Operand <Ctrl+Shift+T>
Expand/collapse parameter list (SCL only) Operand <Ctrl+Shift+Space>
Open autocompletion
Any <Ctrl+I> or <Ctrl+Spacebar>
Set/delete bookmarks <Ctrl+Shift+M>
To the next bookmark <Ctrl+Shift+6>
To the previous bookmark <Ctrl+Shift+5>
Disable code Line <Ctrl+Shift+Y>
Enable code Line <Ctrl+Shift+U>
Monitor program
Function Shortcut key
Set/remove breakpoint (STL, SCL) <Ctrl+Shift+F9>
Step over breakpoint (STL, SCL) <Ctrl+Shift+F10>
Jump to lower-level block (STL, SCL) <Ctrl+Shift+F11>
Return to calling block (STL, SCL) <Ctrl+Shift+F12>
Run program up to marker (cursor position) (STL, SCL) <Ctrl+F3>
Display program status (SCL, STL) <Ctrl+T>
Enable all breakpoints (STL, SCL) <Ctrl+Shift+F2>
Disable all breakpoints (STL, SCL) <Ctrl+Shift+F3>
Modify to 0 (LAD, FBD) <Ctrl+Shift+9>
Modify to 1 (LAD, FBD) <Ctrl+Shift+1>
Modify operand (LAD, FBD) <Ctrl+Shift+2>
See also
Keyboard operation in the TIA Portal (Page 193)
Using project-related functions (Page 195)
Arranging windows (Page 195)
Editing tables (Page 201)
Text editing (Page 200)
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
1040 System Manual, 01/2013,
Enlarging the programming window
Introduction
The programming window is relatively small when all components of the application are shown.
If the program code is large, you may find you have to rearrange the work area constantly. To
avoid this problem, you can hide or minimize the display of the following components of the
application and of the program editor:
Project tree
Task cards
Block interface
Favorites
Comments
Networks
Note
You can also use the "Reduce automatically" option for the task cards, project tree, and
Inspector window. These windows will then be minimized automatically when you do not need
them.
See also: Maximizing and minimizing the work area
Hiding and showing the project tree
The project tree allows you to access all areas of the project. You can hide the project tree
while you are creating a program so you have more space for the programming window.
To show and hide the project tree, follow these steps:
1. To hide the project tree, deselect the "Project tree" check box in the "View" menu, or click
on "Collapse" on the project tree title bar.
2. To show the project tree, select the "Project tree" check box in the "View" menu or click on
"Extend" on the project tree title bar.
Opening and closing task cards
The task cards are located at the right-hand edge of the programming window.
To open or close the task cards, follow these steps:
1. To close the task cards, deselect the "Task card" check box in the "View" menu or click
"Collapse" on the task cards title bar.
2. To open the task cards, select the "Task card" check box in the "View" menu or click
"Expand" on the task cards title bar.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
System Manual, 01/2013, 1041
Hiding and showing the block interface
The block interface is shown in the upper section of the program editor. During programming
you can show and hide it as required.
To show and hide the block interface, follow these steps:
1. In the lower part of the interface within the window splitter, click on the Up arrow or Down
arrow.
Showing and hiding favorites
To hide or show the favorites in the program editor, follow these steps:
1. Click the "Display favorites in the editor" button in the program editor toolbar.
Showing and hiding comments
Within a block you can enter a comment for the block or for each network. These two types of
comments are shown and hidden differently.
To show or hide a block comment, follow these steps:
1. Click the the triangle at the start of the line with the block title.
To show or hide network comments, follow these steps:
1. Click "Network comments on/off" on the program editor toolbar.
Note
The comments available can vary depending on the programming language used.
Opening and closing networks
Some programming languages use networks. You can open or close these networks as
required.
To open or close networks, follow these steps:
1. If you want to open a network, click the right arrow in front of the network title. If you want
to close a network, click the down arrow in front of the network title.
To open and close all networks, follow these steps:
1. Click "Open all networks" or "Close all networks" in the program editor toolbar.
Note
Networks are not used in every programming language.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
1042 System Manual, 01/2013,
See also
Overview of the program editor (Page 1034)
Maximizing and minimizing the work area (Page 173)
Setting the mnemonics
You can program blocks using German or international mnemonics. If you open the TIA portal
for the first the international mnemonics is set as default. You can change the mnemonics at
any time.
Procedure
To set the mnemonics, follow these steps:
1. Select the "Settings" command in the "Options" menu.
The "Settings" window is displayed in the work area.
2. Select the "General" group in the area navigation.
3. In the "General settings" group, select the mnemonics that you want to use.
The mnemonics is changed in all blocks.
Displaying symbolic and absolute addresses
You have the following options for displaying operands in the program editor:
Symbolic representation
The symbolic operands are displayed in the program. The corresponding absolute
addresses are shown in tooltips if you hold the mouse pointer over the operand.
Absolute representation
The absolute addresses are displayed in the program. The corresponding symbolic
operands are displayed in tooltips.
Symbolic and absolute representation
Symbolic operands and absolute addresses are displayed in program.
Requirement
The program editor is open.
Procedure
To change the representation of the operands, follow these steps:
1. Click the "Absolute/symbolic operands" button in the program editor toolbar.
Each time you click the button, the representation and the symbol on the button change.
Or:
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
System Manual, 01/2013, 1043
1. Click the small arrow next to the "Absolute/symbolic operands" button in the program editor
toolbar.
A drop-down list is displayed.
2. Select the required representation from the drop-down list.
The symbol on the button changes.
See also
Basic information about operands (Page 871)
Use instruction versions
Basic information on instruction versions
The instructions available to you for programming the user program are managed in system
libraries. If a new version of a system library is installed by an update, the newer versions of
the instructions of this system library may also be installed.
If there are several versions for an instruction, these are listed in the "Instructions" task card
after the respective instruction. If the instruction versions are not shown, you can show them
via the "Show column headers and additional columns" button in the toolbar of the
"Instructions" task card. You can then select the versions of the instructions to be used in the
program from the dropdown-list box of the "Version" column. If you do not select any versions,
the most recent versions are used.
Note
Please note the following:
You can only ever use the same version of an instruction within a device.
If you change the version of an instruction that other instructions depend on, the versions
of the dependent instructions are also changed.
If you select a version for an instruction that can not be run on the CPU used, the instruction
is shaded out. This means that you cannot use this instruction in this version with your
CPU.
When you change the version of an instruction, you must compile the block before the
new version number is displayed in the properties of the instruction.
Changes in the versions
New versions can be main versions or secondary versions. New versions, such as 2.0 or 3.0,
have more substantial changes to them. New main versions may therefore result in changes
to the block interface. New secondary versions, such as 1.3 or 1.4, contain lesser changes or
remedies to errors.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
1044 System Manual, 01/2013,
Using instruction versions
You can decide within a device which version of an instruction you want to use. If you select
another version for an instruction, the new version is specified for all locations of use of this
instruction within your program. These instructions are identified in the program by a red frame.
You must then download your program to the device to use the new instruction version.
Using instruction profiles
Basics of instruction profiles
Introduction
The TIA Portal provides you with numerous instructions that you can use to program the user
program. However, you may filter out specific instructions that you do not want to use. To this
end you can create instruction profiles in which you can explicitly specify the instructions to be
listed in the "Instructions" task card. However, although you may create several instruction
profiles in a project, only one of these profiles may be active at any given time. You can
exchange instruction profiles with other users by means of shared libraries.
Note
Please note the following:
The use of instructions that are not allowed in the active profile in a block will trigger the
output of a block compilation error. Such a situation may be triggered if you drag-and-drop
a block from the library to your program.
Instructions of a profile that are not supported by the currently installed products are
deleted from the profile the next time it is edited. If you transfer this profile to an engineering
system in which these instructions are supported by the installed products, the instructions
are again present in the profile but they are disabled. You can enable these instructions
as required at any time.
If you want to make changes to the active profile, you must recompile the blocks in the
project. This is also necessary when you disable or delete the active profile or when you
enable a profile.
See also
Creating new instruction profiles (Page 1046)
Opening and editing instruction profiles (Page 1047)
Activating and deactivating instruction profiles (Page 1048)
Deleting instruction profiles (Page 1049)
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
System Manual, 01/2013, 1045
Creating new instruction profiles
Requirement
The "Common data > Instruction profiles" folder is open in the project navigation.
Procedure
Proceed as follows to create a new instruction profile:
1. Double-click the "Add new profile" command.
The Instruction Profile Editor opens and displays the new instruction profile. All instructions
are activated for the new instruction profile.
2. Edit the new instruction profile to suit your requirements.
If necessary, you can rename the new instruction profile. To do this, follow these steps:
1. Right-click on the new instruction profile.
2. Select the "Rename" command in the shortcut menu.
3. Enter a name for the new instruction profile.
Note
The first instruction profile that you create will be used as active profile. In this case, compile
all blocks in the project. If other instruction profiles are already available you must explicitly
activate the new one in order to use it as active profile. You can identify the active profile by
its icon in the project navigation.
See also
Basics of instruction profiles (Page 1045)
Opening and editing instruction profiles (Page 1047)
Activating and deactivating instruction profiles (Page 1048)
Deleting instruction profiles (Page 1049)
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
1046 System Manual, 01/2013,
Opening and editing instruction profiles
Once you have opened an instruction profile, you can edit it as follows:
Activating and deactivating instructions
You can explicitly specify the instructions to be allowed in the instruction profile.
Note
Note that dependencies exist between some instructions. As a result, it is possible that
several instructions may be activated or deactivated by an action. The check box icon
indicates the folders in which instructions are deactivated.
Activating and deactivating instruction versions
Certain instructions are available with different versions. You can explicitly specify the
instruction versions to be allowed in the instruction profile.
Renumbering blocks
An instruction representing an internal function block (FB) or function (FC) in the system is
assigned a specific block number by the system. You can replace this block number with
your own block number. Within a version, there are several implementations for certain
instructions. The block numbers in such instructions can only be changed for the specific
implementation.
Note
If an instruction from the instruction profile is used in the program and the specified block
number is already in use by a different block, the specified block number of the instruction
will be replaced by a free block number.
Requirement
The "Common data > Instruction profiles" folder is open in the project navigation.
Opening instruction profiles
Proceed as follows to open an instruction profile:
1. Double-click the instruction profile that you want to edit.
The instruction profile opens in the Instruction Profile Editor.
Editing instruction profiles
Proceed as follows to edit an instruction profile in the Instruction Profile Editor:
1. Select the device that you want to edit from the "Device family" drop-down list box.
2. Select the programming language for which you want to edit the instruction profile from the
"Language" drop-down list box.
3. Deactivate the instructions or instruction versions that you want to exclude from the
instruction profile. You can deactivate a folder to deactivate all subordinate instructions.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
System Manual, 01/2013, 1047
4. Activate the instructions or instruction versions that you want to allow in the instruction
profile.
5. You may assign your own block numbers.
Note
A new compilation process is required for all blocks in the project when you change the active
profile.
See also
Basics of instruction profiles (Page 1045)
Creating new instruction profiles (Page 1046)
Activating and deactivating instruction profiles (Page 1048)
Deleting instruction profiles (Page 1049)
Use instruction versions (Page 1044)
Activating and deactivating instruction profiles
You first need to activate an instruction profile in order to include filtering of its instructions.
You can always deactivate the instruction profile to reset the instructions task card to the default
scope of instructions.
Note
A new compilation process is required for all blocks in the project.
Requirement
The "Common data > Instruction profiles" folder is open in the project navigation.
Activating instruction profiles
Proceed as follows to activate an instruction profile:
1. Right-click on the instruction profile that you want to activate.
2. Select the "Activate instruction profile" command from the shortcut menu.
The selected instruction profile is now active. Instructions can now only be used in
accordance with the settings of this profile.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
1048 System Manual, 01/2013,
Deactivating instruction profiles
Proceed as follows to deactivate the instruction profile:
1. Right-click on the instruction profile that you want to deactivate.
2. Select the "Deactivate instruction profile" command from the shortcut menu.
No instruction profile is active and the "Instructions" task card once again shows all
instructions that are available for use.
See also
Basics of instruction profiles (Page 1045)
Creating new instruction profiles (Page 1046)
Opening and editing instruction profiles (Page 1047)
Deleting instruction profiles (Page 1049)
Deleting instruction profiles
Requirement
The "Common data > Instruction profiles" folder is open in the project navigation.
Procedure
Proceed as follows to delete an instruction profile:
1. Right-click on the instruction profile that you want to delete.
2. Select the "Delete instruction profile" command from the shortcut menu.
Note
A new compilation process is required for all blocks in the project when you delete the active
profile.
Result
The selected instruction profile is deleted. If you deleted the active instruction profile, no more
active profiles are available and the "Instructions" task card once again shows all instructions
that are available for use.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
System Manual, 01/2013, 1049
See also
Basics of instruction profiles (Page 1045)
Creating new instruction profiles (Page 1046)
Opening and editing instruction profiles (Page 1047)
Activating and deactivating instruction profiles (Page 1048)
Using autocompletion
Basics of autocompletion
Function
You can use autocompletion in the program window of the program editor as an easy way to
access available tags or instructions during programming. Autocompletion means a context-
specific list appears in a dialog from which you can select the tags or instructions you need.
See also
Using autocompletion in graphic programming languages (Page 1050)
Using autocompletion in textual programming languages (Page 1051)
Using autocompletion in graphic programming languages
Inserting tags using autocompletion
To insert tags in graphic programming languages using autocompletion, follow these steps:
1. Select an operand of the instruction to which you wish to assign a tag.
The input field for the operand opens. The autocompletion button will appear beside the
input field.
2. Either click on the autocompletion button or type in the shortcut <Ctrl+l>.
Autocompletion opens. It contains only the local and global tags, data blocks and multiple
instances which are admissible for the operand in the given context. You can exit
autocompletion at any time by pressing <Esc>.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
1050 System Manual, 01/2013,
3. Select the required tag from the list. If necessary, you can also filter the list:
For example, enter the first few letters of the name of the tag or instruction you wish to
insert. Autocompletion will be filtered further with each letter entered. If there is no tag
or instruction starting with the letters entered, autocompletion will remain at the last
match.
Enter # to access the local tags from the block interface.
Enter " to access the global tags.
If the tag is a structured tag, a data block or a multiple instance, then an arrow is displayed
at the end of the row. Click on the arrow to display the lower-level elements. You can
navigate to the very last level in this way. If a structure is allowed as a data type for the
operand, you can choose from the "No Entry". This assigns the entire structure to the
operand as a tag. Use the <Backspace> key to return to the previous level.
4. Press the <Return> key to apply the tag.
See also
Basics of autocompletion (Page 1050)
Using autocompletion in textual programming languages (Page 1051)
Using autocompletion in textual programming languages
Inserting tags and instructions using autocompletion
To insert tags and instructions in textual programming languages using autocompletion, follow
these steps:
1. Enter the first few letters of the name of the tag or instruction you wish to insert. If necessary,
you can directly filter the kind of tags:
Enter # to access the local tags from the block interface.
Enter " to access the global tags.
Autocompletion opens. It contains only the local and global tags, data blocks, multiple
instances and instructions which are admissible at the current position. You can exit
autocompletion at any time by pressing <Esc>.
2. Enter more letters of the name of the tag or instruction you wish to insert. You can use
<Enter> or <Tab> to apply the tag or instruction and close autocompletion.
Autocompletion will be filtered further with each letter entered. If there is no tag or instruction
starting with the letters entered, autocompletion only contains the previous matches.
3. Select the tag or instruction required from the list.
If a tag is a structured tag, a data block or a multiple instance, first select the tag, the data
block or multiple instance from the autocompletion and apply the selection with <Enter>.
To select the additional components of the structure, data block, or multiple instance, enter
a period. Autocompletion then reopens and you can select the next component.
4. Press the <Return> key to apply the tag.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
System Manual, 01/2013, 1051
See also
Basics of autocompletion (Page 1050)
Using autocompletion in graphic programming languages (Page 1050)
General settings for the PLC programming
Overview of the general settings
Overview
The following table shows the general settings that you can make:
Group Setting Description
View With comments Network comments are shown.
with tag information Additional information for the tags used
is displayed in the program editor. This
setting only has an effect on blocks
which were programmed with LAD, FBD
or STL.
Compilation Delete actual parameters on interface
update
Actual parameters are deleted if the
associated formal parameters were
deleted in the called block, and you run
the "Update block call" function or
compile the block.
Default settings for new blocks IEC check The compatibility of operands in
comparison operations and arithmetic
operations are tested according to IEC
rules. You have to explicitly convert non-
compatible operands.
Memory reserve for download without
reinitialization
Memory reserve for new blocks Defines the size of reserve in volatile
memory that can be used for interface
extensions.
Additional settings Show autocompletion list The autocomplete list is displayed.
Sorting of the autocompletion list Sorting of the autocompletion list
according to either symbolic names or
absolute addresses.
Mnemonics German or international designation of
operations and operands
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
1052 System Manual, 01/2013,
See also
Changing the settings (Page 1053)
Permissible addresses and data types of PLC tags (Page 995)
Overview of the print settings (Page 162)
Basics of block access (Page 851)
Setting and canceling the IEC check (Page 946)
Changing the settings
Procedure
To change the settings, follow these steps:
1. Select the "Settings" command in the "Options" menu.
The "Settings" window is displayed in the work area.
2. In the area navigation, select the "PLC programming" group.
3. Change the settings.
Result
The change will be loaded directly, there is no need to save it explicitly.
See also
Overview of the general settings (Page 1052)
9.1.4.2 Programming code blocks
Declaring the block interface
Layout of the block interface
Introduction
The interface contains the declarations of local tags that are used within the block. The tags
are subdivided into two groups:
Block parameters that form the block interface when it is called in the program.
Local data that are used for storage of intermediate results.
You use tag declaration to define the call interface of a block in the program and the names
and data types of tags that you want to use in the block.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
System Manual, 01/2013, 1053
The interface of function blocks also defines the structure of the instances that are assigned
to the function block.
Layout of the block interface
The following figure shows the structure of the block interface. The number of columns and
sections varies depending on the type of block.
Block parameters
The following table shows the types of block parameters:
Type Section Function Available in
Input parameters Input Parameters whose values are read by the
block.
Functions, function blocks and
some types of organization
blocks
Output parameters Output Parameters whose values are written by the
block.
Functions and function blocks
In/out parameters InOut Parameters whose values are read by the
block when it is called, and whose values are
written again by the block after execution.
Functions and function blocks
Return value Return Function value that is returned to the calling
block.
Functions
Depending on the type of block opened, additional sections may be displayed.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
1054 System Manual, 01/2013,
Local data
The following table shows the types of local data:
Type Section Function Available in
Temporary local data Temp Tags that are used to store temporary
intermediate results. Temporary local data
are retained for only one cycle. If you use
temporary local data, you have to make sure
that the values are written within the cycle in
which you want to read them. Otherwise the
values will be random.
Functions, function blocks and
organization blocks
Static local data Static Tags that are used for storage of static
intermediate results in the instance data
block. Static data is retained until
overwritten, which may be after several
cycles. The names of the blocks, which are
called in this code block as multiple instance,
will also be stored in the static local data.
Function blocks
Meaning of the columns
The following table shows the meaning of the individual columns. You can show or hide the
columns as required. The number of columns displayed varies depending on the CPU series
and the type of the open object.
Column Explanation
Symbol you can click on to drag-and-drop a tag to a program for use
as an operand.
Name Name of the tags.
Data type Data type of the tags.
Offset Relative address of the tags. The column is only visible in blocks with
standard access.
Default value Value with which you can pre-assign specific tags in the interface of
the code block.
Specification of the default value is optional. If you do not specify any
value the predefined value for the indicated data type is used. For
example, the value "false" is predefined for BOOL.
The default value is assumed as the start value in the corresponding
instance data block. You can replace these values with instance-
specific start values in the instance data block.
The column is only available in the interface of function blocks.
Retentivity Marks the tag as retentive.
The values of retentive tags are retained even after the power supply
is switched off.
This column is only visible in the interface of the function block with
optimized access.
Visible in HMI Shows whether the tag is visible by default in the HMI selection list.
Accessible from HMI Shows whether HMI can access this tag during runtime.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
System Manual, 01/2013, 1055
Column Explanation
Setting value Marks the tag as setting value. Setting values are the values that will
probably have to be fine tuned during commissioning.
The column is only available in the interface of function blocks.
Comment Comment to document the tags.
See also
Using tags within the program (Page 871)
Reserved key words (Page 873)
Valid data types in the block interface (Page 1058)
Setting the retentivity of local tags (Page 1069)
Rules for declaring the block interface
General rules for declaring the block interface
Using POINTER
The following rules apply to the use of block parameters within the block:
Input parameters may only be read.
Output parameters may only be written.
In/out parameters may be read and written.
Assigning default values to block parameters
You can assign default values to specific parameters in the function block interface. The
possibility of the assignment depends on the declaration subsection and data type of the
parameter.
The following table shows which parameters can be assigned a default value:
Parameter type Section Assignment of a default value is possible
Elementary data types Structured data types Parameter types
Input parameters Input X X -
Output parameters Output X X -
In/out parameters InOut X - -
Static local data Static X X -
Temporary local data Temp - - -
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
1056 System Manual, 01/2013,
See also
Using tags within the program (Page 871)
Reserved key words (Page 873)
Valid data types in the block interface
Valid data types in the block interface in S7-300/400
The following table shows which data types you can assign to the parameters in the individual
sections of the interface.
Section Standard
Data types
ARRAY
STRUCT
STRING
DT
Parameter
types
VOID POINTER ANY
Organization block
Temp X X - - - X
Function block
Input X X X - X X
Output X X - - - -
InOut X X
(1)
- - X X
Static X X - - - -
Temp X X - - - X
Function
Input X X
(1)
X - X X
Output X X
(1)
- - X X
InOut X X
(1)
- - X X
Temp X X - - - X
Return X X - X X X
(2)
(1)
STRING can only be defined in the standard length of 254 characters.
(2)
In SCL, ANY is not permissible as return value.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
System Manual, 01/2013, 1057
Valid data types in the block interface
Valid data types in the block interface in S7-1200
The following table shows which data types you can assign in the parameters in the individual
sections of the interface.
Section Standard
Data types
ARRAY
STRUCT
STRING
DT
VOID VARIANT
Organization block
Temp X X - X
Function block
Input X X - X
Output X X - -
InOut X X
(1)
- X
Static X X - -
Temp X X - X
Function
Input X X
(1)
- X
Output X X
(1)
- X
InOut X X
(1)
- X
Temp X X - X
Return X X X -
(1)
STRING can only be defined in the standard length of 254 characters.
Valid data types in the block interface in S7-1500
The following table shows which data types you can assign in the parameters in the individual
sections of the interface.
Section Standard
Data
types
ARRAY
STRUCT
STRING
DT
Paramete
r types
VOID DB_ANY POINTER ANY VARIANT
Organization block
Temp X X -
(4)
- X - X
(3)
X
Function block
Input X X X - X X X X
Output X X - - X - - -
InOut X X
(1)
-
(4)
- X X X X
Static X X - - X - - -
Temp X X -
(4)
- - - X
(3)
X
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
1058 System Manual, 01/2013,
Section Standard
Data
types
ARRAY
STRUCT
STRING
DT
Paramete
r types
VOID DB_ANY POINTER ANY VARIANT
Function
Input X X
(1)
X - X X X X
Output X X
(1)
- - X X X X
InOut X X
(1)
-
(4)
- X X X X
Temp X X -
(4)
- X - X
(3)
X
Return X x - X X X x
(2)
-
(1)
STRING can only be defined in the standard length of 254 characters.
(2)
In SCL, ANY is not permissible as return value.
(3)
ANY can only be used in blocks with standard access in the "Temp" section.
(4)
The "INSTANCE" parameter type is the only exception permissible in the "TEMP" and "InOut" sections.
Declaring local tags
Declaring local tags in the block interface
Requirement
The block interface is open.
Procedure
To declare a tag of the elementary data type, follow these steps:
1. Select the appropriate declaration section in the interface:
2. Enter a tag name in the "Name" column.
3. Enter the required data type in the "Data type" column. You will be supported by
autocompletion during input.
4. Optional: Change the properties of the tags that are displayed in the other columns of the
block interface.
Result
The tag is created.
Syntax check
A syntax check is performed after each entry, and any errors found are displayed in red. You
do not have to correct these errors immediately - you can continue editing and make any
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
System Manual, 01/2013, 1059
corrections later. However, you will not be able to compile the program if the tag declaration
contains syntax errors.
Note
If you change the interface of a block, the calls of the block in the program will possibly become
inconsistent. The call locations are automatically updated, if possible.
If an automatic updating is not possible, the inconsistent blocks have to be updated manually.
See also:
Updating block calls in LAD (Page 1094)
Updating block calls in FBD (Page 1135)
See also
Editing tables (Page 201)
Basic information on start values (Page 1207)
Using tags within the program (Page 871)
Reserved key words (Page 873)
Properties of local tags (Page 1068)
Setting the retentivity of local tags (Page 1069)
Declaring local tags in the program editor
Requirement
The program editor is open.
Procedure
To declare a local tag, follow these steps:
1. Insert an instruction in your program.
The "<???>", "<??.?>" or "..." strings represent operand placeholders.
2. Replace an operand placeholder with the name of the tag to be created.
3. Select the tag name.
If you want to declare multiple tags, select the names of all the tags to be declared.
4. Select the "Define tag" command in the shortcut menu.
The "Define tag" dialog box opens. This dialog displays a declaration table in which the
name of the tag is already entered.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
1060 System Manual, 01/2013,
5. To declare a local tag, select one of the following sections:
Local In
Local Out
Local InOut
Local Static
Local Temp
6. In the other columns, enter data type and comments.
7. Click the "Define" button to complete your entry.
Result
The declaration is written directly into the block interface and is valid within the entire block.
Note
If you change the interface of a block, the calls of the block in the program will possibly become
inconsistent. The call locations are automatically updated, if possible.
If an automatic updating is not possible, the inconsistent blocks have to be updated manually.
See also:
Updating block calls in LAD (Page 1094)
Updating block calls in FBD (Page 1135)
See also
Editing tables (Page 201)
Using tags within the program (Page 871)
Reserved key words (Page 873)
Basic information on start values (Page 1207)
Properties of local tags (Page 1068)
Setting the retentivity of local tags (Page 1069)
Declaring tags of the ARRAY data type
Requirement
The block interface is open.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
System Manual, 01/2013, 1061
Procedure
To declare a tag of the ARRAY data type, follow these steps:
1. Select the appropriate declaration section in the interface.
2. Enter a tag name in the "Name" column.
3. In the "Data type" column, click the button for the data type selection.
A list of the permissible data types is opened.
4. Select the "Array" data type.
The "Array" dialog opens.
5. In the "Data type" text box, specify the data type of the array elements.
6. In the "ARRAY limits" text box, specify the high and low limit for each dimension.
Example of a one-dimensional ARRAY:
[0..3]
Example of a three-dimensional ARRAY:
[0..3, 0..15, 0..33]
7. Confirm your entry.
8. Optional: Change the properties of the tags that are displayed in the other columns of the
block interface.
Result
The tag of ARRAY data type is created.
Note
You cannot define specific default values for ARRAY elements. However, you can assign
them start values in the instance.
See also
Using tags within the program (Page 871)
Reserved key words (Page 873)
Properties of local tags (Page 1068)
Setting the retentivity of local tags (Page 1069)
Editing tables (Page 201)
Declaring tags of STRUCT data type
Requirement
The block interface is open.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
1062 System Manual, 01/2013,
Procedure
To declare a tag of the STRUCT data type, follow these steps:
1. Select the appropriate declaration section in the interface:
2. Enter a tag name in the "Name" column.
3. Enter "Struct" in the "Data type" column. You will be supported by autocompletion during
input.
An empty, indented row is inserted after the new tag.
4. Insert the first structural element in the first empty row.
An additional empty row is inserted after the element.
5. Select a data type for the structure element.
6. Optional: Change the properties of the structural element that is displayed in the other
columns of the block interface.
7. Repeat the step 4 to 7 for all additional structure elements.
It is not necessary to end the structure explicitly. The structure ends with the last element
that is entered.
8. To insert a new tag after the structure, leave a blank row after the end of the structure and
then start the new tag in the second empty row.
Result
The tag of STRUCT data type is created.
See also
Using tags within the program (Page 871)
Reserved key words (Page 873)
Properties of local tags (Page 1068)
Setting the retentivity of local tags (Page 1069)
Editing tables (Page 201)
Declaring tags based on a PLC data type
Requirement
A PLC data type is declared in the current CPU.
Procedure
To declare a tag based on a PLC data type, follow these steps:
1. Select the appropriate declaration section in the interface:
2. Enter the PLC data type in the "Data type" column. You will be supported by Autocomplete
during input.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
System Manual, 01/2013, 1063
Result
The tag is created.
Note
You define the default values of tags within a PLC data type when the PLC data type is
created. You cannot change these values at the point of use of the PLC data type.
If you change or delete PLC data types that are used in the block interface, the interface
becomes inconsistent. To remedy this inconsistency, the interface has to be updated.
See also: Updating the block interface (Page 1065)
See also
Editing tables (Page 201)
Basics of PLC data types (Page 1222)
Declaring higher-level tags
Introduction
To access data areas within a declared tag, you can overlay the declared tags with an
additional declaration. This provides you with the option of addressing an already declared tag
with a different data type. You can, for example, address the individual bits of a tag of WORD
data type with an ARRAY of BOOL.
Overlaying tags
To overlay a tag with a new data type, follow these steps:
1. Open the block interface.
2. In the interface, select the tag that you want to overlay with a new data type.
3. Click "Add row" in the toolbar.
A row is inserted after the tag to be overlaid. The overlaying tag must be declared in the
row directly after the tag that is to be overlaid.
4. Enter a tag name in the "Name" column.
5. Enter the "AT" entry in the "Data type" column. You will be supported by Autocomplete in
this step.
The following is added to the entry in the "Name" column.
"AT<Name of the higher-level tag>"
6. Click the data type selection button again and select the data type for the new tag.
The tag is created. It points to the same data as the higher-level tag, however interprets
this data with the new data type.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
1064 System Manual, 01/2013,
Removing overlay
To remove the overlay of a tag, follow these steps:
1. Select the overlaid tag that you want to remove.
2. Select the "Delete" command in the shortcut menu.
3. The overlay is removed.
See also
Editing tables (Page 201)
Overlaying tags with AT (Page 887)
Declaring multi-instances
Requirement
The function block to be called exists in project tree and is multi-instance capable.
The block interface of the calling function block is open.
Procedure
To declare a function block to be called as a multi-instance, follow these steps:
1. In the "Name" column of the "Static" section, enter a designation for the block call.
2. In the "Data type" column, enter the symbolic name for the function block to be called.
Note
The program editor will declare the multi-instance automatically if you program a block call
in a network and then specify in the "Call options" dialog that you want to call the block as a
multiple instance.
See also
Updating the block interface (Page 1065)
Updating the block interface
Introduction
If you change or delete PLC data types or multiple instances that are used in the block interface,
the interface will become inconsistent. To remedy this inconsistency, the interface has to be
updated.
You have two options for updating the block interface:
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
System Manual, 01/2013, 1065
Explicit updating of the block interface.
The used PLC data types and multiple instances will be updated. The instance data blocks
that belong to the block are not implicitly updated during this process.
Implicit updating during compilation.
All used PLC data types and multiple instances as well as the related instance data blocks
will be updated.
Explicit updating of the block interface
To explicitly update the block interface, follow these steps:
1. Open the block interface.
2. Select the "Update" command in the shortcut menu.
Implicit Updating during Compilation
Proceed as follows to implicitly update all uses of PLC data types and multiple instances as
well as the instance data blocks during compilation:
1. Open the project tree.
2. Select the "Program blocks" folder.
3. Select the command "Compile > Software (rebuild all blocks)" in the shortcut menu.
See also
Basics of PLC data types (Page 1222)
Declaring tags based on a PLC data type (Page 1063)
Editing tables (Page 201)
Basic information on start values (Page 1207)
Using tags within the program (Page 871)
Reserved key words (Page 873)
Properties of local tags (Page 1068)
Setting the retentivity of local tags (Page 1069)
Updating block calls in LAD (Page 1094)
Declaring multi-instances (Page 1065)
Extending the block interface
Description
In order to enable the editing of PLC programs that have already been commissioned and that
are running without error on a system, the CPUs of the S7-1500 product range support the
option of extending the interfaces of function blocks at runtime.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
1066 System Manual, 01/2013,
You can download the modified blocks without setting the CPU to STOP and without
influencing the values of already loaded tags.
This is a simple means of implementing program changes. This load process (loading without
re-initialization) will not have a negative impact on the controlled process.
Function principle
Each function block is always assigned a default memory reserve. This memory reserve is not
used initially. Activate the memory reserve if you decide on loading interface changes after
having compiled and downloaded the block. All tags that you subsequently declare will be
saved to the memory reserve. The subsequent download does not influence any tags that are
already loaded or have a negative impact on runtime.
If you decide to review your program at a later time while the plant is not in operation, you are
also provided an option of reworking the memory layout of individual or several blocks in a
single pass. With this action, you will move all tags from the reserve area to the regular area.
Memory reserve is now cleared and made available for further interface extensions.
Requirements
This "Load without re-initialization" function is available if the following requirements are met:
The project is available in "TIA Portal V12" format.
You are working with a CPU of the S7-1500 product range.
The block was created in LAD, FBD. STL, or SCL.
The blocks were created by the user, i.e. they are not included with the blocks delivered in
your package.
These blocks are assigned the optimized access attribute.
Basic steps
Perform the following steps if you want to extend the interface of a function block and then
load the block without re-initialization.
1. All blocks have a default memory reserve of 100 bytes. You can adapt this memory reserve
to suit your requirements.
2. Activate the memory reserve.
3. Extend the block interface.
4. Compile the block.
5. Download the block to the CPU as usual.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
System Manual, 01/2013, 1067
For more information on the various steps, refer to chapter "Loading blocks (S7-1200/1500) ".
Note
The full scope of the "Load without re-initialization" function is only available on CPUs of the
S7-1500 product range.
However, all CPU families support the option of extending the interface of function blocks
and downloading newly declared tags without repercussion:
You may add new tags in the "Temp" section and download these without influencing the
process.
You may create new tags of a structured data type in the "InOut" section and download
these without influencing the process.
Editing the properties of local tags
Properties of local tags
Properties
The following table gives an overview of the properties of local tags:
Group Property Description
General Name Name of the tags.
Data type Data type of the tags.
Default value Value with which you pre-assign the tag in the interface
of the code block.
Specification of the default value is optional. If you do not
specify any value the predefined value for the indicated
data type is used. For example, the value "false" is
predefined for BOOL.
The default value will be adopted as the start value in the
corresponding instance. You can then replace these
adopted values with instance-specific start values.
This property is only available in the interface of function
blocks.
Comment Comment on the tag.
Attributes Retain Marks the tag as retentive.
The values of retentive tags are retained even after the
power supply is switched off.
This attribute is only available in the interface of the
function block with optimized access.
Accessible from HMI Shows whether HMI can access this tag during runtime.
Visible in HMI Shows whether the tag is visible by default in the HMI
selection list.
Configurable Indicates whether a parameter is configurable in CFC.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
1068 System Manual, 01/2013,
Group Property Description
For test Indicates whether a parameter is registered for the CFC
test mode.
Visible Indicates whether a parameter is visible in CFC.
Interconnectable Indicates whether a parameter is interconnectable in CFC.
Enable tag readback Indicates whether a parameter is relevant for the "Read
back chart" function in CFC.
Enumeration texts Assigns a parameter to an enumeration in CFC.
Engineering unit Assigns a parameter to a unit in CFC.
Low limit Defines the low limit for the parameter in CFC:
High limit Defines the high limit for the parameter in CFC:
See also
Setting the retentivity of local tags (Page 1069)
Changing properties of local tags (Page 1070)
Reserved key words (Page 873)
Setting the retentivity of local tags
Introduction
Function blocks store their data in an instance. To prevent data loss in the event of power
failure, you can mark the data as retentive. This data is stored in a retentive memory area. The
option of setting the retentivity depends on the set access type of the function block.
Retentive behavior in blocks with standard access
In blocks with standard access you cannot set the retentive behavior of individual tags. You
can only define them as retentive in the assigned instance. All tags contained in the block are
then considered as retentive.
Retentivity for optimized block access
In data blocks with optimized access you can define the retentive behavior of individual tags.
For structured data type tags, the retentivity setting always applies to the entire structure. You
can make no individual retentivity setting for individual elements within the structure.
You cannot create retentive tags of the structured data type in the "InOut" section. In/out
parameters with structured data type, for example ARRAY, STRUCT, or STRING, are always
non-retentive.
The following settings are available:
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
System Manual, 01/2013, 1069
Retentive
The values of the tags or the structure are available even after a power failure.
Non-retentive
The values of the tags or the structure are lost in the event of a power failure.
Set in IDB
The retentivity can be set in the instance data block. The setting that is made in the instance
data block than applies, however, centrally to all tags that are selected with "Set in IDB".
See also
Properties of local tags (Page 1068)
Basics of block access (Page 851)
Changing properties of local tags
Editing properties in the block interface
To edit the properties of one or more tags, follow these steps:
1. Open the block interface.
2. Change the entries in the columns.
Editing properties in the properties window
To edit the properties of an individual tag, follow these steps:
1. Select a tag in the table.
The tag properties will be displayed in the Inspector window.
2. Change the entries in the inspector window.
Renaming tags directly in the program editor
To rename one or more tags, follow these steps:
1. Select one or more tags in the program.
2. Select the "Rename tag" command in the shortcut menu.
The "Rename tag" dialog opens. This dialog box displays a declaration table with the
selected tags.
3. Change the entries in the "Name" column.
4. Confirm the input by clicking the "Change" button.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
1070 System Manual, 01/2013,
Editing the data type or comment in the program editor
Proceed as follows to edit the data type or tag comment in the program editor:
1. Select the tag name.
2. Select the "Rewire tag" command in the shortcut menu.
The "Rewire tag" dialog will open. The dialog shows a declaration table.
3. Change the entry in the "Data type" or "Comment" columns.
4. Click the "Change" button to confirm the input.
Effect in the program
In the case of a change of the tag's name, data type or address, each location of use of the
tag is automatically updated in the program.
Note
If you change the interface of a block, the program may become inconsistent. The
inconsistencies are automatically updated, if possible.
If an automatic updating is not possible, the inconsistent calls are marked in red. You than
have to manually updated the inconsistencies.
See also:
Updating block calls in LAD (Page 1094)
Updating block calls in FBD (Page 1135)
See also
Layout of the block interface (Page 1053)
Editing tables (Page 201)
Properties of local tags (Page 1068)
Setting the retentivity of local tags (Page 1069)
Basic information on start values (Page 1207)
Using tags within the program (Page 871)
Reserved key words (Page 873)
Updating the block interface (Page 1065)
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
System Manual, 01/2013, 1071
Editing the block interface
Inserting table rows
Procedure
Proceed as follows to insert a row above the selected row:
1. Select the row in front of which you want to insert a new row.
2. Click the "Insert row" button on the toolbar of the table.
Result
A new row is inserted above the selected row.
See also
Editing tables (Page 201)
Inserting table rows
Procedure
Proceed as follows to insert a row below the selected row:
1. Select the row below which you want to insert a new row.
2. Click the "Add row" button on the table toolbar.
Result
A new empty row will be inserted below the selected row.
See also
Editing tables (Page 201)
Deleting tags
Procedure
To delete a tag, follow these steps:
1. Select the row with the tag to be deleted. You can also select several rows by clicking on
them one after the other while holding down the <Ctrl> key or by pressing and holding down
<Shift> and clicking on the first and last row.
2. Select the "Delete" command in the shortcut menu.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
1072 System Manual, 01/2013,
See also
Editing tables (Page 201)
Automatically filling in successive cells
You can load the contents of one or several table cells into the cells below, automatically filling
in the successive cells.
If you automatically fill in cells in the "Name" column, a consecutive number will be appended
to each name. For example, "Motor" will become "Motor_1".
You can define individual or more cells as well as entire rows as source area.
If less rows exist in the open table than you want to fill, then you will first have to insert additional
empty rows.
Requirement
The table is open.
Sufficient declaration rows are available.
Procedure
To automatically fill in successive cells, follow these steps:
1. Select the cells to be loaded.
2. Click the "Fill" symbol in the bottom right corner of the cell.
The mouse pointer is transformed into a crosshair.
3. Keep the mouse button pressed and drag the mouse pointer downwards over the cells that
you want to fill in automatically.
4. Release the mouse button.
The cells are filled in automatically.
5. If entries are already present in the cells that are to be automatically filled in, a dialog
appears. In this dialog you can indicate whether you want to overwrite the existing entries
or insert new rows for the new tags.
See also
Editing tables (Page 201)
Show and hide table columns
You can show or hide the columns in a table as needed.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
System Manual, 01/2013, 1073
Procedure
To show or hide table columns, follow these steps:
1. Click a column header.
2. Select the "Show/Hide" command in the shortcut menu.
The selection of available columns is displayed.
3. To show a column, select the column's check box.
4. To hide a column, clear the column's check box.
Editing tags with external editors
To edit individual tags in external table editors, such as Excel, you can export or import these
tags using copy and paste. However, you cannot copy structured tags to an editor.
Requirements
The block interface and an external editor are opened.
Procedure
To export individual tags to an external editor and import them again, follow these steps:
1. Select one or more tags.
2. Select "Copy" in the shortcut menu.
3. Switch to the external editor and paste the copied tags.
4. Edit the tags as required.
5. Copy the tags in the external editor.
6. Select the tags in the external editor.
7. Switch back to the block interface.
8. Select "Paste" in the shortcut menu.
Creating program code
Creating LAD programs
Basic information on LAD
LAD programming language
Overview of the Ladder Logic (LAD) programming language
LAD is a graphical programming language. The representation is based on circuit diagrams.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
1074 System Manual, 01/2013,
The program is mapped in one or more networks. A network contains a power rail on the left
where the rungs originate. The binary signal scans are arranged in the form of contacts on the
rungs. The serial arrangement of the elements on a rung creates a series connection;
arrangement on simultaneous branches creates a parallel connection. Complex functions are
represented by boxes.
Example of networks in LAD
The following figure shows a LAD network with two normally open contacts, one normally
closed contact and one coil:
#Start #Stop #Coil 1
#Coil
Network 1
Overview of the LAD elements
LAD elements
A LAD program consists of separate elements that you can arrange in series or parallel on the
power rail of a network. Most program elements must be supplied with tags.
There is at least one rung from the power rail. Network programming starts at the left edge of
the rung. You can expand the power rail by several rungs and branches.
For example, the following figure shows elements of a LAD network:
1) Power rail
2) Rung
3) Branch
4) Contact
5) Coil
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
System Manual, 01/2013, 1075
6) Box
Power rail
Each LAD network consists of a power rail that contains at least one rung. A network can be
extended by adding additional rungs. You can use branches to program parallel connections
in the specific rungs.
Contacts
You can use contacts to create or interrupt a current-carrying connection between two
elements. The current is relayed from left to right. You can use contacts to query the signal
state or the value of an operand and control it depending on the result of the current flow.
The following types of contact are available to you in a LAD program:
Normally open contact:
Normally open contacts forward the current if the signal state of a specified binary operand
is "1".
Normally closed contacts:
Normally closed contacts forward the current if the signal state of a specified binary operand
is "0".
Contact with additional function:
Contacts with additional function forward the current if a specific condition is met. With these
contacts you can also execute an additional function, such as an RLO edge detection and
a comparison.
Coils
You can use coils to control binary operands. Coils can set or reset a binary operand depending
on the signal state of the result of logic operation.
The following types of coils are available to you in a LAD program:
Standard coils:
Standard coils set a binary operand if current flows in the coil. The "Assignment" instruction
is an example of a standard coil.
Coils with additional function:
These coils have additional functions in addition to the evaluation of the logic operation
result. Coils for RLO edge detection and program control are examples of coils with
additional function.
Boxes
Boxes are LAD elements with complex functions. The empty box is an exception. You can use
the empty box as a placeholder in which you can select the required instruction.
The following types of boxes are available to you in a LAD program:
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
1076 System Manual, 01/2013,
Boxes without EN/ENO mechanism:
A box is executed depending on the signal state at the box inputs. The error status of the
processing cannot be queried.
Boxes with EN/ENO mechanism:
A box is only executed if the enable input "EN" carries the signal state "1". If the box is
processed correctly, the "ENO" enable output has signal state "1". If an error occurs during
the processing, the "ENO" enable output is reset.
Calls of code block are also shown in the network as boxes with EN/ENO mechanism.
See also
Rules for the use of LAD elements (Page 1085)
Settings for LAD
Overview of the settings for LAD
Overview
The following table shows the settings that you can make:
Group Setting Description
Font Font size Font size in program editor
View Layout Compact or wide
Changes the vertical spacing between
operands and other objects (such as
operand and contact). The change
becomes visible once the block is
reopened.
With absolute information Additional display of the absolute
addresses
Operand field Maximum width Maximum number of characters that
can be entered horizontally in the
operand field. This setting recalculates
the layout of the networks.
Maximum height Maximum number of characters that
can be entered vertically in the operand
field. This setting recalculates the layout
of the networks.
See also
Changing the settings (Page 1078)
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
System Manual, 01/2013, 1077
Changing the settings
Procedure
To change the settings, follow these steps:
1. Select the "Settings" command in the "Options" menu.
The "Settings" window is displayed in the work area.
2. In the area navigation, select the "PLC programming" group.
3. Change the settings.
Result
The change will be loaded directly, there is no need to save it explicitly.
See also
Overview of the settings for LAD (Page 1077)
Working with networks
Using networks
Function
The user program is created in the block within networks. For a code block to be programmed,
it must contain at least one network. To achieve a better overview of the user program, you
can also subdivide your program into several networks.
See also
Entering the network title (Page 1082)
Entering a network comment (Page 1083)
Navigating networks (Page 1084)
Inserting networks
Requirement
A block is open.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
1078 System Manual, 01/2013,
Procedure
To insert a new network, follow these steps:
1. Select the network after which you want to insert a new network.
2. Select the "Insert network" command in the shortcut menu.
Result
A new empty network is inserted into the block.
See also
Selecting networks (Page 1079)
Copying and pasting networks (Page 1080)
Deleting networks (Page 1081)
Expanding and collapsing networks (Page 1081)
Entering the network title (Page 1082)
Entering a network comment (Page 1083)
Navigating networks (Page 1084)
Selecting networks
Requirements
A network is available.
Selecting a network
To select a network, follow these steps:
1. Click the title bar of the network that you want to select.
Selecting several networks
Proceed as follows to select several individual networks:
1. Press and hold down the <Ctrl> key.
2. Click all the networks that you want to select.
To select several successive networks, follow these steps:
1. Press and hold down the <Shift> key.
2. Click the first network that you want to select.
3. Click the last network that you want to select.
The first and last networks and all those in between are selected.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
System Manual, 01/2013, 1079
See also
Inserting networks (Page 1078)
Copying and pasting networks (Page 1080)
Deleting networks (Page 1081)
Expanding and collapsing networks (Page 1081)
Entering the network title (Page 1082)
Entering a network comment (Page 1083)
Navigating networks (Page 1084)
Copying and pasting networks
Copied networks can be pasted within the block or in another block. Networks that were created
in LAD or FBD can also be inserted in blocks of the respective other programming language.
Requirement
A network is available.
Procedure
To copy and paste a network, follow these steps:
1. Select the network or networks to be copied.
2. Select "Copy" in the shortcut menu.
3. Select the network after which you want to paste in the copied network.
4. Select "Paste" in the shortcut menu.
See also
Inserting networks (Page 1078)
Selecting networks (Page 1079)
Deleting networks (Page 1081)
Expanding and collapsing networks (Page 1081)
Entering the network title (Page 1082)
Entering a network comment (Page 1083)
Navigating networks (Page 1084)
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
1080 System Manual, 01/2013,
Deleting networks
Requirement
A network is available.
Procedure
To delete a network, follow these steps:
1. Select the network that you want to delete.
2. Select the "Delete" command in the shortcut menu.
See also
Inserting networks (Page 1078)
Selecting networks (Page 1079)
Copying and pasting networks (Page 1080)
Expanding and collapsing networks (Page 1081)
Entering the network title (Page 1082)
Entering a network comment (Page 1083)
Navigating networks (Page 1084)
Expanding and collapsing networks
Requirements
A network is available.
Opening and closing a network
To open a network, follow these steps:
1. Click on the right arrow in the network title bar.
To close a network, follow these steps:
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
System Manual, 01/2013, 1081
1. Click on the down arrow in the network title bar.
Opening and closing all networks
To open and close all networks, follow these steps:
1. In the toolbar, click "Open all networks" or "Close all networks".
See also
Inserting networks (Page 1078)
Selecting networks (Page 1079)
Copying and pasting networks (Page 1080)
Deleting networks (Page 1081)
Entering the network title (Page 1082)
Entering a network comment (Page 1083)
Navigating networks (Page 1084)
Entering the network title
The network title is the header of a network. The length of the network title is limited to one
line.
Requirement
A network is available.
Procedure
To enter a network title, follow these steps:
1. Click on the title bar of the network.
2. Enter the network title.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
1082 System Manual, 01/2013,
See also
Using networks (Page 1078)
Inserting networks (Page 1078)
Selecting networks (Page 1079)
Copying and pasting networks (Page 1080)
Deleting networks (Page 1081)
Expanding and collapsing networks (Page 1081)
Entering a network comment (Page 1083)
Navigating networks (Page 1084)
Entering a network comment
You can use network comments to provide comments on the program contents of individual
networks. For example, you can indicate the function of the network or draw attention to special
characteristics.
Requirement
A network is available.
Procedure
To enter a network comment, follow these steps:
1. Click on the right arrow before the network title.
2. If the comment area is not visible, click "Network comments on/off" in the toolbar.
The comment area is displayed.
3. Click "Comment" in the comment area.
The "Comment" text passage is selected.
4. Enter the network comment.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
System Manual, 01/2013, 1083
See also
Using networks (Page 1078)
Inserting networks (Page 1078)
Selecting networks (Page 1079)
Copying and pasting networks (Page 1080)
Deleting networks (Page 1081)
Expanding and collapsing networks (Page 1081)
Entering the network title (Page 1082)
Navigating networks (Page 1084)
Navigating networks
You can navigate straight to a specific position within a block.
Procedure
To navigate to a specific position within a block, follow these steps:
1. Right-click in the code area of the programming window.
2. Select the "Go to > Network/line" command in the shortcut menu.
The "Go to" dialog will open.
3. Enter the network to which you want to navigate.
4. Enter the line number of the network to which you want to navigate.
5. Confirm your entry with "OK".
Result
The relevant line will be displayed if this is possible. If the network or line requested does not
exist, the last existing network or the last existing line in the network requested will be displayed.
See also
Using networks (Page 1078)
Inserting networks (Page 1078)
Selecting networks (Page 1079)
Copying and pasting networks (Page 1080)
Deleting networks (Page 1081)
Expanding and collapsing networks (Page 1081)
Entering the network title (Page 1082)
Entering a network comment (Page 1083)
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
1084 System Manual, 01/2013,
Inserting LAD elements
Rules for the use of LAD elements
Rules
Note the following rules when inserting LAD elements:
Every LAD network must terminate with a coil or a box. However, the following LAD
elements must not be used to terminate a network:
Comparator boxes
Instructions for positive and negative RLO edge detection
The starting point of the branch for a box connection must always be the power rail. Logic
operations or other boxes can be present in the branch before the box.
Only contacts can be inserted into simultaneous branches with preceding logic operations.
The contact for negating the result of logic operation (-|NOT|-) is an exception here. The
contact for negating the result of logic operation, as well as coils and boxes, can be used
in simultaneous branches if they originate directly from the power rail.
Constants (e.g. TRUE or FALSE) cannot be assigned to normally closed or normally open
contacts. Instead, use operands of the BOOL data type.
Only one jump instruction can be inserted in each network.
Only one jump label can be inserted in each network.
Instructions with positive or negative edge detection may not be arranged directly at the
left margin of the rung as they requires a prior logic operation.
Placement rules for S7-1200/1500 CPUs
The following table sets out the instructions that can only be positioned at the end of the
network:
Instruction Preceding logic operation
required
Mnemonics Name
SET_BF Set bit field No
RESET_BF Reset bit field No
JMP Jump if RLO = 1 No
JMPN Jump if RLO = 0 Yes
JMP_LIST Define jump list No
SWITCH Jump distributor No
RET Return No
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
System Manual, 01/2013, 1085
Placement rules for S7-300/400 CPUs
The following table sets out the instructions that can only be positioned at the end of the
network:
Instruction Preceding logic operation
required
Mnemonic
s
Name
S Set output Yes
R Reset output Yes
SP Start pulse timer Yes
SE Start extended pulse timer Yes
SD Start on-delay timer Yes
SS Start retentive on-delay timer Yes
SF Start off-delay timer Yes
SC Set counter value Yes
CU Count up Yes
CD Count down Yes
JMP Jump if RLO = 1 No
JMPN Jump if RLO = 0 Yes
RET Return No
OPN Open global data block No
OPNI Open instance data block No
CALL Call block No
SAVE Save RLO in BR bit No
MCRA Enable MCR range No
MCRD Disable MCR range No
MCR< Open MCR ranges No
MCR> Close MCR ranges No
See also
Prohibited interconnections in LAD (Page 1087)
Overview of the LAD elements (Page 1075)
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
1086 System Manual, 01/2013,
Prohibited interconnections in LAD
Power flow from right to left
No branches can be programmed that could result in a power flow in the reverse direction.
lmpermissible rate of flow!
l 4.4 l 2.8
l 2.6 l 6.8
l 1.4 l 4.2 Q 6.0 l 1.2 l 1.0
Short-circuit
No branches may be programmed that would cause a short-circuit.
Short circuit impermissible!
l 1.4 Q 6.0 l 1.2 l 1.0
Logic operations
The following rules apply to logic operations:
Only Boolean inputs can be combined with preceding logic operations.
Only the first Boolean output can be combined with a further logic operation.
Only one complete logical path can exist per network. Paths that are not connected can be
linked.
See also
Rules for the use of LAD elements (Page 1085)
Inserting LAD elements using the "Instructions" task card
Requirement
A network is available.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
System Manual, 01/2013, 1087
Procedure
To insert a LAD element into a network using the "Instructions" task card, follow these steps:
1. Open the "Instructions" task card.
2. Navigate to the LAD element that you want to insert.
3. Use drag-and-drop to move the element to the desired place in the network.
If the element is an internal system function block (FB), the "Call options" dialog opens. In
this dialog you can create an instance data block of the single-instance or multiple-instance
type for the function block in which the data of the inserted element will be saved. You will
find the new instance data block created in the project tree in the "Program resources"
folder under "Program blocks > System blocks". If you have selected "multiple instance",
these are located in the block interface in the "Static" section.
Or:
1. Select the point in the network at which you want to insert the element.
2. Open the "Instructions" task card.
3. Double-click on the element you want to insert.
If the element is an internal system function block (FB), the "Call options" dialog opens. In
this dialog you can create an instance data block of the single-instance or multiple-instance
type for the function block in which the data of the inserted element will be saved. You will
find the new instance data block created in the project tree in the "Program resources"
folder under "Program blocks > System blocks". If you have selected "multiple instance",
these are located in the block interface in the "Static" section.
Result
The selected LAD element is inserted with placeholders for the parameters.
Inserting LAD elements using an empty box
Requirement
A network is available.
Procedure
To insert an LAD element into a network using an empty box, follow these steps:
1. Open the "Instructions" task card.
2. Navigate to "General > Empty box" in the "Basic instructions" palette.
3. Use a drag-and-drop operation to move the "Empty box" element to the desired place in
the network.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
1088 System Manual, 01/2013,
4. Position the cursor over the triangle in the top right-hand corner of the empty box.
A drop-down list is displayed.
5. Select the required LAD element from the drop-down list.
If the element is an internal system function block (FB), the "Call option" dialog opens. In
this dialog you can create an instance data block of the single-instance or multiple-instance
type for the function block in which the data of the inserted element will be saved. You will
find the new instance data block created in the project tree in the "Program resources"
folder under "Program blocks > System blocks". If you have selected "multi-instance", these
are located in the block interface in the "Static" section.
Result
The empty box is changed to the respective LAD element. Placeholders are inserted for the
parameters.
Selecting the data type of a LAD element
Selecting a data type
Introduction
Some instructions can be executed with several different data types. If you use one of these
instructions in the program, you have to specify a valid data type for the instruction at the
specific point in the program. For some instructions, you have to select the data types for the
inputs and outputs separately.
Note
The valid data type (BOOL) for the tags on the enable input EN and the enable output ENO
is predefined by the system and cannot be changed.
The valid data types for an instruction are listed in the instruction drop-down list. You specify
the data type of the instruction by selecting an entry from the drop-down list. If the data type
of an operand differs from the data type of the instruction and cannot be converted implicitly,
the operand is displayed in red and a rollout with the corresponding error message appears.
Data type selection of mathematical instructions
Some mathematical instructions provide you with the option of having the data type
automatically set corresponding to the data types of the operand. In the drop-down list for data
type selection, these instructions have the entry "Auto" in addition to the actual data types. If
you select this entry and then allocate the first operand, the data type of the operand is selected
as data type for the instruction. The entry in the drop-down list changes to "Auto (<Data type>)",
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
System Manual, 01/2013, 1089
e.g. "Auto (Real)". If you allocate additional operands, the automatically set data type of the
instruction is adjusted according to the following criteria:
You supply all other operands with tags of the same data type:
The data type of the instruction is not changed.
You supply all other operands with tags whose data type is smaller than the data type of
the instruction:
The data type of the instruction is not changed. For the operand with the smaller data type,
an implicit conversion is conducted if necessary.
You supply an additional operand with a tag whose data type is greater than the data type
of the instruction:
The data type of the instruction is changed to the larger data type. An implicit conversion
is performed, if necessary, for operands that deviate from the newly set data type of the
instruction.
Each change in the data type of an operand can result in a change of the data type of the
instruction. Other operands may possibly be implicitly converted as a result. Operands for
which an implicit conversion is performed are marked with a gray square.
Note
Please also observe the information on data type conversion for your device and, in particular,
the notes on the IEC check.
See also: Data type conversion
See also
Defining the data type of an instruction (Page 1090)
Defining the data type of an instruction
Introduction
Some instructions can be executed with several different data types. When you insert such
instructions into your program, you must specify the data type for these instructions at the
actual point in the program.
Specifying the data type by means of the drop-down list
To define the data type of an instruction using the drop-down list, follow these steps:
1. Insert the instruction at the required point in the program using drag-and-drop.
The entry "???" (undefined) is displayed in the drop-down list of the inserted instruction.
2. Click the triangle in the upper corner of the drop-down list.
The drop-down list will open to display the data types valid for the instruction.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
1090 System Manual, 01/2013,
3. Select a data type from the drop-down list.
The selected data type is displayed.
4. If the instruction has two drop-down lists, select the data type for the instruction inputs in
the left-hand drop-down list and the data type for the instruction outputs in the right-hand
drop-down list.
Specifying data type by assigning tags
To define the data type of an instruction by assigning tags, follow these steps:
1. Insert the instruction at the required point in the program using drag-and-drop.
The entry "???" (undefined) is displayed in the drop-down list of the inserted instruction.
2. At an input or output, specify a valid tag, the data type of which is to be applied as the
instruction data type.
The data type of the tag is displayed in the drop-down list.
3. Enter a valid tag at an input and a valid tag at an output if data types need to be defined
for both the inputs and outputs of the instruction. The tag specified at the input determines
the data type of the inputs; the tag specified at the output determines the data type of the
outputs of the instruction.
Automatically specifying the data type of mathematical instructions
To automatically specify the data type for mathematical instructions, follow these steps:
1. Insert the mathematical instruction at the required point in the program using drag-and-drop.
The entry "???" (undefined) is displayed in the drop-down list of the inserted instruction.
2. Select the "Auto" entry from the drop-down list.
3. Enter a valid tag at an input or output.
The data type of the tag is applied as data type of the instruction. The entry in the drop-
down list changes to "Auto (<Data type>)".
See also: Selecting a data type (Page 1089)
See also
Selecting a data type (Page 1089)
Using favorites in LAD
Adding LAD elements to Favorites
Requirement
A block is open.
The multipane mode is set for the "Instructions" task card or the Favorites are also displayed
in the editor.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
System Manual, 01/2013, 1091
Procedure
To add SCL instructions to the Favorites, follow these steps:
1. Open the "Instructions" task card.
2. Maximize the "Basic instructions" pane.
3. Navigate in the "Basic instructions" pane to the instruction that you want to add to the
Favorites.
4. Drag-and-drop the instruction into the "Favorites" pane or into the Favorites area in the
program editor.
Note
To additionally display the Favorites in the program editor, click the "Display favorites in the
editor" button in the program editor toolbar.
See also
Removing LAD elements from Favorites (Page 1093)
Overview of the program editor (Page 1034)
Inserting LAD elements using favorites
Requirement
A block is open.
Favorites are available.
Procedure
To insert an instruction into a program using Favorites, follow these steps:
1. Drag-and-drop the desired instruction from Favorites to the desired position.
Or:
1. Select the position in the program where you want to insert the instruction.
2. In the Favorites, click on the instruction you want to insert.
Note
To additionally display the Favorites in the program editor, click the "Display favorites in the
editor" button in the program editor toolbar.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
1092 System Manual, 01/2013,
See also
Removing LAD elements from Favorites (Page 1093)
Overview of the program editor (Page 1034)
Removing LAD elements from Favorites
Requirement
A code block is open.
Procedure
To remove instructions from Favorites, follow these steps:
1. Right-click on the instruction you want to remove.
2. Select the "Remove instruction" command in the shortcut menu.
Note
To additionally display the Favorites in the program editor, click the "Display favorites in the
editor" button in the program editor toolbar.
See also
Adding LAD elements to Favorites (Page 1091)
Inserting LAD elements using favorites (Page 1092)
Overview of the program editor (Page 1034)
Insert block calls in LAD
Inserting block calls using a drag-and-drop operation
You can insert calls for existing functions (FC) and function blocks (FB) using a drag-and-drop
operation from the project tree. If you call function blocks from other function blocks, you can
either call them as single-instance or multi-instance blocks. If a function block is called as single
instance, it will store its data in a data block of its own. If a function block is called as multi-
instance, it will store its data in the instance data block of the calling function block.
Requirement
A network is available.
The block that is to be called is available.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
System Manual, 01/2013, 1093
Inserting a call of a function (FC)
To insert a call of a function (FC) into a network using a drag-and-drop operation, follow these
steps:
1. Drag the function from the project tree to the required network.
Inserting a call for a function block (FB)
To insert a call for a function block (FB), follow these steps:
1. Drag the function block from the project tree to the required network.
The "Call options" dialog opens.
2. Enter in the dialog whether you wish to call the block as single or multi-instance.
If you click on the "Single instance" button, you will have to enter a name in the "Name"
text box for the data block that you want to assign to the function block.
If you click on the "Multi-instance" button, you will have to enter the name of the tag in
the "Name in the interface" text box; this is the name that you use to enter the called
function block as a static tag in the interface of the calling block.
3. Confirm your entries with "OK".
Result
The function or the function block is inserted with its parameters. You can then assign the
parameters.
See also: Auto-Hotspot
Note
If when calling a function block you specify an instance data block that does not exist, it will
be created. If you have called a function block as a multi-instance, this will be entered as a
static tag in the interface.
See also
Updating block calls in LAD (Page 1094)
Changing the instance type (Page 1095)
Single instances (Page 858)
Multi-instances (Page 859)
Updating block calls in LAD
If interface parameters of a called block are changed, the block call can no longer be executed
correctly. You can avoid such inconsistent block calls by updating the block calls.
You have two options to update the block calls:
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
1094 System Manual, 01/2013,
Explicit updating in the program editor.
The block calls in the open block will be updated.
Implicit updating during compilation.
All block calls in the program as well as the used PLC data types will be updated.
Update blocks in the program editor
To update a block call within a block, follow these steps:
1. Open the block in the program editor.
2. Click "Update inconsistent block calls" in the toolbar.
Or:
1. Open the block in the program editor.
2. Right-click on the instruction with the block call.
3. Select the "Update" command in the shortcut menu.
The "Interface update" dialog opens. This dialog shows the differences between the block
interface in use and the changed interface of the called block.
4. If you want to update the block call, click "OK". To cancel the update, click "Cancel".
Update block calls during compilation
Follow these steps to update all block calls and uses of PLC data types during compilation
implicitly:
1. Open the project tree.
2. Select the "Program blocks" folder.
3. Select the command "Compile > Software (rebuild all blocks)" in the shortcut menu.
See also
Inserting block calls using a drag-and-drop operation (Page 1093)
Changing the instance type (Page 1095)
Changing the instance type
Instance type
There are two ways of calling function blocks:
As a single instance
As a multiple instance
See also: Auto-Hotspot
You can modify a defined instance type at any time.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
System Manual, 01/2013, 1095
Requirement
The user program contains a block call.
Procedure
To change the instance type of a function block, follow these steps:
1. Open the code block and select the block call.
2. Select the "Change instance" command in the shortcut menu.
The "Call options" dialog opens.
3. Click the "Single instance" or "Multi instance" button.
If you select the "Single instance" instance type, enter a name for the data block that is
to be assigned to the function block.
If you select "Multiple instance" as the instance type, enter in the "Name in the interface"
text field the name of the tag with which the called function block is to be entered as a
static tag in the interface of the calling block.
4. Confirm your entries with "OK".
Note
The previous single and multiple instances will not be deleted automatically.
See also
Inserting block calls using a drag-and-drop operation (Page 1093)
Updating block calls in LAD (Page 1094)
Inserting complex LAD instructions
Using the "Calculate" instruction
Requirement
A network is available.
Procedure
Proceed as follows to use the "Calculate" instruction:
1. Open the "Instructions" task card.
2. Navigate to "Math functions > CALCULATE" in the "Basic instructions" pane.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
1096 System Manual, 01/2013,
3. Use drag-and-drop to move the element to the desired place in the network.
The instruction "Calculate" will be inserted for the data type with a placeholder expression
and question mark.
4. Enter the data type for the calculation.
5. Enter the operands for the calculation.
Note
The calculation is run with the inputs of the "Calculate" instruction. If you want to use
constants you must also insert appropriate inputs for them.
6. Click on the "Edit 'Calculate' instruction" button to replace the placeholder expression with
the correct expression.
The "Edit 'Calculate' instruction" dialog will open.
7. Enter the required expression in the "OUT:= " text box.
Note
In the "Example" area you can find an example of a valid expression and possible
instructions that you can use.
To determine a value with the help of Pythagoras' theorem, for example, enter "OUT :=
SQRT (SQR (IN1) + SQR (IN2))".
8. Confirm your entry with "OK".
See also
CALCULATE: Calculate (Page 1519)
Using free-form comments
Basic information on using free-form comments in LAD
Introduction
Free-form comments allow you to add comments to the source code for graphic programming
languages similar to line comments for textual languages.
Free-form comments can be used for the following elements:
Boxes
Coils
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
System Manual, 01/2013, 1097
See also
Inserting free-form comments (Page 1098)
Editing free-form comments (Page 1098)
Deleting free-form comments (Page 1100)
Inserting free-form comments
Requirement
A network with instructions is available.
Procedure
To insert a free comment on an instruction, proceed as follows:
1. If necessary, activate the "Free-form comments on/off" button in the toolbar.
2. Right-click on the instruction for which you want to insert a free-form comment.
3. Select the "Insert comment" command in the shortcut menu.
A comment box with a standard comment opens. The comment box is connected by an
arrow to the corresponding instruction.
4. Enter the required comment in the comment box.
See also
Basic information on using free-form comments in LAD (Page 1097)
Editing free-form comments (Page 1098)
Deleting free-form comments (Page 1100)
Editing free-form comments
Introduction
Free-form comments can be edited as follows:
Changing the comment text
Changing the position and size of the comment box
Attaching a comment to another element
Showing and hiding free comments
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
1098 System Manual, 01/2013,
Changing the comment text
To change the text of free-form comments, follow these steps:
1. Click on the comment box.
2. Enter the desired text.
Changing the position of the comment box
To change the positioning of the comment box, follow the steps below:
1. Left-click the comment box and keep the mouse button pressed.
2. Drag the comment box to the desired location.
Changing the size of the comment box
To change the size of the comment box, follow the steps below:
1. Click on the comment box.
2. Drag the comment box on the move handle in the lower right corner to the desired size.
Attaching a comment to another element
To attach a free-form comment to another element, follow these steps:
1. Left-click the point of the arrow that links the comment box with the instruction and keep
the mouse button pressed.
2. Drag the arrow to the element to which you want to attach the comment. Possible insertion
points are marked with a green square.
3. Release the mouse button.
Showing and hiding free comments
To show or hide a free-form comments, follow these steps:
1. Click the "Free-form comment on/off" button in the toolbar.
See also
Basic information on using free-form comments in LAD (Page 1097)
Inserting free-form comments (Page 1098)
Deleting free-form comments (Page 1100)
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
System Manual, 01/2013, 1099
Deleting free-form comments
Procedure
To delete a free-form comment, proceed as follows:
1. Right-click on the free-form comment that you want to delete.
2. Select the "Delete" command in the shortcut menu.
See also
Basic information on using free-form comments in LAD (Page 1097)
Inserting free-form comments (Page 1098)
Editing free-form comments (Page 1098)
Editing LAD elements
Selecting LAD elements
You can select several individual elements or all elements in a network.
Requirement
LAD elements are available
Selecting several individual LAD elements
To select several individual LAD elements, follow these steps:
1. Press and hold down the <Ctrl> key.
2. Click on all the LAD elements you wish to select.
3. Now release the <Ctrl> key.
Selecting all LAD elements in a network
To select all LAD elements in a network, follow these steps:
1. Go to the network whose elements you wish to select.
2. Select the "Select all" command in the "Edit" menu or press <Ctrl A>.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
1100 System Manual, 01/2013,
See also
Copying LAD elements (Page 1101)
Cutting LAD elements (Page 1102)
Pasting an LAD element from the clipboard (Page 1102)
Replacing LAD elements (Page 1103)
Inserting additional inputs and outputs in LAD elements (Page 1104)
Removing inputs and outputs (Page 1105)
Deactivating and activating EN/ENO mechanisms (Page 1105)
Deleting LAD elements (Page 1106)
Copying LAD elements
Requirement
An LAD element is available.
Procedure
To copy a LAD element, follow these steps:
1. Right-click the LAD element that you want to copy.
2. Select "Copy" in the shortcut menu.
Result
The LAD element will be copied and saved to the clipboard.
See also
Selecting LAD elements (Page 1100)
Cutting LAD elements (Page 1102)
Pasting an LAD element from the clipboard (Page 1102)
Replacing LAD elements (Page 1103)
Inserting additional inputs and outputs in LAD elements (Page 1104)
Removing inputs and outputs (Page 1105)
Deactivating and activating EN/ENO mechanisms (Page 1105)
Deleting LAD elements (Page 1106)
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
System Manual, 01/2013, 1101
Cutting LAD elements
Requirement
An LAD element is available.
Cutting
To cut a LAD element, follow these steps:
1. Right-click the LAD element that you want to cut.
2. Select "Cut" in the shortcut menu.
Result
The LAD element will be cut and saved to the clipboard.
See also
Selecting LAD elements (Page 1100)
Copying LAD elements (Page 1101)
Pasting an LAD element from the clipboard (Page 1102)
Replacing LAD elements (Page 1103)
Inserting additional inputs and outputs in LAD elements (Page 1104)
Removing inputs and outputs (Page 1105)
Deactivating and activating EN/ENO mechanisms (Page 1105)
Deleting LAD elements (Page 1106)
Pasting an LAD element from the clipboard
Requirement
An LAD element is available.
Procedure
To paste an LAD element from the clipboard, follow these steps:
1. Copy a LAD element or cut a LAD element.
2. Right-click the point in the network where you want to paste the element.
3. Select "Paste" in the shortcut menu.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
1102 System Manual, 01/2013,
See also
Selecting LAD elements (Page 1100)
Copying LAD elements (Page 1101)
Cutting LAD elements (Page 1102)
Replacing LAD elements (Page 1103)
Inserting additional inputs and outputs in LAD elements (Page 1104)
Removing inputs and outputs (Page 1105)
Deactivating and activating EN/ENO mechanisms (Page 1105)
Deleting LAD elements (Page 1106)
Replacing LAD elements
You can easily exchange LAD elements with other LAD elements of the same type. This has
the advantage that the parameters are retained and need not be entered again. For example,
you can exchange normally open contacts and normally closed contacts or RS FlipFlop and
SR FlipFlop.
Requirements
A network with at least one LAD element is present.
Procedure
To replace an LAD element with another LAD element, follow these steps:
1. Select the LAD element that you want to replace.
2. Position the cursor over the triangle in the top right-hand corner of the LAD element.
A drop-down list is displayed.
3. From the drop-down list, select the LAD element that you want to use to replace the existing
LAD element.
See also
Selecting LAD elements (Page 1100)
Copying LAD elements (Page 1101)
Cutting LAD elements (Page 1102)
Pasting an LAD element from the clipboard (Page 1102)
Inserting additional inputs and outputs in LAD elements (Page 1104)
Removing inputs and outputs (Page 1105)
Deactivating and activating EN/ENO mechanisms (Page 1105)
Deleting LAD elements (Page 1106)
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
System Manual, 01/2013, 1103
Inserting additional inputs and outputs in LAD elements
Introduction
You can expand LAD elements which execute commutative arithmetic instructions by adding
additional inputs. Such elements are, for example, the instructions "Add" (ADD) and "Multiply"
(MUL). You can expand the MOVE and DEMUX instruction boxes by adding additional outputs.
Requirement
An LAD element is available that permits the insertion of additional inputs and outputs.
Inserting an additional input
To add an additional input to the box of a LAD element, follow these steps:
1. Right-click on an existing input of the LAD element.
2. Select "Insert input" in the shortcut menu.
An additional input is added to the box of the LAD element.
Or:
1. Click on the yellow star symbol beside the last input in the instruction box.
An additional input is added to the box of the LAD element.
Inserting an additional output
To add an additional output to the box of a LAD element, follow these steps:
1. Right-click on an existing output of the LAD element.
2. Select "Insert output" from the shortcut menu.
An additional output is added to the box of the LAD element.
Or:
1. Click on the yellow star symbol beside the last input in the instruction box.
An additional output is added to the box of the LAD element.
See also
Selecting LAD elements (Page 1100)
Copying LAD elements (Page 1101)
Cutting LAD elements (Page 1102)
Pasting an LAD element from the clipboard (Page 1102)
Replacing LAD elements (Page 1103)
Removing inputs and outputs (Page 1105)
Deactivating and activating EN/ENO mechanisms (Page 1105)
Deleting LAD elements (Page 1106)
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
1104 System Manual, 01/2013,
Removing inputs and outputs
Introduction
Inputs and outputs which you have added to an instruction can be removed.
Requirement
An LAD element is available to which you have added additional inputs and outputs.
Remove input
To remove an input, follow these steps:
1. Select the input that you want to remove.
2. Select the "Delete" command in the shortcut menu.
The input of the LAD element is removed.
Remove output
To remove an output, follow these steps:
1. Select the output that you want to remove.
2. Select the "Delete" command in the shortcut menu.
The output of the LAD element will be removed.
See also
Selecting LAD elements (Page 1100)
Copying LAD elements (Page 1101)
Cutting LAD elements (Page 1102)
Pasting an LAD element from the clipboard (Page 1102)
Replacing LAD elements (Page 1103)
Inserting additional inputs and outputs in LAD elements (Page 1104)
Deactivating and activating EN/ENO mechanisms (Page 1105)
Deleting LAD elements (Page 1106)
Deactivating and activating EN/ENO mechanisms
Specific instructions in LAD and FBD have an enable input EN and an enable output ENO.
You can use the enable output ENO to query runtime errors in instructions and react to these.
You can enhance CPU performance by dispensing of the use of the ENO enable output of an
instruction. However, you can then no longer use the ENO value to react to runtime errors of
the instruction.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
System Manual, 01/2013, 1105
The EN/ENO mechanism can be deactivated separately for each instruction. If you deactivate
the EN/ENO mechanism for an instruction, any other instruction that you drag-and-drop to your
program is also inserted without enable output ENO. You may always reactivate the
mechanism if you want to use the evaluation of ENO again for an instruction. Further
instructions that you drag-and-drop to your program will also be inserted again with ENO
enable output.
See also: Basics of the EN/ENO mechanism (Page 987)
Deactivating the EN/ENO mechanism
Proceed as follows to deactivate the EN/ENO mechanism of an instruction:
1. In your program, right-click the instruction at which you want to deactivate the EN/ENO
mechanism.
2. Select the "Do not generate ENO" command from the shortcut menu.
The ENO value is no longer generated for the instruction. Other instructions are inserted
without enable output.
Activating the EN/ENO mechanism
Proceed as follows to activate the EN/ENO mechanism of an instruction:
1. In your program, right-click the instruction at which you want to activate the EN/ENO
mechanism.
2. Select the "Generate ENO" command from the shortcut menu.
The ENO value is again generated for the instruction. Other instructions are inserted with
the enable output.
See also
Selecting LAD elements (Page 1100)
Copying LAD elements (Page 1101)
Cutting LAD elements (Page 1102)
Pasting an LAD element from the clipboard (Page 1102)
Replacing LAD elements (Page 1103)
Inserting additional inputs and outputs in LAD elements (Page 1104)
Removing inputs and outputs (Page 1105)
Deleting LAD elements (Page 1106)
Deleting LAD elements
Requirement
An LAD element is available.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
1106 System Manual, 01/2013,
Procedure
To delete a LAD element, follow these steps:
1. Right-click the LAD element that you want to delete.
2. Select the "Delete" command in the shortcut menu.
See also
Selecting LAD elements (Page 1100)
Copying LAD elements (Page 1101)
Cutting LAD elements (Page 1102)
Pasting an LAD element from the clipboard (Page 1102)
Replacing LAD elements (Page 1103)
Inserting additional inputs and outputs in LAD elements (Page 1104)
Removing inputs and outputs (Page 1105)
Deactivating and activating EN/ENO mechanisms (Page 1105)
Inserting operands into LAD instructions
Inserting operands
The character strings "<???>", "<??.?>" and "..." are inserted as placeholders for the
parameters when an LAD element is inserted. The "<???>" and "<??.?>" strings displayed in
red indicate parameters that need to be connected. The "..." string displayed in black indicates
parameters that may be connected. "<??.?>" stands for Boolean placeholders.
Note
If you position the cursor over the placeholder, the expected data type will be displayed.
Requirement
An LAD element is available.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
System Manual, 01/2013, 1107
Procedure
To connect the parameters of a LAD element, follow these steps:
1. Double-click the placeholder of the parameter.
An entry field opens, and the placeholder is selected.
2. Enter the appropriate parameter.
Note
If you enter the absolute address of a parameter that has already been defined, this
absolute address will be changed to the symbolic name of the parameter as soon as the
input is confirmed. If you have not yet defined the parameter, a new tag with this absolute
address and the default name "Tag_<n>" will be entered in the PLC tag table. When you
confirm your input, the absolute address will be replaced with the symbolic name
"Tag_<n>".
3. Confirm the parameter with the Enter key.
4. If you have not yet defined the parameter, you can define it directly in the program editor
using the shortcut menu.
See also:
Declaring PLC tags in the program editor (Page 1001)
Declaring local tags in the program editor (Page 1060)
Or drag from it the PLC tag table:
1. In the project tree, select the "PLC tags" folder or open the PLC tag table.
2. If you have opened the PLC tag table, drag the symbol from the first column of the desired
tag to the appropriate place in your program. If you have not opened the PLC tag table yet,
open the detail view now. Drag the desired tag from the detail view to the appropriate place
in your program.
Or drag from it the block interface:
1. Open the block interface.
2. Drag the required operand from the block interface to the instruction window.
Result
If the syntax is error-free, the displayed parameter is black. The editor then jumps to the
next placeholder.
If there is an error in the syntax, the cursor stays in the entry field and a corresponding error
message is displayed in the status line. If you press the Enter key again, the entry field is
closed and the faulty entry is displayed in red italics.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
1108 System Manual, 01/2013,
Wiring hidden parameters
Introduction
Depending on the CPU used, you can use complex instructions in your program that are
dispatched with the TIA portal. These instructions can contain parameters that are declared
as hidden.
If an instruction contains hidden parameters, the instruction box has a small arrow on the lower
edge. You can recognize hidden parameters by their white font.
You can show and wire the hidden parameters at any time.
Showing or hiding hidden parameters
To show or hide hidden parameters, follow these steps:
1. Click on the down arrow at the bottom edge of the instruction box to show hidden
parameters.
2. Click on the up arrow at the bottom edge of the instruction box to hide hidden parameters.
Wiring hidden parameters
To wire parameters, follow these steps:
1. Wire the hidden parameters like normally visible parameters.
The hidden parameter is transformed into a visible parameter.
See also
Using libraries (Page 297)
Displaying or hiding variable information
Introduction
You can display the following information about the tags to be used in the programming editor:
Name of the tags
Address of the tags
Comments to document the tags
The information is taken from the block interface for local tags and DB tags and from the PLC
tag table for tags that are valid CPU-wide.
You can display the tag information either for all the blocks or for individually opened blocks.
If you display the tag information for all the blocks, the tag information for all the blocks currently
opened and opened in future is shown.
You can hide the tag information at any time again. If you hidden the tag information for all the
blocks, you display it again for individual ones that are opened.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
System Manual, 01/2013, 1109
Displaying or hiding tag information for all the blocks
Proceed as follows to display or hide the tag information for all the blocks:
1. Select the "Settings" command in the "Options" menu.
The "Settings" window is displayed in the work area.
2. In the area navigation, select the "PLC programming" group.
3. If you want to display the tag information activate the check box "With tag information" in
the "View" section. If you want to hide the tag information, clear the "With tag information"
check box.
The tag information is displayed or hidden for all the blocks. When you open further blocks,
the tag information is displayed or not displayed depending on the selected setting.
Displaying or hiding tag information for an opened block
Proceed as follows to display or hide the tag information for an opened block:
1. Activate or deactivate the "Tag information" check box in the menu "View > Display with"
or click the "Tag information on/off" button in the toolbar.
The tag information is displayed or hidden.
Branches in LAD
Basic information on branches in LAD
Definition
You use branches to program parallel circuits with the Ladder Logic (LAD) programming
language. Branches are inserted in the main rung. You can insert several contacts into the
branch and thus achieve a parallel circuit of series connections. This allows you to program
complex ladder logic.
The figure below shows an example of the use of branches:
R
#MOTOR
#S2
#S4
#S5
MOTOR carries signal 1, if one of the following conditions is fulfilled:
Signal 1 is pending on S2 or S4
Signal 0 is pending on S5.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
1110 System Manual, 01/2013,
See also
Rules for branches in LAD (Page 1111)
Inserting branches into the LAD network (Page 1111)
Closing branches in the LAD network (Page 1112)
Deleting branches in LAD networks (Page 1112)
Rules for branches in LAD
Rules
The following rules apply to simultaneous branches:
A simultaneous branch can only be inserted if the main branch already contains an LAD
element.
Simultaneous branches are opened downwards or are connected directly to the power rail.
They are terminated upwards.
Simultaneous branches are opened after the selected LAD element.
Simultaneous branches are terminated after the selected LAD element.
To delete a simultaneous branch, you must delete all LAD elements of this branch. When
the last LAD element is removed from the branch, the rest of the branch is also removed.
See also
Basic information on branches in LAD (Page 1110)
Inserting branches into the LAD network (Page 1111)
Deleting branches in LAD networks (Page 1112)
Closing branches in the LAD network (Page 1112)
Inserting branches into the LAD network
You can create several branches in a network.
Requirement
A network is available.
The network contains elements.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
System Manual, 01/2013, 1111
Procedure
To insert a new branch in a network, follow these steps:
1. Open the "Instructions" task card.
2. Navigate to "General > Open branches" in the "Simple instructions" palette.
3. Use drag-and-drop to move the element to the desired place in the network.
If you want to connect the new branch directly to the power rail, drag the element to the
power rail.
See also
Basic information on branches in LAD (Page 1110)
Rules for branches in LAD (Page 1111)
Deleting branches in LAD networks (Page 1112)
Closing branches in the LAD network
Branches must be closed again at suitable places. If necessary, branches will be arranged so
that they do not cross each other.
Requirement
A branch is available.
Procedure
To close an open branch, follow these steps:
1. Select the open branch.
2. Press and hold down the left mouse button.
A dashed line will appear as soon as the cursor is moved.
3. Drag the dashed line to a suitable place on the network. Permissible connections are
indicated by green lines.
4. Release the left mouse button.
See also
Basic information on branches in LAD (Page 1110)
Rules for branches in LAD (Page 1111)
Deleting branches in LAD networks
Requirement
A branch is available.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
1112 System Manual, 01/2013,
Procedure
To delete a branch, follow these steps:
1. Select the connection line that links the branch to the main branch.
2. Select the "Delete" command in the shortcut menu.
See also
Basic information on branches in LAD (Page 1110)
Rules for branches in LAD (Page 1111)
Inserting branches into the LAD network (Page 1111)
Crossings in LAD
Basic information on crossings in LAD
Definition
A crossing is a place in a LAD network where one branch is closed and at the same time
another branch is opened.
Crossing
"Tagln_1" "TagOut" "Tagln_2"
"Tagln_3" "Tagln_4"
"TagOut" receives signal 1, if the following two conditions are met:
"TagIn_1" or "TagIn_3" has signal 1
"TagIn_2" or "TagIn_4" has signal 0
Inserting crossings
You can insert crossings in a LAD network by creating connections between the main branch
and an additional branch or between different branches.
Requirements
A branch is available.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
System Manual, 01/2013, 1113
Procedure
To insert a new crossing in an LAD network, follow these steps:
1. Open the "Instructions" task card.
2. Navigate to "General > Open branches" in the "Simple instructions" palette.
3. Drag the element behind the existing branch.
4. Insert any element into the open branch.
5. Click the arrow of the open branch after the inserted element.
6. Hold down the left mouse button and drag the dashed connecting line to the main branch.
7. Release the left mouse button.
See also
Rearranging crossings (Page 1114)
Deleting crossings (Page 1115)
Inserting branches into the LAD network (Page 1111)
Rearranging crossings
Requirement
A crossing is available.
Procedure
To rearrange a connection, follow these steps:
1. Select the connection line that defines the crossings in the respective branches.
2. Select the "Delete" command in the shortcut menu.
3. Open the "Instructions" task card.
4. Navigate to "General > Open branches" in the "Simple instructions" palette.
5. Use a drag-and-drop operation to move the element to the place in the network where you
want to insert the new crossing.
6. Click on the arrow for the open branch.
7. Hold down the left mouse button and drag the dashed connecting line to the subsidiary
branch in which you wish to insert the new crossing.
8. Release the left mouse button.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
1114 System Manual, 01/2013,
See also
Inserting crossings (Page 1113)
Deleting crossings (Page 1115)
Deleting crossings
Requirement
A crossing is available.
Procedure
To delete a crossing, follow these steps:
1. Select the connection line that defines the crossings in the respective branches.
2. Select the "Delete" command in the shortcut menu.
See also
Inserting crossings (Page 1113)
Rearranging crossings (Page 1114)
Rungs in LAD
Basic information on rungs in LAD
Using rungs
The program is mapped in one or more networks. A network contains a power rail on the left
where one or more rungs originate. The binary signal scans are arranged in the form of contacts
on the rungs. The serial arrangement of the elements on a rung creates a series connection;
arrangement on simultaneous branches creates a parallel connection. A rung is closed by a
coil or a box in which the result of logic operation will be written.
The figure below shows an example of the use of several rungs within a network:
"StartSwitch_Left"
"StartSwitch_Right"
S
R
"StopSwitch_Left"
"StopSwitch_Right"
"MOTOR_ON"
"MOTOR_ON"
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
System Manual, 01/2013, 1115
Rules
Remember the following rules when using several rungs:
Connections are not permitted between rungs.
Only one jump instruction is permissible per network. The positioning rules for jump
instructions remain valid.
Running rungs
Rungs and networks are executed from top to bottom and from left to right. This means that
the first instruction in the first rung of the first network is processed first. All instructions of this
rung are then processed. After this come all other rungs of the first network. The next network
is processed only after all rungs have first been run.
Differences between branches and rungs
The difference between branches and rungs is that the rungs are independent branches that
can also stand in a different network. Branches, on the other hand, permit the programming
of a parallel connection.
See also
Insert rung (Page 1116)
Deleting a rung (Page 1117)
Insert rung
Requirement
A block is open.
A network is available.
Procedure
To insert a new rung in a network, proceed as follows:
1. Insert any coil on the power rail.
A new rung will be inserted and the coil positioned at the end of the rung.
2. Insert additional instructions in the new rung.
See also
Basic information on rungs in LAD (Page 1115)
Deleting a rung (Page 1117)
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
1116 System Manual, 01/2013,
Deleting a rung
Requirement
A rung is available.
Procedure
To delete a rung, proceed as follows:
1. Hold down the left mouse button and draw a frame around the rung. At the same time,
make sure that you select all instructions. Alternatively, you can hold down the <Shift> key
and select the first the last instruction of the rung.
2. Right-click on one of the instructions in the rung.
3. Select the "Delete" command in the shortcut menu.
See also
Basic information on rungs in LAD (Page 1115)
Insert rung (Page 1116)
Creating FBD programs
Basic information on FBD
FBD programming language
Overview of the Function Block Diagram (FBD) programming language
FBD is a graphical programming language. The representation is based on electronic circuit
systems.
The program is mapped in one or more networks. A network contains one or more logic
operation paths. The binary signal scans are linked by boxes. The representation of the logic
is based on the graphical logic symbols used in Boolean algebra.
Example of networks in FBD
The following figure shows an FBD network with AND and OR boxes and an assignment:
#Operand1
#Operand2
#Stop
#Output
Network 1
> = 1
&
=
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
System Manual, 01/2013, 1117
Overview of the FBD elements
FBD elements
An FBD program consists of separate elements that are linked by means of a binary signal
flow. Most program elements must be supplied with tags.
A FBD network is programmed from left to right.
For example, the following figure shows elements of an FBD network:
1) Binary function
2) Standard box
3) Complex box
Binary functions
You can use binary functions to query binary operands and to combine their signal states. The
following operations are examples of binary functions: "AND operation", "OR operation" and
"EXCLUSIVE OR operation".
Standard boxes:
You can use standard boxes to control binary operands, perform RLO edge detection or
execute jump functions in the program. Standard boxes generally have only one single input.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
1118 System Manual, 01/2013,
Complex boxes
Complex boxes represent program elements with complex functions. The empty box is an
exception. You can use the empty box as a placeholder in which you can select the required
instruction.
The following types of boxes are available to you in an FBD program:
Complex boxes without EN/ENO mechanism:
A box is executed independently of the signal state at the box inputs. The error status of
the processing cannot be queried.
Complex boxes with EN/ENO mechanism:
A box is only executed if the enable input "EN" has the signal state "1". If the box is
processed correctly, the "ENO" enable output has signal state "1". If an error occurs during
processing, the "ENO" output is reset.
If the EN enable input is not interconnected, the box is always executed.
Calls of code block are also shown in the network as complex boxes with EN/ENO mechanism.
Settings for FBD
Overview of the settings for FBD
Overview
The following table shows the settings that you can make:
Group Setting Description
Font Font size Font size in program editor
View Layout Compact or wide
Changes the vertical spacing between
operands and other objects (such as
operand and contact). The change
becomes visible once the block is
reopened.
With absolute information Additional display of the absolute
addresses
Operand field Maximum width Maximum number of characters that
can be entered horizontally in the
operand field. This setting recalculates
the layout of the networks.
Maximum height Maximum number of characters that
can be entered vertically in the operand
field. This setting recalculates the layout
of the networks.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
System Manual, 01/2013, 1119
See also
Changing the settings (Page 1120)
Changing the settings
Procedure
To change the settings, follow these steps:
1. Select the "Settings" command in the "Options" menu.
The "Settings" window is displayed in the work area.
2. In the area navigation, select the "PLC programming" group.
3. Change the settings.
Result
The change will be loaded directly, there is no need to save it explicitly.
See also
Overview of the settings for FBD (Page 1119)
Working with networks
Using networks
Function
The user program is created in the block within networks. For a code block to be programmed,
it must contain at least one network. To achieve a better overview of the user program, you
can also subdivide your program into several networks.
See also
Entering the network title (Page 1124)
Entering a network comment (Page 1125)
Navigating networks (Page 1126)
Inserting networks
Requirement
A block is open.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
1120 System Manual, 01/2013,
Procedure
To insert a new network, follow these steps:
1. Select the network after which you want to insert a new network.
2. Select the "Insert network" command in the shortcut menu.
Result
A new empty network is inserted into the block.
See also
Entering the network title (Page 1124)
Entering a network comment (Page 1125)
Navigating networks (Page 1126)
Selecting networks
Requirements
A network is available.
Selecting a network
To select a network, follow these steps:
1. Click the title bar of the network that you want to select.
Selecting several networks
Proceed as follows to select several individual networks:
1. Press and hold down the <Ctrl> key.
2. Click all the networks that you want to select.
To select several successive networks, follow these steps:
1. Press and hold down the <Shift> key.
2. Click the first network that you want to select.
3. Click the last network that you want to select.
The first and last networks and all those in between are selected.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
System Manual, 01/2013, 1121
See also
Inserting networks (Page 1120)
Entering the network title (Page 1124)
Entering a network comment (Page 1125)
Navigating networks (Page 1126)
Copying and pasting networks
Copied networks can be pasted within the block or in another block. Networks that were created
in LAD or FBD can also be inserted in blocks of the respective other programming language.
Requirement
A network is available.
Procedure
To copy and paste a network, follow these steps:
1. Select the network or networks to be copied.
2. Select "Copy" in the shortcut menu.
3. Select the network after which you want to paste in the copied network.
4. Select "Paste" in the shortcut menu.
See also
Inserting networks (Page 1120)
Selecting networks (Page 1121)
Entering the network title (Page 1124)
Entering a network comment (Page 1125)
Navigating networks (Page 1126)
Deleting networks
Requirement
A network is available.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
1122 System Manual, 01/2013,
Procedure
To delete a network, follow these steps:
1. Select the network that you want to delete.
2. Select the "Delete" command in the shortcut menu.
See also
Inserting networks (Page 1120)
Selecting networks (Page 1121)
Copying and pasting networks (Page 1122)
Entering the network title (Page 1124)
Entering a network comment (Page 1125)
Navigating networks (Page 1126)
Expanding and collapsing networks
Requirements
A network is available.
Opening and closing a network
To open a network, follow these steps:
1. Click on the right arrow in the network title bar.
To close a network, follow these steps:
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
System Manual, 01/2013, 1123
1. Click on the down arrow in the network title bar.
Opening and closing all networks
To open and close all networks, follow these steps:
1. In the toolbar, click "Open all networks" or "Close all networks".
See also
Inserting networks (Page 1120)
Selecting networks (Page 1121)
Copying and pasting networks (Page 1122)
Deleting networks (Page 1122)
Entering the network title (Page 1124)
Entering a network comment (Page 1125)
Navigating networks (Page 1126)
Entering the network title
The network title is the header of a network. The length of the network title is limited to one
line.
Requirement
A network is available.
Procedure
To enter a network title, follow these steps:
1. Click on the title bar of the network.
2. Enter the network title.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
1124 System Manual, 01/2013,
See also
Using networks (Page 1120)
Inserting networks (Page 1120)
Selecting networks (Page 1121)
Copying and pasting networks (Page 1122)
Deleting networks (Page 1122)
Expanding and collapsing networks (Page 1123)
Entering a network comment (Page 1125)
Navigating networks (Page 1126)
Entering a network comment
You can use network comments to provide comments on the program contents of individual
networks. For example, you can indicate the function of the network or draw attention to special
characteristics.
Requirement
A network is available.
Procedure
To enter a network comment, follow these steps:
1. Click on the right arrow before the network title.
2. If the comment area is not visible, click "Network comments on/off" in the toolbar.
The comment area is displayed.
3. Click "Comment" in the comment area.
The "Comment" text passage is selected.
4. Enter the network comment.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
System Manual, 01/2013, 1125
See also
Using networks (Page 1120)
Inserting networks (Page 1120)
Selecting networks (Page 1121)
Copying and pasting networks (Page 1122)
Deleting networks (Page 1122)
Expanding and collapsing networks (Page 1123)
Entering the network title (Page 1124)
Navigating networks (Page 1126)
Navigating networks
You can navigate straight to a specific position within a block.
Procedure
To navigate to a specific position within a block, follow these steps:
1. Right-click in the code area of the programming window.
2. Select the "Go to > Network/line" command in the shortcut menu.
The "Go to" dialog will open.
3. Enter the network to which you want to navigate.
4. Enter the line number of the network to which you want to navigate.
5. Confirm your entry with "OK".
Result
The relevant line will be displayed if this is possible. If the network or line requested does not
exist, the last existing network or the last existing line in the network requested will be displayed.
See also
Using networks (Page 1120)
Inserting networks (Page 1120)
Selecting networks (Page 1121)
Copying and pasting networks (Page 1122)
Deleting networks (Page 1122)
Expanding and collapsing networks (Page 1123)
Entering the network title (Page 1124)
Entering a network comment (Page 1125)
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
1126 System Manual, 01/2013,
Inserting FBD elements
Rules for the use of FBD elements
Rules
Note the following rules when inserting FBD elements:
An FBD network can consist of several elements. All elements of a logic path must be linked
to each other according to IEC 61131-3.
Standard boxes (flip flops, counters, timers, math operations, etc.) can be added as output
to boxes with binary logic operations (for example, AND, OR). Comparison boxes are
excluded from this rule.
Only Boolean inputs in an instruction can be combined with preceding logic operations.
Only the bottom Boolean output in an instruction can be combined with an additional logic
operation.
Enable input EN or enable output ENO can be connected to boxes, but this is not mandatory.
Constants (for example, TRUE or FALSE) cannot be assigned to binary logic operations.
Instead, use tags of the BOOL data type.
Only one jump instruction can be inserted in each network.
Only one jump label can be inserted in each network.
Instructions for positive or negative RLO edge detection may not be arranged right at the
left of the network as this requires a prior logic operation.
Placement rules for S7-1200/1500 CPUs
The following table sets out the instructions that can only be positioned at the end of the
network:
Instruction Preceding logic operation
required
Mnemonics Name
SET_BF Set bit field No
RESET_BF Reset bit field No
JMP Jump if RLO = 1 No
JMPN Jump if RLO = 0 Yes
JMP_LIST Define jump list No
SWITCH Jump distributor No
RET Return No
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
System Manual, 01/2013, 1127
Placement rules for S7-300/400 CPUs
The following table sets out the instructions that can only be positioned at the end of the
network:
Instruction Preceding logic operation
required
Mnemonic
s
Name
S Set output Yes
R Reset output Yes
SP Start pulse timer Yes
SE Start extended pulse timer Yes
SD Start on-delay timer Yes
SS Start retentive on-delay timer Yes
SF Start off-delay timer Yes
SC Set counter value Yes
CU Count up Yes
CD Count down Yes
JMP Jump if RLO = 1 No
JMPN Jump if RLO = 0 Yes
RET Return No
OPN Open global data block No
OPNI Open instance data block No
CALL Call block No
SAVE Save RLO in BR bit No
MCRA Enable MCR range No
MCRD Disable MCR range No
MCR< Open MCR ranges No
MCR> Close MCR ranges No
Inserting FBD elements using the "Instructions" task card
Requirement
A network is available.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
1128 System Manual, 01/2013,
Procedure
To insert FBD elements into a network using the "Instructions" task card, follow these steps:
1. Open the "Instructions" task card.
2. Navigate to the FBD element that you want to insert.
3. Use drag-and-drop to move the element to the desired place in the network.
If the element is an internal system function block (FB), the "Call options" dialog opens. In
this dialog you can create an instance data block of the single-instance or multiple-instance
type for the function block in which the data of the inserted element will be saved. You will
find the new instance data block created in the project tree in the "Program resources"
folder under "Program blocks > System blocks". If you have selected "multiple instance",
these are located in the block interface in the "Static" section.
Or:
1. Select the point in the network at which you want to insert the element.
2. Open the "Instructions" task card.
3. Double-click on the element you want to insert.
If the element is an internal system function block (FB), the "Call options" dialog opens. In
this dialog you can create an instance data block of the single-instance or multiple-instance
type for the function block in which the data of the inserted element will be saved. You will
find the new instance data block created in the project tree in the "Program resources"
folder under "Program blocks > System blocks". If you have selected "multiple instance",
these are located in the block interface in the "Static" section.
Result
The selected FBD element is inserted with dummy entries for the parameters.
See also
Rules for the use of FBD elements (Page 1127)
Inserting FBD elements using an empty box
Requirement
A network is available.
Procedure
To insert FBD elements into a network using an empty box, follow these steps:
1. Open the "Instructions" task card.
2. Navigate to "General > Empty box" in the "Basic instructions" palette.
3. Use a drag-and-drop operation to move the "Empty box" element to the desired place in
the network.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
System Manual, 01/2013, 1129
4. Position the cursor over the triangle in the top right-hand corner of the empty box.
A drop-down list is displayed.
5. Select the desired FBD element from the drop-down list.
If the element is an internal system function block (FB), the "Call options" dialog opens. In
this dialog you can create an instance data block of the single-instance or multiple-instance
type for the function block in which the data of the inserted element will be saved. You will
find the new instance data block created in the project tree in the "Program resources"
folder under "Program blocks > System blocks". If you have selected "multi-instance", these
are located in the block interface in the "Static" section.
Result
The empty box is changed to the respective FBD element. Placeholders are inserted for the
parameters.
Selecting the data type of an FBD element
Selecting a data type
Introduction
Some instructions can be executed with several different data types. If you use one of these
instructions in the program, you have to specify a valid data type for the instruction at the
specific point in the program. For some instructions, you have to select the data types for the
inputs and outputs separately.
Note
The valid data type (BOOL) for the tags on the enable input EN and the enable output ENO
is predefined by the system and cannot be changed.
The valid data types for an instruction are listed in the instruction drop-down list. You specify
the data type of the instruction by selecting an entry from the drop-down list. If the data type
of an operand differs from the data type of the instruction and cannot be converted implicitly,
the operand is displayed in red and a rollout with the corresponding error message appears.
Data type selection of mathematical instructions
Some mathematical instructions provide you with the option of having the data type
automatically set corresponding to the data types of the operand. In the drop-down list for data
type selection, these instructions have the entry "Auto" in addition to the actual data types. If
you select this entry and then allocate the first operand, the data type of the operand is selected
as data type for the instruction. The entry in the drop-down list changes to "Auto (<Data type>)",
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
1130 System Manual, 01/2013,
e.g. "Auto (Real)". If you allocate additional operands, the automatically set data type of the
instruction is adjusted according to the following criteria:
You supply all other operands with tags of the same data type:
The data type of the instruction is not changed.
You supply all other operands with tags whose data type is smaller than the data type of
the instruction:
The data type of the instruction is not changed. For the operand with the smaller data type,
an implicit conversion is conducted if necessary.
You supply an additional operand with a tag whose data type is greater than the data type
of the instruction:
The data type of the instruction is changed to the larger data type. An implicit conversion
is performed, if necessary, for operands that deviate from the newly set data type of the
instruction.
Each change in the data type of an operand can result in a change of the data type of the
instruction. Other operands may possibly be implicitly converted as a result. Operands for
which an implicit conversion is performed are marked with a gray square.
Note
Please also observe the information on data type conversion for your device and, in particular,
the notes on the IEC check.
See also: Data type conversion
See also
Defining the data type of an instruction (Page 1131)
Defining the data type of an instruction
Introduction
Some instructions can be executed with several different data types. When you insert such
instructions into your program, you must specify the data type for these instructions at the
actual point in the program.
Specifying the data type by means of the drop-down list
To define the data type of an instruction using the drop-down list, follow these steps:
1. Insert the instruction at the required point in the program using drag-and-drop.
The entry "???" (undefined) is displayed in the drop-down list of the inserted instruction.
2. Click the triangle in the upper corner of the drop-down list.
The drop-down list will open to display the data types valid for the instruction.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
System Manual, 01/2013, 1131
3. Select a data type from the drop-down list.
The selected data type is displayed.
4. If the instruction has two drop-down lists, select the data type for the instruction inputs in
the left-hand drop-down list and the data type for the instruction outputs in the right-hand
drop-down list.
Specifying data type by assigning tags
To define the data type of an instruction by assigning tags, follow these steps:
1. Insert the instruction at the required point in the program using drag-and-drop.
The entry "???" (undefined) is displayed in the drop-down list of the inserted instruction.
2. At an input or output, specify a valid tag, the data type of which is to be applied as the
instruction data type.
The data type of the tag is displayed in the drop-down list.
3. Enter a valid tag at an input and a valid tag at an output if data types need to be defined
for both the inputs and outputs of the instruction. The tag specified at the input determines
the data type of the inputs; the tag specified at the output determines the data type of the
outputs of the instruction.
Automatically specifying the data type of mathematical instructions
To automatically specify the data type for mathematical instructions, follow these steps:
1. Insert the mathematical instruction at the required point in the program using drag-and-drop.
The entry "???" (undefined) is displayed in the drop-down list of the inserted instruction.
2. Select the "Auto" entry from the drop-down list.
3. Enter a valid tag at an input or output.
The data type of the tag is applied as data type of the instruction. The entry in the drop-
down list changes to "Auto (<Data type>)".
See also: Selecting a data type (Page 1130)
See also
Selecting a data type (Page 1130)
Using favorites in FBD
Adding FBD elements to Favorites
Requirement
A block is open.
The multipane mode is set for the "Instructions" task card or the Favorites are also displayed
in the editor.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
1132 System Manual, 01/2013,
Procedure
To add SCL instructions to the Favorites, follow these steps:
1. Open the "Instructions" task card.
2. Maximize the "Basic instructions" pane.
3. Navigate in the "Basic instructions" pane to the instruction that you want to add to the
Favorites.
4. Drag-and-drop the instruction into the "Favorites" pane or into the Favorites area in the
program editor.
Note
To additionally display the Favorites in the program editor, click the "Display favorites in the
editor" button in the program editor toolbar.
See also
Removing FBD elements from Favorites (Page 1134)
Overview of the program editor (Page 1034)
Inserting FBD elements using favorites
Requirement
A block is open.
Favorites are available.
Procedure
To insert an instruction into a program using Favorites, follow these steps:
1. Drag-and-drop the desired instruction from Favorites to the desired position.
Or:
1. Select the position in the program where you want to insert the instruction.
2. In the Favorites, click on the instruction you want to insert.
Note
To additionally display the Favorites in the program editor, click the "Display favorites in the
editor" button in the program editor toolbar.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
System Manual, 01/2013, 1133
See also
Overview of the program editor (Page 1034)
Removing FBD elements from Favorites (Page 1134)
Removing FBD elements from Favorites
Requirement
A code block is open.
Procedure
To remove instructions from Favorites, follow these steps:
1. Right-click on the instruction you want to remove.
2. Select the "Remove instruction" command in the shortcut menu.
Note
To additionally display the Favorites in the program editor, click the "Display favorites in the
editor" button in the program editor toolbar.
See also
Adding FBD elements to Favorites (Page 1132)
Inserting FBD elements using favorites (Page 1133)
Overview of the program editor (Page 1034)
Inserting block calls in FBD
Inserting block calls using a drag-and-drop operation
You can insert calls for existing functions (FC) and function blocks (FB) using a drag-and-drop
operation from the project tree. If you call function blocks from other function blocks, you can
either call them as single-instance or multi-instance blocks. If a function block is called as single
instance, it will store its data in a data block of its own. If a function block is called as multi-
instance, it will store its data in the instance data block of the calling function block.
Requirement
A network is available.
The block that is to be called is available.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
1134 System Manual, 01/2013,
Inserting a call of a function (FC)
To insert a call of a function (FC) into a network using a drag-and-drop operation, follow these
steps:
1. Drag the function from the project tree to the required network.
Inserting a call for a function block (FB)
To insert a call for a function block (FB), follow these steps:
1. Drag the function block from the project tree to the required network.
The "Call options" dialog opens.
2. Enter in the dialog whether you wish to call the block as single or multi-instance.
If you click on the "Single instance" button, you will have to enter a name in the "Name"
text box for the data block that you want to assign to the function block.
If you click on the "Multi-instance" button, you will have to enter the name of the tag in
the "Name in the interface" text box; this is the name that you use to enter the called
function block as a static tag in the interface of the calling block.
3. Confirm your entries with "OK".
Result
The function or the function block is inserted with its parameters. You can then assign the
parameters.
See also: Auto-Hotspot
Note
If when calling a function block you specify an instance data block that does not exist, it will
be created. If you have called a function block as a multi-instance, this will be entered as a
static tag in the interface.
See also
Updating block calls in FBD (Page 1135)
Changing the instance type (Page 1136)
Single instances (Page 858)
Multi-instances (Page 859)
Updating block calls in FBD
If interface parameters of a called block are changed, the block call can no longer be executed
correctly. You can avoid such inconsistent block calls by updating the block calls.
You have two options to update the block calls:
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
System Manual, 01/2013, 1135
Explicit updating in the program editor.
The block calls in the open block will be updated.
Implicit updating during compilation.
All block calls in the program as well as the used PLC data types will be updated.
Update blocks in the program editor
To update a block call within a block, follow these steps:
1. Open the block in the program editor.
2. Click "Update inconsistent block calls" in the toolbar.
Or:
1. Open the block in the program editor.
2. Right-click on the instruction with the block call.
3. Select the "Update" command in the shortcut menu.
The "Interface update" dialog opens. This dialog shows the differences between the block
interface in use and the changed interface of the called block.
4. If you want to update the block call, click "OK". To cancel the update, click "Cancel".
Update block calls during compilation
Follow these steps to update all block calls and uses of PLC data types during compilation
implicitly:
1. Open the project tree.
2. Select the "Program blocks" folder.
3. Select the command "Compile > Software (rebuild all blocks)" in the shortcut menu.
See also
Inserting block calls using a drag-and-drop operation (Page 1134)
Changing the instance type (Page 1136)
Changing the instance type
Instance type
There are two ways of calling function blocks:
As a single instance
As a multiple instance
See also: Auto-Hotspot
You can modify a defined instance type at any time.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
1136 System Manual, 01/2013,
Requirement
The user program contains a block call.
Procedure
To change the instance type of a function block, follow these steps:
1. Open the code block and select the block call.
2. Select the "Change instance" command in the shortcut menu.
The "Call options" dialog opens.
3. Click the "Single instance" or "Multi instance" button.
If you select the "Single instance" instance type, enter a name for the data block that is
to be assigned to the function block.
If you select "Multiple instance" as the instance type, enter in the "Name in the interface"
text field the name of the tag with which the called function block is to be entered as a
static tag in the interface of the calling block.
4. Confirm your entries with "OK".
Note
The previous single and multiple instances will not be deleted automatically.
See also
Inserting block calls using a drag-and-drop operation (Page 1134)
Updating block calls in FBD (Page 1135)
Inserting complex FBD instructions
Using the "Calculate" instruction
Requirement
A network is available.
Procedure
Proceed as follows to use the "Calculate" instruction:
1. Open the "Instructions" task card.
2. Navigate to "Math functions > CALCULATE" in the "Basic instructions" pane.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
System Manual, 01/2013, 1137
3. Use drag-and-drop to move the element to the desired place in the network.
The instruction "Calculate" will be inserted for the data type with a placeholder expression
and question mark.
4. Enter the data type for the calculation.
5. Enter the operands for the calculation.
Note
The calculation is run with the inputs of the "Calculate" instruction. If you want to use
constants you must also insert appropriate inputs for them.
6. Click on the "Edit 'Calculate' instruction" button to replace the placeholder expression with
the correct expression.
The "Edit 'Calculate' instruction" dialog will open.
7. Enter the required expression in the "OUT:= " text box.
Note
In the "Example" area you can find an example of a valid expression and possible
instructions that you can use.
To determine a value with the help of Pythagoras' theorem, for example, enter "OUT :=
SQRT (SQR (IN1) + SQR (IN2))".
8. Confirm your entry with "OK".
See also
CALCULATE: Calculate (Page 1757)
Using free-form comments
Basic information on using free comments in FBD
Introduction
Free-form comments allow you to add comments to the source code for graphic programming
languages similar to line comments for textual languages.
Free-form comments can be used for all non-binary boxes.
See also
Inserting free-form comments (Page 1139)
Editing free-form comments (Page 1139)
Deleting free-form comments (Page 1140)
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
1138 System Manual, 01/2013,
Inserting free-form comments
Requirement
A network with instructions is available.
Procedure
To insert a free comment on an instruction, proceed as follows:
1. If necessary, activate the "Free-form comments on/off" button in the toolbar.
2. Right-click on the instruction for which you want to insert a free-form comment.
3. Select the "Insert comment" command in the shortcut menu.
A comment box with a standard comment opens. The comment box is connected by an
arrow to the corresponding instruction.
4. Enter the required comment in the comment box.
See also
Basic information on using free comments in FBD (Page 1138)
Editing free-form comments (Page 1139)
Deleting free-form comments (Page 1140)
Editing free-form comments
Introduction
Free-form comments can be edited as follows:
Changing the comment text
Changing the position and size of the comment box
Attaching a comment to another element
Showing and hiding free comments
Changing the comment text
To change the text of free-form comments, follow these steps:
1. Click on the comment box.
2. Enter the desired text.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
System Manual, 01/2013, 1139
Changing the position of the comment box
To change the positioning of the comment box, follow the steps below:
1. Left-click the comment box and keep the mouse button pressed.
2. Drag the comment box to the desired location.
Changing the size of the comment box
To change the size of the comment box, follow the steps below:
1. Click on the comment box.
2. Drag the comment box on the move handle in the lower right corner to the desired size.
Attaching a comment to another element
To attach a free-form comment to another element, follow these steps:
1. Left-click the point of the arrow that links the comment box with the instruction and keep
the mouse button pressed.
2. Drag the arrow to the element to which you want to attach the comment. Possible insertion
points are marked with a green square.
3. Release the mouse button.
Showing and hiding free comments
To show or hide a free-form comments, follow these steps:
1. Click the "Free-form comment on/off" button in the toolbar.
See also
Basic information on using free comments in FBD (Page 1138)
Inserting free-form comments (Page 1139)
Deleting free-form comments (Page 1140)
Deleting free-form comments
Procedure
To delete a free-form comment, proceed as follows:
1. Right-click on the free-form comment that you want to delete.
2. Select the "Delete" command in the shortcut menu.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
1140 System Manual, 01/2013,
See also
Basic information on using free comments in FBD (Page 1138)
Inserting free-form comments (Page 1139)
Editing free-form comments (Page 1139)
Editing FBD elements
Selecting FBD elements
You can select several individual elements or all elements in a network.
Requirement
FBD elements are available
Selecting several individual FBD elements
To select several individual FBD elements, follow these steps:
1. Press and hold down the <Ctrl> key.
2. Click on all the FBD elements you wish to select.
3. Now release the <Ctrl> key.
Selecting all FBD elements in a network
To select all FBD elements in a network, follow these steps:
1. Go to the network whose elements you wish to select.
2. Select the "Select all" command in the "Edit" menu or press <Ctrl+A>.
See also
Copying FBD elements (Page 1142)
Cutting FBD elements (Page 1142)
Pasting an FBD element from the clipboard (Page 1143)
Replacing FBD elements (Page 1143)
Adding additional inputs and outputs to FBD elements (Page 1144)
Removing instruction inputs and outputs (Page 1145)
Deactivating and activating EN/ENO mechanisms (Page 1146)
Deleting FBD elements (Page 1147)
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
System Manual, 01/2013, 1141
Copying FBD elements
Requirement
An FBD element is available.
Procedure
To copy an FBD element, follow these steps:
1. Right-click the FBD element that you want to copy.
2. Select "Copy" in the shortcut menu.
Result
The FBD element will be copied and saved to the clipboard.
See also
Selecting FBD elements (Page 1141)
Cutting FBD elements (Page 1142)
Pasting an FBD element from the clipboard (Page 1143)
Replacing FBD elements (Page 1143)
Adding additional inputs and outputs to FBD elements (Page 1144)
Removing instruction inputs and outputs (Page 1145)
Deactivating and activating EN/ENO mechanisms (Page 1146)
Deleting FBD elements (Page 1147)
Cutting FBD elements
Requirement
An FBD element is available.
Cutting
To cut an FBD element, follow these steps:
1. Right-click the FBD element that you want to cut.
2. Select "Cut" in the shortcut menu.
Result
The FBD element will be cut and saved to the clipboard.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
1142 System Manual, 01/2013,
See also
Selecting FBD elements (Page 1141)
Copying FBD elements (Page 1142)
Pasting an FBD element from the clipboard (Page 1143)
Replacing FBD elements (Page 1143)
Adding additional inputs and outputs to FBD elements (Page 1144)
Removing instruction inputs and outputs (Page 1145)
Deactivating and activating EN/ENO mechanisms (Page 1146)
Deleting FBD elements (Page 1147)
Pasting an FBD element from the clipboard
Requirement
An FBD element is available.
Procedure
To paste an FBD element from the clipboard, follow these steps:
1. Copy an FBD element or cut an FBD element.
2. Right-click the point in the network where you want to paste the element.
3. Select "Paste" in the shortcut menu.
See also
Selecting FBD elements (Page 1141)
Copying FBD elements (Page 1142)
Cutting FBD elements (Page 1142)
Replacing FBD elements (Page 1143)
Adding additional inputs and outputs to FBD elements (Page 1144)
Removing instruction inputs and outputs (Page 1145)
Deactivating and activating EN/ENO mechanisms (Page 1146)
Deleting FBD elements (Page 1147)
Replacing FBD elements
You can easily exchange FBD elements with other FBD elements of the same type. This has
the advantage that the parameters are retained and need not be entered again. For example,
you can exchange OR and AND, RS-FlipFlop and SR-FlipFlop, comparison functions or jump
instructions.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
System Manual, 01/2013, 1143
Requirements
A network with at least one FBD element is present.
Procedure
To replace an FBD element with another FBD element, follow these steps:
1. Select the FBD element that you want to replace.
If elements compatible with the selected FBD element are available, a triangle will appear
in the upper right-hand corner of the element.
2. Position the cursor above the triangle of the FBD element.
A drop-down list is displayed.
3. From the drop-down list, select the FBD element that you want to use to replace the existing
FBD element.
See also
Selecting FBD elements (Page 1141)
Copying FBD elements (Page 1142)
Cutting FBD elements (Page 1142)
Pasting an FBD element from the clipboard (Page 1143)
Adding additional inputs and outputs to FBD elements (Page 1144)
Removing instruction inputs and outputs (Page 1145)
Deactivating and activating EN/ENO mechanisms (Page 1146)
Deleting FBD elements (Page 1147)
Adding additional inputs and outputs to FBD elements
Introduction
You can expand several FBD elements with additional inputs that execute arithmetic or binary
operations. Such elements are, for example, the instructions "Add" (ADD), "Multiply" (MUL),
AND or OR. You can expand the "MOVE value" (MOVE) and "Demultiplex" (DEMUX)
instruction boxes by adding additional outputs.
The name of the new inputs and outputs is comprised of the type of inserted element and a
consecutive number. The name of a new input is may be "IN2"; the name of a new output may
be "OUT2".
Requirements
An FBD element is available that permits the insertion of additional inputs and outputs.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
1144 System Manual, 01/2013,
Inserting an additional input
To add an additional input to the box of an FBD element, follow these steps:
1. Right-click on an existing input of the FBD element.
2. Select "Insert input" in the shortcut menu.
An additional input is added to the box of the FBD element.
Or:
1. Click on the yellow star symbol beside the last input in the instruction box.
An additional input is added to the box of the FBD element.
Inserting an additional output
To add an additional output to the box of an FBD element, follow these steps:
1. Right-click on an existing output of the FBD element.
2. Select "Insert output" from the shortcut menu.
An additional output is added to the box of the FBD element.
Or:
1. Click on the yellow star symbol beside the last output of the instruction box.
An additional output is added to the box of the FBD element.
See also
Selecting FBD elements (Page 1141)
Copying FBD elements (Page 1142)
Cutting FBD elements (Page 1142)
Pasting an FBD element from the clipboard (Page 1143)
Replacing FBD elements (Page 1143)
Removing instruction inputs and outputs (Page 1145)
Deactivating and activating EN/ENO mechanisms (Page 1146)
Deleting FBD elements (Page 1147)
Removing instruction inputs and outputs
Introduction
Inputs and outputs which you have added to an instruction can be removed.
Requirement
An FBD element is available, which you have expanded with additional inputs or outputs.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
System Manual, 01/2013, 1145
Remove input
To remove an input, follow these steps:
1. Select the input that you want to remove.
2. Select the "Delete" command in the shortcut menu.
The input of the FBD element is removed.
Remove output
To remove an output, follow these steps:
1. Select the output that you want to remove.
2. Select the "Delete" command in the shortcut menu.
The output of the FBD element will be removed.
See also
Selecting FBD elements (Page 1141)
Copying FBD elements (Page 1142)
Cutting FBD elements (Page 1142)
Pasting an FBD element from the clipboard (Page 1143)
Replacing FBD elements (Page 1143)
Adding additional inputs and outputs to FBD elements (Page 1144)
Deactivating and activating EN/ENO mechanisms (Page 1146)
Deleting FBD elements (Page 1147)
Deactivating and activating EN/ENO mechanisms
Specific instructions in LAD and FBD have an enable input EN and an enable output ENO.
You can use the enable output ENO to query runtime errors in instructions and react to these.
You can enhance CPU performance by dispensing of the use of the ENO enable output of an
instruction. However, you can then no longer use the ENO value to react to runtime errors of
the instruction.
The EN/ENO mechanism can be deactivated separately for each instruction. If you deactivate
the EN/ENO mechanism for an instruction, any other instruction that you drag-and-drop to your
program is also inserted without enable output ENO. You may always reactivate the
mechanism if you want to use the evaluation of ENO again for an instruction. Further
instructions that you drag-and-drop to your program will also be inserted again with ENO
enable output.
See also: Basics of the EN/ENO mechanism (Page 987)
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
1146 System Manual, 01/2013,
Deactivating the EN/ENO mechanism
Proceed as follows to deactivate the EN/ENO mechanism of an instruction:
1. In your program, right-click the instruction at which you want to deactivate the EN/ENO
mechanism.
2. Select the "Do not generate ENO" command from the shortcut menu.
The ENO value is no longer generated for the instruction. Other instructions are inserted
without enable output.
Activating the EN/ENO mechanism
Proceed as follows to activate the EN/ENO mechanism of an instruction:
1. In your program, right-click the instruction at which you want to activate the EN/ENO
mechanism.
2. Select the "Generate ENO" command from the shortcut menu.
The ENO value is again generated for the instruction. Other instructions are inserted with
the enable output.
See also
Selecting FBD elements (Page 1141)
Copying FBD elements (Page 1142)
Cutting FBD elements (Page 1142)
Pasting an FBD element from the clipboard (Page 1143)
Replacing FBD elements (Page 1143)
Adding additional inputs and outputs to FBD elements (Page 1144)
Removing instruction inputs and outputs (Page 1145)
Deleting FBD elements (Page 1147)
Deleting FBD elements
Requirement
An FBD element is available.
Procedure
To delete an FBD element, follow these steps:
1. Right-click the FBD element that you want to delete.
2. Select the "Delete" command in the shortcut menu.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
System Manual, 01/2013, 1147
See also
Selecting FBD elements (Page 1141)
Copying FBD elements (Page 1142)
Cutting FBD elements (Page 1142)
Pasting an FBD element from the clipboard (Page 1143)
Replacing FBD elements (Page 1143)
Adding additional inputs and outputs to FBD elements (Page 1144)
Removing instruction inputs and outputs (Page 1145)
Deactivating and activating EN/ENO mechanisms (Page 1146)
Inserting operands in FBD instructions
Inserting operands
The character strings "<???>", "<??.?>" and "..." are inserted as placeholders for the
parameters when a FBD element is inserted. The "<???>" and "<??.?>" strings displayed in
red indicate parameters that need to be connected. The "..." string displayed in black indicates
parameters that may be connected. "<??.?>" stands for Boolean placeholders.
Note
To display the available data types in a tooltip, move the cursor over the placeholder.
Requirement
An FBD element is available.
Procedure
To connect the parameters of an FBD element, follow these steps:
1. Click the placeholder of the parameter.
An input field is opened.
2. Enter the corresponding parameters, for example a PLC tag, a local tag or a constant.
Note
If you enter the absolute address of a parameter that has already been defined, this
absolute address will be changed to the symbolic name of the parameter as soon as the
input is confirmed. If you have not yet defined the parameter, a new tag with this absolute
address and the default name "Tag_1" will be entered in the PLC tag table. When you
confirm your input, the absolute address will be replaced with the symbolic name "Tag_1".
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
1148 System Manual, 01/2013,
3. Confirm the parameter with the Enter key.
4. If you have not yet defined the parameter, you can define it directly in the program editor
using the shortcut menu.
See also: "Declaring PLC tags in the program editor (Page 1001)".
Or drag from it the PLC tag table:
1. In the project tree, select the "PLC tags" folder and open the PLC tag table.
2. If you have opened the PLC tag table, drag the desired tag to the corresponding location
in your program. If you have not opened the PLC tag table yet, open the detail view now.
Drag the desired tag from the detail view to the appropriate place in your program.
Or drag from it the block interface:
1. Open the block interface.
2. Drag the desired operand from the block interface to the corresponding location in your
program.
Result
If the syntax is error-free, the displayed parameter is black.
If there is an error in the syntax, the cursor stays in the input field and a corresponding error
message is displayed in the inspector window in the "Info > Syntax" register.
Wiring hidden parameters
Introduction
Depending on the CPU used, you can use complex instructions in your program that are
dispatched with the TIA portal. These instructions can contain parameters that are declared
as hidden.
If an instruction contains hidden parameters, the instruction box has a small arrow on the lower
edge. You can recognize hidden parameters by their white font.
You can show and wire the hidden parameters at any time.
Showing or hiding hidden parameters
To show or hide hidden parameters, follow these steps:
1. Click on the down arrow at the bottom edge of the instruction box to show hidden
parameters.
2. Click on the up arrow at the bottom edge of the instruction box to hide hidden parameters.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
System Manual, 01/2013, 1149
Wiring hidden parameters
To wire parameters, follow these steps:
1. Wire the hidden parameters like normally visible parameters.
The hidden parameter is transformed into a visible parameter.
See also
Using libraries (Page 297)
Displaying or hiding variable information
Introduction
You can display the following information about the tags to be used in the programming editor:
Name of the tags
Address of the tags
Comments to document the tags
The information is taken from the block interface for local tags and DB tags and from the PLC
tag table for tags that are valid CPU-wide.
You can display the tag information either for all the blocks or for individually opened blocks.
If you display the tag information for all the blocks, the tag information for all the blocks currently
opened and opened in future is shown.
You can hide the tag information at any time again. If you hidden the tag information for all the
blocks, you display it again for individual ones that are opened.
Displaying or hiding tag information for all the blocks
Proceed as follows to display or hide the tag information for all the blocks:
1. Select the "Settings" command in the "Options" menu.
The "Settings" window is displayed in the work area.
2. In the area navigation, select the "PLC programming" group.
3. If you want to display the tag information activate the check box "With tag information" in
the "View" section. If you want to hide the tag information, clear the "With tag information"
check box.
The tag information is displayed or hidden for all the blocks. When you open further blocks,
the tag information is displayed or not displayed depending on the selected setting.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
1150 System Manual, 01/2013,
Displaying or hiding tag information for an opened block
Proceed as follows to display or hide the tag information for an opened block:
1. Activate or deactivate the "Tag information" check box in the menu "View > Display with"
or click the "Tag information on/off" button in the toolbar.
The tag information is displayed or hidden.
Branches in FBD
Basic information on branches in FBD
Definition
You can use the Function Block Diagram (FBD) programming language to program parallel
branches. This is done using branches that are inserted between the boxes. You can insert
additional boxes within the branch and in this way build up complex function block diagrams.
The figure below shows an example of the use of branches:
R
S
>=1
#S2
#S4
#S5
"LEFT"
"RlGHT"
See also
Rules for branches in FBD (Page 1151)
Inserting branches in FBD networks (Page 1152)
Deleting branches in FBD networks (Page 1152)
Rules for branches in FBD
Rules
The following rules apply to the use of branches in FBD:
Branches are opened downward.
Branches can be inserted only between FBD elements.
To delete a branch, you must delete all FBD elements, including the branch itself.
If you delete the connection between two branches, the FBD elements of the interrupted
branch will be positioned freely in the network.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
System Manual, 01/2013, 1151
See also
Basic information on branches in FBD (Page 1151)
Inserting branches in FBD networks (Page 1152)
Deleting branches in FBD networks (Page 1152)
Inserting branches in FBD networks
Requirement
A network is available.
Procedure
To insert a new branch in a network, follow these steps:
1. Open the "Instructions" task card.
2. Navigate to "General > Branch" in the "Basic instructions" palette.
3. Drag the element from the "Elements" pane to the a required location on a connection line
between two boxes.
See also
Rules for branches in FBD (Page 1151)
Basic information on branches in FBD (Page 1151)
Deleting branches in FBD networks (Page 1152)
Deleting branches in FBD networks
Requirement
A branch is available.
Procedure
To delete a branch, follow these steps:
1. Select the connection line that links the branch to the main branch.
2. Select the "Delete" command in the shortcut menu.
Result
The branch is now deleted. Boxes connected to the deleted branch are placed freely within
the network.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
1152 System Manual, 01/2013,
See also
Rules for branches in FBD (Page 1151)
Basic information on branches in FBD (Page 1151)
Inserting branches in FBD networks (Page 1152)
Logic paths in FBD
Basic information on logic paths in FBD
Use of logic paths
The user program will be mapped in one or more networks. The networks can contain one or
more logic paths on which the binary signals are arranged in the form of boxes.
The following figure shows an example of the use of several logic paths within a network:
"StartSwitch_Left"
>=1
S
"MOTOR_ON"
"StartSwitch_Right"
"StopSwitch_Left"
>=1
R
"MOTOR_ON"
"StopSwitch_Right"
Rules
Remember the following rules when using logic paths:
Connections are not permitted between logic paths.
Only one jump instruction is permissible per network. The positioning rules for jump
instructions remain valid.
Executing logic paths
Logic paths are executed from top to bottom and from left to right. This means that the first
instruction in the first logic path of the first network is executed first. All instructions of this logic
path are then executed. After this come all other logic paths of the first network. The next
network is executed only after all logic paths have first been executed.
When jumps are used the regular execution of the logic paths is circumvented and the
instruction is executed at the jump destination.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
System Manual, 01/2013, 1153
Differences between branches and logic paths
The difference between branches and logic paths is that the logic paths are independent
branches that can also stand in a different network. Branches, on the other hand, permit the
programming of a parallel connection and have a common preceding logic operation.
See also
Inserting a logic path (Page 1154)
Deleting a logic operation path (Page 1154)
Inserting a logic path
Requirement
A block is open.
A network is available.
Procedure
To insert a new logic path in a network, follow these steps:
1. Insert any instruction in a network in such a way that it has no connection to existing
instructions.
A new logic path is inserted.
2. Insert an assignment at the end of the new logic path.
3. Insert additional instructions in the new logic path.
See also
Basic information on logic paths in FBD (Page 1153)
Deleting a logic operation path (Page 1154)
Deleting a logic operation path
Requirement
A logic path is available.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
1154 System Manual, 01/2013,
Procedure
To delete a logic path, proceed as follows:
1. Hold down the left mouse button and draw a frame around the logic path. At the same time,
make sure that you select all instructions of the logic path. Alternatively, you can hold down
the <Shift> key and select the first the last instruction of the logic path.
2. Right-click on one of the instructions in the logic path.
3. Select the "Delete" command in the shortcut menu.
See also
Basic information on logic paths in FBD (Page 1153)
Inserting a logic path (Page 1154)
Creating SCL programs
Basics of SCL
Programming language SCL
Programming language SCL
SCL (Structured Control Language) is a high-level programming language based on PASCAL.
The language is based on DIN EN 61131-3 (international IEC 1131-3).
The standard standardizes programming languages for programmable logic controllers. The
SCL programming language fulfills the PLCopen Basis Level of ST language (Structured Text)
defined in this standard.
Language elements
SCL also contains higher programming languages in addition to the typical elements of the
PLC, such as inputs, outputs, timers or memory bits.
Expressions
Value assignments
Operators
Program control
SCL provides convenient instructions for controlling the program allowing you, for example, to
create program branches, loops or jumps.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
System Manual, 01/2013, 1155
Application
SCL is therefore particularly suitable for the following areas of application:
Data management
Process optimization
Recipe management
Mathematical / statistical tasks
Expressions
Description
Expressions are calculated during the runtime of the program and return a value. An expression
consists of operands (such as constants, tags or function calls) and optionally out of operators
(such as *, /, + or -). Expressions can be linked together or nested within each other by
operators.
Evaluation order
The evaluation of the expression occurs in a specific order that is defined by the following
factors:
Priority of the operators involved
Left-to-right order
Brackets
Types of expressions
The following expression types are available depending on the operator:
Arithmetic expressions
Arithmetic expressions consist of either a numerical value or combine two values or
expressions with arithmetic operators.
Relational expressions
Relational expressions compare the values of two operands and yield a Boolean value.
The result is TRUE if the comparison is true, and FALSE if it is not met.
Logical expressions
Logical expressions combine two operands with logical operators (AND, OR, XOR) or
negating operands (NOT).
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
1156 System Manual, 01/2013,
How expressions are used
You can use the result of an expression in different ways:
As a value assignment for a tag
As as a condition for a control instruction
As a parameter for a calling a block or instruction
See also
Operators and operator precedence (Page 1161)
Arithmetic expressions (Page 1157)
Relational expressions (Page 1159)
Logical expressions (Page 1161)
Arithmetic expressions
Description
Arithmetic expressions consist of either a numerical value or combine two values or
expressions with arithmetic operators.
Arithmetic operators can process the data types that are allowed in the CPU in use. If two
operands are involved in the operation, the data type of the result is determined based on the
following criteria:
If both operands are integers with sign and have different lengths, the result receives the
data type of the longer integer (e. g. INT + DINT = DINT).
If both operands are integers without sign and have different lengths, the result receives
the data type of the longer integer (e. g. USINT + UDINT = UDINT).
If one operand is an integer with sign and the other integer is an operand without sign, the
result receives the next larger data type with sign that covers the integer without sign (e.
g. SINT + USINT = INT).
You can only execute an operation with such operands if the IEC check is not set.
If one operand is an integer and the other operand is a floating-point number, the result
receives the data type of the floating-point number (e. g. INT + REAL = REAL).
If both operands are floating-point numbers and have different lengths, the result receives
the data type of the longer floating-point number (e. g. REAL + LREAL = LREAL).
The data type of the result of an operation that involves operands of the data type groups
"Times" and "Date and time" can be found in the table in section "Data types of arithmetic
expressions".
You cannot use data types of the data type groups "Times" and "Date and time" when the
IEC check is set.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
System Manual, 01/2013, 1157
Data types of arithmetic expressions
The following table shows the data types you can use in arithmetic expressions:
Operation Operator 1. Operand 2. Operand Result
Power ** Integer/floating-point
number
Integer/floating-point
number
Integer/floating-point
number
Unary plus + Integer/floating-point
number
TIME, LTIME
- Integer/floating-point
number
TIME, LTIME
Unary minus - Integer/floating-point
number
TIME, LTIME
- Integer/floating-point
number
TIME, LTIME
Multiplication * Integer/floating-point
number
Integer/floating-point
number
Integer/floating-point
number
TIME, LTIME Integer TIME, LTIME
Division / Integer/floating-point
number
Integer/floating-point
number (not equal 0)
Integer/floating-point
number
TIME, LTIME Integer TIME, LTIME
Modulo
function
MOD Integer Integer Integer
Addition + Integer/floating-point
number
Integer/floating-point
number
Integer/floating-point
number
TIME TIME TIME
TIME DINT TIME
LTIME TIME, LTIME LTIME
LTIME LINT LTIME
TOD TIME TOD
TOD DINT TOD
LTOD TIME, LTIME LTOD
LTOD LINT LTOD
DATE LTOD DTL
DATE TOD S7-300/400: DT
S7-1200/1500:
DTL
DT TIME DT
LDT TIME, LTIME LDT
DTL TIME, LTIME DTL
Subtraction - Integer/floating-point
number
Integer/floating-point
number
Integer/floating-point
number
TIME TIME TIME
TIME DINT TIME
LTIME TIME, LTIME LTIME
LTIME LINT LTIME
TOD TIME TOD
DINT TOD
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
1158 System Manual, 01/2013,
Operation Operator 1. Operand 2. Operand Result
LTOD TIME, LTIME LTOD
LTOD LINT LTOD
DATE DATE S7-300/400: TIME
S7-1200/1500:
LTIME
DT TIME DT
LDT TIME, LTIME LDT
DTL TIME, LTIME DTL
DTL DTL LTIME
For additional information on valid data types, refer to "See also".
Example
The following example shows an arithmetic expression:
SCL
"MyTag1":= "MyTag2" * "MyTag3";
See also
Expressions (Page 1156)
Relational expressions
Description
Relational expressions compare the values of two operands and yield a Boolean value. The
result is TRUE if the comparison is true, and FALSE if it is not met.
Relational operators can process the data types that are allowed in the CPU in use. The data
type of the result always is BOOL.
Note the following rules when forming relational expressions:
All tags are comparable within the following data type groups:
Integers/floating-point numbers
Binary numbers
String
With the following data types/data groups, only tags of the same type can be compared:
TIME, LTIME
Date and time
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
System Manual, 01/2013, 1159
The comparison of strings is based on the ASCII character set. The length of the tags and
the numerical value of each ASCII character are used for the comparison.
S5TIME tags are not permitted as comparison operands. An explicit conversion from
S5TIME to TIME or LTIME is necessary.
Data types of relational expressions
The following table shows the data types/data type groups you can use in relational
expressions:
Operation Operator 1. Operand 2. Operand Result
Compare for
equal, not equal
=, <> Integer/floating-
point number
Integer/floating-
point number
BOOL
Binary number Binary number BOOL
String String BOOL
TIME, LTIME TIME, LTIME BOOL
Date and time Date and time BOOL
Compare for less
than, less than-
equal to, greater
than, greater than
or equal to
<, <=, >, >= Integer/floating-
point number
Integer/floating-
point number
BOOL
String String BOOL
TIME, LTIME TIME, LTIME BOOL
Date and time Date and time BOOL
For additional information on valid data types, refer to "See also".
Example
The following example shows a relational expression:
SCL
IF a > b THEN c:= a;
IF A > 20 AND B < 20 THEN C:= TRUE;
IF A<>(B AND C) THEN C:= FALSE;
Note
The comparison for STRING and DT are executed internally in the S7-300/400 by extended
instructions. The following operands are not permitted for these functions:
Parameter of a FC
In-out parameter of an FB of type STRUCT or ARRAY
See also
Expressions (Page 1156)
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
1160 System Manual, 01/2013,
Logical expressions
Description
Logical expressions combine two operands with logical operators AND OR XOR or negating
operands NOT.
Logical operators can process the data types that are allowed in the CPU in use. The result
of a logical expression is of BOOL data type, if both operands are of BOOL data type. If at
least one of both operands is a bit string, then the result is also a bit string and is determined
by the type of the highest operand. For example, when you link a BOOL type operand to a
WORD type operand, the result is type WORD.
Data types of logical expressions
The following table shows the data types you can use in logical expressions:
Operation Operator 1. Operand 2. Operand Result
Negation NOT BOOL - BOOL
AND logic
operation
AND or & BOOL BOOL BOOL
Bit string Bit string Bit string
OR logic operation OR BOOL BOOL BOOL
Bit string Bit string Bit string
EXCLUSIVE OR
logic operation
XOR BOOL BOOL BOOL
Bit string Bit string Bit string
Example
The following example shows a logical expression:
SCL
IF "MyTag1" AND NOT "MyTag2" THEN c:=a;
MyTag:=ALPHA OR BETA;
See also
Expressions (Page 1156)
Operators and operator precedence
Operators and their order of evaluation
Expressions can be linked together or nested within each other by operators.
The order of evaluation for expressions depends on the precedence of operators and brackets.
The following basic rules apply:
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
System Manual, 01/2013, 1161
Arithmetic operators are evaluated before relational operators and relational operators are
evaluated before logical operators.
Operators with no precedence are evaluated according to their occurrence from left to right.
Operations in brackets are evaluated first.
The following table provides an overview of the operators and their precedence:
Operator Operation Precedence
Arithmetic expressions
** Power 2
+ Unary plus 3
- Unary minus 3
* Multiplication 4
/ Division 4
MOD Modulo function 4
+ Addition 5
- Subtraction 5
Relational expressions
< Less than 6
> Greater than 6
<= Less than or equal 6
>= Greater than or equal 6
== Equal 7
<> Not equal 7
Logical expressions
NOT Negation 3
AND or & Boolean AND 8
XOR Exclusive OR 9
OR Boolean OR 10
Miscellaneous operations
( ) Brackets 1
:= Assignment 11
See also
Expressions (Page 1156)
Value assignments
Definition
You can use a value assignment to assign the value of an expression to a tag. On the left side
of the assignment is the tag that takes the value of the expression on the right.
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
1162 System Manual, 01/2013,
The name of a function can also be specified as an expression. The function is called by the
value assignment and sends its return value back to the tag on the left.
The data type of value assignment is defined by the data type of the tag on the left. The data
type of the expression on the right must match this type.
For additional information on compatibility and conversion of data types, refer to "See also".
Value assignments for STRUCT data type or PLC data types
An entire structure can be assigned to another if the structures are identically organized and
the data types as well as the names of the structural components match.
You can assign a tag, an expression or another structural element to an individual structural
element.
Value assignments for the ARRAY data type
An entire ARRAY can be assigned to another ARRAY if both the data types of the ARRAY
elements as well as the ARRAY limits match.
You can assign a tag, an expression or another ARRAY element to an individual ARRAY
element.
Value assignments for the STRING data type
An entire STRING can be assigned to another STRING. If the assigned character string is
longer than the string on the left, a warning is generated during compiling.
You can assign another STRING element to an individual STRING element.
Value assignments for the ANY data type
You can assign a tag with the ANY data type only to the following objects:
Input parameters or temporary local data of FBs that also have the data type ANY.
Temporary local data of FCs that also have the data type ANY.
Note that you can only point to memory areas with "standard" access mode with the ANY
pointer.
Value assignments for the POINTER data type
You cannot use POINTER in value assignments in SCL.
Examples
The following table shows examples for value assignments:
SCL
"MyTag1" := "MyTag2"; (* Assignment of a tag*)
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
System Manual, 01/2013, 1163
SCL
"MyTag1" := "MyTag2" * "MyTag3"; (* Assignment of an expression*)
"MyTag" := "MyFC"(); (* Call a function, which assigns its
return value to the "MyTag" tag*)
#MyStruct.MyStructElement := "MyTag"; (* Assignment of a tag to a structure
element*)
#MyArray[2] := "MyTag"; (* Assignment of a tag to an ARRAY
element*)
"MyTag" := #MyArray[1,4]; (* Assignment of an ARRAY element to a
tag*)
#MyString[2] := #MyOtherString[5]; (* Assignment of a STRING element to
another STRING element*)
Settings for SCL
Overview of the settings for SCL
Overview
The following tables show the settings you can make for SCL:
Editor settings
Group Setting Description
View Keyword highlighting Notation used to represent the keywords of the programming
language. You can choose between uppercase and lowercase
letters or a notation corresponding to the conventions of the
Pascal programming language.
Default settings for new blocks
If you create new blocks, the following settings are set as default values. You can change
these in the block properties at a later point in time.
Group Setting Description
Compile Create extended status information Allows all tags in a block to be monitored. The memory
requirements of the program and execution times increase,
however, with this option.
Check ARRAY limits
1)
Checks at runtime whether array indices are within the declared
range for an ARRAY. If an array index exceeds the permissible
range, the enable output ENO of the block is set to "0".
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
1164 System Manual, 01/2013,
Group Setting Description
Set ENO automatically Checks at runtime whether errors occur in the processing of
certain instructions. If a runtime error occurs, the enable output
ENO of the block is set to "0".
1)
For CPUs of the S7-300/400 series: When the ARRAY limits are violated, the enable output ENO is set to FALSE.
For CPUs of the S7-1200/1500 series: When the ARRAY limits are violated, the enable output ENO is not set to FALSE.
See "Auto-Hotspot" for error query options.
See also
Changing the settings (Page 1165)
Changing the settings
Procedure
To change the settings, follow these steps:
1. Select the "Settings" command in the "Options" menu.
The "Settings" window is displayed in the work area.
2. In the area navigation, select the "PLC programming" group.
3. Change the settings.
Result
The change will be loaded directly, there is no need to save it explicitly.
See also
Overview of the settings for SCL (Page 1164)
The programming window of SCL
Overview of the programming window
Function
The programming window is the work area, where you enter the SCL program.
The following figure shows the programming window of SCL:
Programming the PLC
9.1 Creating a user program
STEP 7 Basic V12.0
System Manual, 01/2013, 1165
4
5
Programming the PLC
9.5 Configuring alarms
STEP 7 Basic V12.0
System Manual, 01/2013, 1367
Tabular display of the alarms in the work area, see: Auto-Hotspot
"Program alarms" tab: You can edit program alarms here.
"System diagnostic alarms" tab: System diagnostic alarms can only be viewed, not
edited. To edit these alarms, you must change to the device view ("Go to device" menu
command), where you can modify the system diagnostic alarms in the Inspector window.
"User diagnostic alarms" tab: User diagnostic alarms can be created and edited here.
This tab is hidden by default and must be activated by means of the icon in the toolbar.
The icon is grayed out for S7-1500 CPUs because the function is not available.
Auto-Hotspot
You can enter or modify the necessary parameters, texts and attributes in the table or in the
Inspector window.
9.5.8 Creating and editing alarms
9.5.8.1 Creating program alarms
Requirement
You have created a function block.
Procedure
To create a program alarm, follow these steps:
1. In the "Program blocks" folder in the project navigation, select the function block (FB) for
which you want to create a program alarm and double-click the block to open it.
2. Fill in the block interface. For each alarm block that will be called in the FB, you will need
to declare tags in the calling FB.
For this purpose, enter the following tags, for example:
For the "IN" parameter, a name for the alarm block input, for example "Alarm01" (for
alarm input 01) and the data type.
3. In the instruction window of the FB, insert the call for the selected alarm block, e.g. "CALL
ALARM_S" and complete your input with the RETURN key.
Result: The instruction part of the FB displays the input tags of the called alarm block, in
this case the ALARM_S block.
4. Assign the name that you entered for the alarm block input in step 2 to the "EV_ID" tag, in
this case "Alarm01".
Note
If, instead of an alarm block in the CPU, you call an FB with multiple instances in which
alarms are also configured, you also need to configure the alarms of the FB with multiple
instances in the calling block.
5. Repeat steps 2 through 4 for all alarm block calls in this FB.
Programming the PLC
9.5 Configuring alarms
STEP 7 Basic V12.0
1368 System Manual, 01/2013,
9.5.8.2 Editing program alarms in the alarm editor
Requirement
You have created a program alarm.
Procedure
To edit program alarms, follow these steps:
1. Double-click "PLC alarms" in the project navigation. The alarm editor opens.
2. Enter the required texts and attributes in the appropriate columns.
Note
When you edit alarm types, you can lock texts and attributes. You do this by clicking on
the icon in front of the relevant column.
If you edit alarms in instance DBs in which the texts/attributes are not locked in the alarm
type, a type icon is displayed in front of the relevant column. When you click on this icon,
modified texts/attributes are reset to the values of the alarm type.
9.5.8.3 Editing program alarms in the program editor
Requirement
You have created a program alarm.
Procedure
To edit program alarms, follow these steps:
1. Select the appropriate line in the block interface.
2. Move to the "Alarm" tab in the Inspector window and select the required group.
3. Enter the required texts and attributes in the appropriate fields.
Note
When you edit alarm types, you can lock texts and attributes. You do this by clicking on
the icon next to the relevant field.
If you edit alarms in instance DBs in which the texts/attributes are not locked in the alarm
type, a type icon is displayed next to the relevant field. When you click on this icon, modified
texts/attributes are reset to the values of the alarm type.
Programming the PLC
9.5 Configuring alarms
STEP 7 Basic V12.0
System Manual, 01/2013, 1369
9.5.8.4 Deleting program alarms
Procedure
To delete a program alarm, follow these steps:
1. Open the block containing the alarm you want to delete.
2. Select the corresponding line in the block interface and select "Delete" in the shortcut menu.
Result
The alarm is deleted.
9.5.8.5 Creating and editing an alarm type
Procedure
To edit an alarm type, follow these steps:
1. Select the required alarm block.
2. Enter the texts you require in the appropriate columns or select the required attributes.
If you have selected a multichannel alarm block (for example, "ALARM_8"), you can assign
a separate text and certain separate attributes to each subnumber.
3. If you do not want the texts or attributes of the instance to be changed, lock them in the
alarm type.
9.5.8.6 Creating and editing an instance DB
Prerequisites
You have already created an FB and created at least one alarm in it.
Programming the PLC
9.5 Configuring alarms
STEP 7 Basic V12.0
1370 System Manual, 01/2013,
Procedure
To assign instance data blocks (DBs) to an alarm type and to edit the alarms for these DBs
for specific instances, follow the steps below:
1. Double-click on "Add new block" in the project navigation, click on the "Data block (BD)"
button that appears in the dialog and select the function block (alarm type) to which you
want to assign the instance DB from the "Type" drop-down list.
2. Now click in the inspector window on the "Alarm" tab and select the group you want.
Or:
Double-click in the project navigation on "PLC alarms" to open the alarm configuration.
3. Make the changes you require for the particular instance DB.
Note
If the properties of the instance DB are write-protected then you must first unlock them in
alarm type (FB).
Result
This completes the alarm configuration for the selected instance DB.
9.5.8.7 Creating user diagnostic alarms
User diagnostic alarms are assigned to a CPU. They are created and edited in the alarm
editor.
Procedure
To create a user diagnostic alarm, follow these steps:
1. Double-click on the "PLC alarms" folder in project navigation to open the alarm editor.
2. Select the "User diagnostic alarms" tab in the alarm editor.
3. Click in the table and select "Insert new alarm" in the shortcut menu.
Result
You have created a user diagnostic alarm.
9.5.8.8 Editing user diagnostic alarms
Requirement
You have created a user diagnostic alarm.
The alarm editor is open.
Programming the PLC
9.5 Configuring alarms
STEP 7 Basic V12.0
System Manual, 01/2013, 1371
Procedure
To edit a user diagnostic alarm, follow these steps:
1. Enter the required texts and attributes in the appropriate columns.
9.5.8.9 Deleting user diagnostic alarms
You can delete a selected alarm. The texts you configured for this alarm are deleted and the
alarm number is released for use.
Procedure
To delete a user diagnostic alarm, follow these steps:
1. Select the corresponding row in the table and select "Delete" in the shortcut menu.
Result
The alarm is deleted. It is no longer displayed in the table.
9.5.8.10 Insert associated values in alarms
To add current information to alarms, e.g. from the process, you can insert associated values
at any location within an alarm text.
Procedure
To insert an associated value into an alarm, follow these steps:
Alarm SFB for the S7-400 (e.g. Alarm8)
1. Configure a block as follows:
@<No. of associated value><Element type><Format>@.
2. Insert this block at the locations in the alarm text at which the associated value is to be
shown.
Programming the PLC
9.5 Configuring alarms
STEP 7 Basic V12.0
1372 System Manual, 01/2013,
Alarm SFC for the S7-300/400 (e.g. Alarm_S)
The maximum length of an associated value in the AlarmS/SQ is a maximum of 12 bytes.
1. Configure a block as follows:
@<Index><ElementType><FormatSpecification>@.
Index: Index in the associated value. The index is interpreted as an array index starting
with 1.
The byte offset is calculated with the following formula:
Offset = ((Index - 1) * data width (element type))
Use only element types Y, W, X, or R. The element type is used here only to determine the
data width. The display type is determined by the format specification.
2. Insert this block at the locations in the alarm text at which the associated value is to be
shown.
See also
Structure of associated values (Page 1373)
Examples of associated values (Page 1374)
9.5.8.11 Structure of associated values
Associated values are comprised of the following:
Element type
This uniquely configures the data type of the associated value:
Element type Data type
Y BYTE
W WORD
X DWORD
I Integer
D DINT
B BOOL
C CHAR
R REAL
The element type only uniquely identifies the data type transferred by the AS. It is not used as
Casting Operator.
Programming the PLC
9.5 Configuring alarms
STEP 7 Basic V12.0
System Manual, 01/2013, 1373
Format
Determine the output format for the associated value on the display device. The format is
preceded by the "%" sign. The following fixed formats apply to alarm texts:
Format Description
%[i]X Hexadecimal number with i digits
%[i]u Decimal number without sign with i digits
%[i]d Decimal number with sign with i digits
%[i]b Binary number with i digits
%[i][.y]f Fixed number of points
Signed value of the form
dddd: one or more numbers with y digits after the
decimal point and total number of digits i
%[i]s String (ANSI string) with i digits
Characters are printed up to the first 0 Byte
(00Hex).
%t#<Name of text library> Access to text library
If the format is too small then the value is nevertheless output in full.
If the format is too large then an appropriate number of empty characters are output before
the value.
Note
Please note that you can optionally enter "[i]", without the square brackets.
See also
Insert associated values in alarms (Page 1372)
Examples of associated values (Page 1374)
9.5.8.12 Examples of associated values
Examples of associated values:
@1I%6d@: The value from associated value 1 is shown as a decimal number with a max. 6
digits.
@2R%6f@: The value "5.4", for instance from associated value 2, is shown as a fixed number
of points "5.4" (three leading blanks).
@2R%2f@: The value "5.4", for instance from associated value 2, is shown as a fixed number
of points "5.4" (if number of digits is too small then these are not cut off).
Programming the PLC
9.5 Configuring alarms
STEP 7 Basic V12.0
1374 System Manual, 01/2013,
@1W%t#Textbib1@: Associated value 1 of the WORD data type is the index by which the text
to be inserted is referenced in the Textbib1 text library.
Note
If you want to transfer more than one associated value to an ALARM_S block then you can
transfer an array with a max. length of 12 bytes. These could be, e.g. maximum 12 Byte or
Char, maximum 6 Word or Int or maximum 3 DWord, Real or Dint.
See also
Insert associated values in alarms (Page 1372)
Structure of associated values (Page 1373)
9.5.8.13 Deleting associated values
You can delete associated values by deleting the string that represents an associated value
in the alarm text.
Procedure:
Follow the steps below to delete associated values:
1. Find the block in the alarm text that corresponds to the associated value you want to delete.
The block begins with the "@" character followed by the location ID by which you can
recognize the associated value, there is then format information and it ends with the "@"
character.
2. Delete the block you have found from the alarm text.
9.5.9 Creating and editing alarms
9.5.9.1 Creating program alarms
Requirement
You have created a function block.
Programming the PLC
9.5 Configuring alarms
STEP 7 Basic V12.0
System Manual, 01/2013, 1375
Procedure
To create a program alarm, follow these steps:
1. In the "Program blocks" folder in the project navigation, select the function block (FB) for
which you want to create a program alarm and double-click the block to open it.
2. In the instruction window of the FB, insert the call for the selected alarm block, e.g.
"Program_Alarm" and complete your input with the RETURN key. The block interface is
automatically provided with the necessary information in the "Static" area.
Result: The instruction part of the FB displays the input tags of the called alarm block, in
this case the Program_Alarm block.
3. Repeat steps 3 through 4 for all alarm block calls in this FB.
Please note that you must specify the alarm class when you create alarms for S7-1500 CPUs.
Indicates whether the message requires acknowledgment. Alarms that do not require
acknowledgment can also be used only for information purposes.
As a result, there are three types of alarm:
The alarm has to be acknowledged and has the status "incoming" or "outgoing". The check
mark in the "Acknowledgment" column depends on the acknowledgment property of the
alarm class.
The alarm has to be acknowledged and has the status "incoming" or "outgoing".
The alarm is used only for information purposes. The check mark must be set in the
"Information only" column.
See also
Creating alarm classes (Page 1385)
9.5.9.2 Editing program alarms in the alarm editor
Requirement
You have created a program alarm.
Programming the PLC
9.5 Configuring alarms
STEP 7 Basic V12.0
1376 System Manual, 01/2013,
Procedure
To edit program alarms, follow these steps:
1. Double-click "PLC alarms" in the project navigation. The alarm editor opens.
2. Enter the required texts and attributes in the appropriate columns.
Note
When you edit alarm types, you can lock texts and attributes. You do this by clicking on
the icon in front of the relevant column.
If you edit alarms in instance DBs in which the texts/attributes are not locked in the alarm
type, a type icon is displayed in front of the relevant column. When you click on this icon,
modified texts/attributes are reset to the values of the alarm type.
9.5.9.3 Editing program alarms in the program editor
Requirement
You have created a program alarm.
Procedure
To edit program alarms, follow these steps:
1. Select the appropriate line in the block interface.
2. Move to the "Alarm" tab in the Inspector window and select the required group.
3. Enter the required texts and attributes in the appropriate fields.
Note
When you edit alarm types, you can lock texts and attributes. You do this by clicking on
the icon next to the relevant field.
If you edit alarms in instance DBs in which the texts/attributes are not locked in the alarm
type, a type icon is displayed next to the relevant field. When you click on this icon, modified
texts/attributes are reset to the values of the alarm type.
Programming the PLC
9.5 Configuring alarms
STEP 7 Basic V12.0
System Manual, 01/2013, 1377
9.5.9.4 Deleting program alarms
Procedure
To delete a program alarm, follow these steps:
1. Open the block containing the alarm you want to delete.
2. Select the corresponding line in the block interface and select "Delete" in the shortcut menu.
Result
The alarm is deleted.
9.5.9.5 Creating and editing an alarm type
Procedure
To edit an alarm type, follow these steps:
1. Select the required alarm block.
2. Enter the texts you require in the appropriate columns or select the required attributes.
If you have selected a multichannel alarm block, you can assign a separate text and certain
separate attributes to each sub-number.
3. If you do not want the texts or attributes of the instance to be changed, lock them in the
alarm type.
9.5.9.6 Creating and editing an instance DB
Prerequisites
You have already created an FB and created at least one alarm in it.
Programming the PLC
9.5 Configuring alarms
STEP 7 Basic V12.0
1378 System Manual, 01/2013,
Procedure
To assign instance data blocks (DBs) to an alarm type and to edit the alarms for these DBs
for specific instances, follow the steps below:
1. Double-click on "Add new block" in the project navigation, click on the "Data block (BD)"
button that appears in the dialog and select the function block (alarm type) to which you
want to assign the instance DB from the "Type" drop-down list.
2. Now click in the inspector window on the "Alarm" tab and select the group you want.
Or:
Double-click in the project navigation on "PLC alarms" to open the alarm configuration.
3. Make the changes you require for the particular instance DB.
Note
If the properties of the instance DB are write-protected then you must first unlock them in
alarm type (FB).
Result
This completes the alarm configuration for the selected instance DB.
9.5.9.7 Insert associated values in alarms
To add current information to alarms, e.g. from the process, you can insert associated values
at any location within an alarm text.
Procedure
To insert an associated value into an alarm, follow these steps:
1. Configure a block as follows:
@<No. of associated value><Format>@.
2. Insert this block at the locations in the alarm text at which the associated value is to be
shown.
See also
Structure of associated values (Page 1379)
Examples of associated values (Page 1380)
9.5.9.8 Structure of associated values
Associated values are comprised of the following:
Programming the PLC
9.5 Configuring alarms
STEP 7 Basic V12.0
System Manual, 01/2013, 1379
Format
Determine the output format for the associated value on the display device. The format is
preceded by the "%" sign. The following fixed formats apply to alarm texts:
Format Description
%[i]X Hexadecimal number with i digits
%[i]u Decimal number without sign with i digits
%[i]d Decimal number with sign with i digits
%[i]b Binary number with i digits
%[i][.y]f Fixed number of points
Signed value of the form
dddd: one or more numbers with y digits after the
decimal point and total number of digits i
%[i]s String (ANSI string) with i digits
Characters are printed up to the first 0 Byte
(00Hex).
%t#<Name of text library> Access to text library
If the format is too small then the value is nevertheless output in full.
If the format is too large then an appropriate number of empty characters are output before
the value.
Note
Please note that you can optionally enter "[i]", without the square brackets.
See also
Insert associated values in alarms (Page 1379)
Examples of associated values (Page 1380)
9.5.9.9 Examples of associated values
Examples of associated values:
@1%6d@: The value from associated value 1 is shown as a decimal number with a max. 6
digits.
@2%6f@: The value "5.4", for instance from associated value 2, is shown as a fixed number
of points "5.4" (three leading blanks).
@2%2f@: The value "5.4", for instance from associated value 2, is shown as a fixed number
of points "5.4" (if number of digits is too small then these are not cut off).
@1%t#Textbib1@: Associated value 1 is the index by which the text to be inserted is
referenced in the Textbib1 text library.
Programming the PLC
9.5 Configuring alarms
STEP 7 Basic V12.0
1380 System Manual, 01/2013,
See also
Insert associated values in alarms (Page 1379)
Structure of associated values (Page 1379)
9.5.9.10 Deleting associated values
You can delete associated values by deleting the string that represents an associated value
in the alarm text.
Procedure:
Follow the steps below to delete associated values:
1. Find the block in the alarm text that corresponds to the associated value you want to delete.
The block begins with the "@" character followed by the location ID by which you can
recognize the associated value, there is then format information and it ends with the "@"
character.
2. Delete the block you have found from the alarm text.
9.5.10 Texts and attributes
9.5.10.1 Entering texts
You can enter the texts for alarms manually or you can use the default values.
Text template from the alarm type
All the texts in the alarm type are available as a template for creating alarm texts. If the alarm
type already contains a general text, all instances of this alarm type include the same attributes
and texts. Where necessary, you simply need to modify them.
Info text
The info text is a text that can be specified for certain display devices. With certain groups of
devices (for example WinCC), it can be changed during run time.
Additional texts
Additional texts are texts that can be displayed by certain HMI devices. Click in the relevant
row and type in the text. If you want to protect the text from being overwritten, click the option
in the column. The texts can include line breaks.
Programming the PLC
9.5 Configuring alarms
STEP 7 Basic V12.0
System Manual, 01/2013, 1381
See also
Locking texts (Page 1382)
9.5.10.2 Locking texts
"Locked" option in the alarm type
You can only lock texts when you edit the alarm type. The locked texts in alarms derived from
the alarm type are write-protected. The icon displayed beside the input field indicates whether
or not they are locked.
Locking texts
Follow the steps below to lock texts:
1. Start by editing the alarm types.
2. Click on the icon beside the input box you want to lock.
Result: The icon changes to a closed chain link.
Unlocking texts
To unlock texts, follow the steps below:
1. Start by editing the alarm types.
2. Click on the icon beside the input box you want to unlock.
Result: The icon changes to an open chain link.
9.5.10.3 Locking attributes
Locking attributes in the alarm type
You can only lock attributes when you edit the alarm type. The locked attributes in alarms
derived from the alarm type are write-protected. The icon in front of the input field indicates
whether the attribute is locked.
Locking attributes
Follow the steps below to lock attributes:
1. Start by editing the alarm types.
2. Click on the icon to the left of the input box you want to lock in the table.
Result: The icon changes to a closed chain link.
Programming the PLC
9.5 Configuring alarms
STEP 7 Basic V12.0
1382 System Manual, 01/2013,
Unlocking attributes
Follow the steps below to unlock attributes:
1. Start by editing the alarm types.
2. Click on the icon to the left of the input box you want to unlock in the table.
Result: The icon changes to an open chain link.
9.5.11 Text lists for alarms
9.5.11.1 Basics of alarm text lists
You can adapt existing text lists (user-defined and system-defined text lists) to your
requirements and edit texts and attributes. You can then translate the texts into the project
language(s) you want to use.
Detailed information on text lists is contained in the "Working with text lists" chapter.
See also
Text lists (Page 290)
9.5.11.2 Editing text lists for alarms
Requirement
The user interface language and the project language must be the same during editing.
Procedure
Follow the steps below to edit text lists:
1. Double-click on the "Text lists" command below "Common data" in project navigation or
select the context command "Go to text list" in the alarm editor.
The text list editor opens.
2. Select the text list you want to edit from the table.
3. Change the values as required.
You can change the following values:
Programming the PLC
9.5 Configuring alarms
STEP 7 Basic V12.0
System Manual, 01/2013, 1383
Text titles:
With the exception of the Info text, the titles for the alarm texts (alarm text, additional texts)
can be freely configured to suit your purposes.
Names of attribute values:
Many of the names for attribute values (for example Priority, Display class, ...) can be
configured freely. The index in the system text list matches the index in the selection box
of the corresponding attribute in the alarm editor.
Example: If you enter the text "Priority_0" at index 0 in the priority text list, the same text
will be displayed at the first position in the selection box in the alarm editor.
9.5.11.3 Integrating texts from text lists in alarms
You can integrate any number of texts in an alarm from various text lists. The texts can be
positioned anywhere you want which means that they can be used in alarms in foreign
languages.
Procedure
To integrate texts from text lists in alarms, follow the steps below:
1. Double-click on the "Text lists" command below the PLC in the program navigation.
The text list editor opens
2. Find the index of the text you want to integrate.
3. Put a placeholder in the format @[Index]%t#[textlist]@ at the point at which you want the
text to appear.
Note
S7-300/400: [Index] = for example, 1W, where 1W is the first associated value of the alarm
of the type WORD.
S7-1500: [Index] = e.g. 1, where 1 is the first associated value of the alarm.
9.5.11.4 Example of integrating texts from text lists in alarms
S7-300/400: Configured alarm text: Pressure has risen @2W%t#textlist1@.
S7-1500: Configured alarm text: Pressure has risen @2%t#textlist1@.
Text list with the name "textlist1":
Index German English
1734 zu hoch too high
The associated value is supplied with the value 1734.
The following alarm text is displayed: Pressure has risen too high.
Programming the PLC
9.5 Configuring alarms
STEP 7 Basic V12.0
1384 System Manual, 01/2013,
See also
Integrating texts from text lists in alarms (Page 1384)
9.5.12 Alarm classes
9.5.12.1 Creating alarm classes
You can configure alarm classes to suit your purposes. You can create and edit them in the
alarm class editor. An alarm can then by assigned to an alarm class in the alarm editor.
Two alarm classes "Ackownledgement" (for alarms with acknowledgment) and "No
Ackownledgement" (for alarms without acknowledgment) are already created by the system.
These cannot be modified.
A total of 16 alarm classes can be created. The "With acknowledgment" property of the alarm
classes indicates that its is mandatory to acknowledge the assigned alarms.
Requirement
You have opened the "Common data" folder in project navigation.
Procedure
To configure an alarm class, follow these steps:
1. Double click on the "Alarm classes" entry in project navigation.
The alarm class editor opens.
2. Select "Insert new alarm class" in the shortcut menu.
3. Enter a unique name for the new alarm class in the "Name" column.
The language of the name you assign here is neutral.
4. Enter a display name in the "Display name" column. This name is translatable.
5. Specify whether or not alarms of this alarm class require acknowledgment in the "With
acknowledgment" column.
9.5.12.2 Editing alarm classes
You can change the settings (name, display name, or acknowledgment) for an alarm class at
any time even if alarms have already been assigned to the alarm class. The changes are
adopted automatically in the alarms.
Programming the PLC
9.5 Configuring alarms
STEP 7 Basic V12.0
System Manual, 01/2013, 1385
Copying alarm classes
To copy alarm classes, follow these steps:
1. Select the row with the alarm class you want to copy.
2. Select "Copy" in the shortcut menu.
3. Select "Paste" in the shortcut menu.
Result
The copied alarm class is appended to the end of the table under a new name.
The name of the new alarm class is made up as follows:
<old name><no.>
no.: This the lowest free natural number.
Programming the PLC
9.5 Configuring alarms
STEP 7 Basic V12.0
1386 System Manual, 01/2013,
9.6 Using global project functions
9.6.1 Importing and exporting
9.6.1.1 Basics for importing and exporting
Introduction
You can export PLC tag tables to a standardized XLSX format for editing with external table
editors. Similarly, you can import PLC tag tables created with external table editors to the TIA
Portal.
Overwriting existing PLC tags and constants during import
Existing entries of the same name will be overwritten during import if they have the same name
as the entries that will be imported.
Link to existing objects
References to PLC tags or constants that already exist in the project are updated automatically
during import. The update is executed based on the name of the PLC tags and constants.
See also
Format of the export file (Page 1387)
Exporting PLC tags (Page 1388)
Importing PLC tags (Page 1389)
9.6.1.2 Format of the export file
Introduction
During the export of PLC tag tables, a standardized XSLX format will be generated that you
can edit with external table editors.
This format is also expected during the import of tables.
Format of the export file
The sheet is always named "PLC Tags". This sheet can contain the displayed columns. The
sorting order of columns can vary. The sheet does not necessarily have to include all columns.
During import, the following values will be identified by a <no value> entry.
Programming the PLC
9.6 Using global project functions
STEP 7 Basic V12.0
System Manual, 01/2013, 1387
The names of the column headers are also clearly defined and are always expected in English.
The following table specifies the contents expected for the individual columns:
Element Explanation
Name Name of the tags
Path Group and name of the PLC tag table
Data type The notation of the data type corresponds to the
notation used in the PLC tag table.
Logical address The address can be specified with German or
international mnemonics.
Comment Free-form comments
HMI visible The value TRUE or FALSE is expected.
HMI accessible The value TRUE or FALSE is expected.
See also
Basics for importing and exporting (Page 1387)
Exporting PLC tags (Page 1388)
Importing PLC tags (Page 1389)
9.6.1.3 Exporting PLC tags
Requirement
A PLC tag table is open.
Procedure
To export PLC tags and constants, follow these steps:
1. In the PLC tag table, click the "Export" button.
The "Export to Excel" dialog opens.
2. Select the path to which you want to save the export file.
3. Select whether to export tags and/or constants.
4. Click the "OK" button.
Result
The export file will be generated. Errors and warnings generated during export are indicated
in the "Info" tab of the Inspector window.
Programming the PLC
9.6 Using global project functions
STEP 7 Basic V12.0
1388 System Manual, 01/2013,
See also
Basics for importing and exporting (Page 1387)
Format of the export file (Page 1387)
Importing PLC tags (Page 1389)
9.6.1.4 Importing PLC tags
Requirement
A table exists and it conforms to format specifications.
Procedure
To import a PLC tag table, follow these steps:
1. Open the "All tags" table.
2. Click the "Import" button.
The "Import from Excel" dialog opens.
3. Select whether to import PLC tags and/or constants.
4. Select the table you want to import.
5. Click the "OK" button.
Result
The PLC tag table will be imported.
Errors and warnings generated during export are indicated in the "Info" tab of the Inspector
window.
See also
Basics for importing and exporting (Page 1387)
Format of the export file (Page 1387)
Exporting PLC tags (Page 1388)
Programming the PLC
9.6 Using global project functions
STEP 7 Basic V12.0
System Manual, 01/2013, 1389
9.7 Programming examples
9.7.1 LAD programming examples
9.7.1.1 Example of controlling a conveyor belt
Controlling a conveyor belt
The following figure shows a conveyor belt that can be activated electrically. There are two
pushbutton switches at the beginning of the conveyor belt: S1 for START and S2 for STOP.
There are also two pushbutton switches at the end of the conveyor belt: S3 for START and
S4 for STOP. It is possible to start and stop the conveyor belt from either end.
MOTOR_ON
S1
S2
S3
S4
O start
O stop
O start
O stop
Implementation
The following table shows the definition of the tags used:
Name Data type Description
StartSwitch_Left (S1) BOOL Start switch on the left side of the
conveyor belt
StopSwitch_Left (S2) BOOL Stop switch on the left side of the
conveyor belt
StartSwitch_Right (S3) BOOL Start switch on the right side of
the conveyor belt
StopSwitch_Right (S4) BOOL Stop switch on the right side of
the conveyor belt
MOTOR_ON BOOL Turn on the conveyor belt motor
The following networks show the LAD programming for solving this task:
Network 1:
The conveyor belt motor is switched on when Start switch "S1" or "S3" is pressed.
Programming the PLC
9.7 Programming examples
STEP 7 Basic V12.0
1390 System Manual, 01/2013,
S
"MOTOR_ON "StartSwitch_Left
"StartSwitch_Right
Network 2:
The conveyor belt motor is switched off when Stop switch "S2" or "S4" is pressed.
R
"MOTOR_ON" "StopSwitch_Left"
"StopSwitch_Right"
9.7.1.2 Example of detecting the direction of a conveyor belt
Detecting the direction of a conveyor belt
The following figure shows a conveyor belt that is equipped with two photoelectric barriers
(PEB1 and PEB2). The photoelectric barriers are designed to detect the direction in which an
object is moving on the conveyor belt.
Implementation
The following table shows the definition of the tags used:
Name Data type Description
PEB1 BOOL Photoelectric barrier 1
PEB2 BOOL Photoelectric barrier 2
RIGHT BOOL Display during movement to right
LEFT BOOL Display during movement to left
Programming the PLC
9.7 Programming examples
STEP 7 Basic V12.0
System Manual, 01/2013, 1391
Name Data type Description
CM1 BOOL Edge bit memory 1
CM2 BOOL Edge bit memory 2
The following networks show the LAD programming for solving this task:
Network 1:
If the signal state changes from "0" to "1" (positive edge) at photoelectric barrier "PEB1" and,
at the same time, the signal state at "PEB2" is "0", the object on the belt is moving to the left.
S
"PEB1
"CM1
"PEB2 "LEFT
P
R
"RlGHT
Network 2:
If the signal changes from "0" to "1" (positive edge) at photoelectric barrier "PEB2" and, at the
same time, the signal state at "PEB1" is "0", the object on the belt is moving to the right.
S
"PEB1
"CM2
"PEB2
"LEFT
P
R
"RlGHT
9.7.1.3 Example of detecting the fill level of a storage area
Detecting the fill level of a storage area
The following figure shows a system with two conveyor belts and a temporary storage area
between them. Conveyor belt 1 delivers packages to the storage area. A photoelectric barrier
at the end of conveyor belt 1 near the storage area detects how many packages are delivered
to the storage area. Conveyor belt 2 transports packages from the temporary storage area to
a loading dock onto which the packages are loaded for delivery to customers by truck. A
photoelectric barrier at the storage area exit detects how many packages leave the storage
area to be transported to the loading dock. Five display lamps indicate the capacity of the
temporary storage area.
When a conveyor belt is restarted, the current count value is set to the number of packages
available in the storage area.
Programming the PLC
9.7 Programming examples
STEP 7 Basic V12.0
1392 System Manual, 01/2013,
Display panel
Storage area
empty
incoming
packages
outgoing
packages
Storage area
not empty
Storage area
50% full
Storage area
90% full
Storage area
full
Temporary
storage area
for 100
packages
Conveyor belt 1 Conveyor belt 2
Photoelectric barrier 1 Photoelectric barrier 2
Implementation
The following table shows the definition of the tags used:
Name Data type Description
PEB1 BOOL Photoelectric barrier 1
PEB2 BOOL Photoelectric barrier 2
RESET BOOL Reset counter
LOAD BOOL Set counter to value of "PV"
parameter
STOCK INT Stock at restart
PACKAGECOUNT INT Number of packages in the
storage area (current count
value)
STOCK_PACKAGES BOOL Is set if the current count value
is greater than or equal to the
value of the tag "STOCK".
STOR_EMPTY BOOL Display lamp: Storage area
empty
STOR_NOT_EMPTY BOOL Display lamp: Storage area not
empty
STOR_50%_FULL BOOL Display lamp: Storage area 50%
full
STOR_90%_FULL BOOL Display lamp: Storage area 90%
full
STOR_FULL BOOL Display lamp: Storage area full
VOLUME_50 INT Comparison value: 50 packages
Programming the PLC
9.7 Programming examples
STEP 7 Basic V12.0
System Manual, 01/2013, 1393
Name Data type Description
VOLUME_90 INT Comparison value: 90 packages
VOLUME_100 INT Comparison value: 100
packages
The following networks show the LAD programming for activating the lamps:
Network 1:
When a package is delivered to the storage area, the signal state at "PEB1" switches from "0"
to "1" (positive signal edge). On a positive signal edge at "PEB1", the "Up" counter is enabled,
and the current count value of "PACKAGECOUNT" is increased by one.
When a package is delivered from the storage area to the loading dock, the signal state at
"PEB2" switches from "0" to "1" (positive signal edge). On a positive signal edge at "PEB2",
the "Down" counter is enabled, and the current count value of "PACKAGECOUNT" is
decreased by one.
If there are no packages in the storage area ("PACKAGECOUNT" = "0"), the "STOR_EMPTY"
tag is set to signal state "1", and the "Storage area empty" lamp is switched on.
The current count value can be reset to "0" if the "RESET" tag is set to signal state "1".
If the "LOAD" tag is set to signal state "1", the current count value is set to the value of the
"STOCK" tag. If the current count value is greater than or equal to the value of the "STOCK"
tag, the "STOCK_PACKAGES" tag supplies the signal state "1".
CTUD
CU
"PEB1"
"STOCK_PACKAGES"
"STOCK"
"PEB2"
"LOAD"
"RESET"
CD "STOR_EMPTY"
"PACKAGECOUNT"
"CTUD_DB"
R
PV
LD
QU
QD
CV
lNT
Network 2:
As long as there are packages in the storage area, the "STOR_NOT_EMPTY" tag is set to
signal state "1", and the "Storage area not empty" lamp is switched on.
"STOR_EMPTY" "STOR_NOT_EMPTY"
Network 3:
If the number of packages in the storage area is greater than or equal to 50, the lamp for
the"Storage area 50% full" message switches on.
Programming the PLC
9.7 Programming examples
STEP 7 Basic V12.0
1394 System Manual, 01/2013,
>=
lNT
"STOR_50%_FULL" "PACKAGECOUNT"
"VOLUME_50"
<
lNT
"PACKAGECOUNT"
"VOLUME_90"
Network 4:
If the number of packages in the storage area is greater than or equal to 90, the "Storage area
90% full" lamp switches on.
>=
lNT
"STOR_90%_FULL" "PACKAGECOUNT"
"VOLUME_90"
<
lNT
"PACKAGECOUNT"
"VOLUME_100"
Network 5:
If the number of packages in the storage area reaches 100, the lamp for the "Storage area
full" message switches on.
>=
lNT
"STOR_FULL"
"PACKAGECOUNT"
"VOLUME_100"
9.7.1.4 Example of controlling room temperature
Controlling room temperature
In a cold room, the temperature must be maintained below zero degrees Celsius. Any
temperature fluctuations are monitored by a sensor. If the temperature rises above zero
degrees Celsius, the cooling system switches on for a preset time. The "Cooling system On"
lamp is lit during this time.
The cooling system and the lamp are turned off if one of the following conditions is met:
The sensor reports a temperature fall below zero degrees Celsius.
The preset cooling time has elapsed.
The pushbutton switch "STOP" has been pressed.
If the preset cooling time has expired and the temperature in the cold room is still too high, the
cooling system can be restarted by means of the pushbutton switch "RESET".
COOLlNG
SYSTEM
TEMPERATURE
SENSOR
LAMP
RESET
STOP
Programming the PLC
9.7 Programming examples
STEP 7 Basic V12.0
System Manual, 01/2013, 1395
Implementation
The following table shows the definition of the tags used:
Name Data type Comment
Sensor BOOL Temperature sensor signal
RESET BOOL Restart
STOP BOOL The cooling system is switched
off.
MaxCoolTime TIME Preset cooling time
This tag is defined in the
"DB_Cool" data block.
CurrCoolTime TIME Currently elapsed cooling time
This tag is defined in the
"DB_Cool" data block.
Cooling system BOOL The cooling system is switched
on.
Lamp BOOL The lamp for the "Cooling
system on" message is switched
on.
TempVariable BOOL Temporary tag
This tag stores the signal state
of the IEC time TP.
The following network shows the LAD programming for controlling room temperature:
Network 1:
"DB_Cool".
MaxCoolTime
"Sensor"
DB_Cool.
CurrCoolTime
"TP_DB"
"TempVariable" "RESET"
TP
PT
Q
ET
lN
Time
Network 2:
"Cooling system" "Lamp" "STOP" "Sensor" "TempVariable"
When the temperature in the cold room rises above zero degrees Celsius, the signal state at
the "Sensor" operand switches from "0" to "1" (positive signal edge). In the case of a positive
signal edge at the input IN of the time function, the preset cooling time is started and the
"TempVariable" receives the signal state "1". The signal state "1" of the "TempVariable" has
the result in network 2 that the cooling system as well as the display lamp are turned on. The
outputs "Sensor", "Cooling system" and "Lamp" must be programmed in network 2, because
you can program only one coil at output Q of the time function.
Programming the PLC
9.7 Programming examples
STEP 7 Basic V12.0
1396 System Manual, 01/2013,
If the temperature in the cold room falls below zero degrees Celsius, the signal state of the
sensor switches back to "0". This switches the cooling system and lamp off.
If the sensor does not signal a temperature drop, the cooling system and lamp are switched
off after the preset cooling time has elapsed, at the latest. In this case, the cooling process
can be restarted by pressing the "RESET" pushbutton switch. Pressing and releasing the
pushbutton switch generates a new positive signal edge at input IN, which restarts the cooling
system.
Using the pushbutton switch "STOP", the cooling system and the display lamp can be turned
off at any time.
9.7.2 FBD programming examples
9.7.2.1 Example of controlling a conveyor belt
Controlling a conveyor belt
The following figure shows a conveyor belt that can be activated electrically. There are two
pushbutton switches at the beginning of the conveyor belt: S1 for START and S2 for STOP.
There are also two pushbutton switches at the end of the conveyor belt: S3 for START and
S4 for STOP. It is possible to start and stop the conveyor belt from either end.
MOTOR_ON
S1
S2
S3
S4
O start
O stop
O start
O stop
Implementation
The following table shows the definition of the tags used:
Name Data type Description
StartSwitch_Left (S1) BOOL Start switch on the left side of the
conveyor belt
StopSwitch_Left (S2) BOOL Stop switch on the left side of the
conveyor belt
StartSwitch_Right (S3) BOOL Start switch on the right side of
the conveyor belt
Programming the PLC
9.7 Programming examples
STEP 7 Basic V12.0
System Manual, 01/2013, 1397
Name Data type Description
StopSwitch_Right (S4) BOOL Stop switch on the right side of
the conveyor belt
MOTOR_ON BOOL Turn on the conveyor belt motor
The following networks show the FBD programming for solving this task:
Network 1:
The conveyor belt motor is switched on when Start switch "S1" or "S3" is pressed.
"StartSwitch_Left
>=1
S
"MOTOR_ON
"StartSwitch_Right
Network 2:
The conveyor belt motor is switched off when stop switch "S2" or "S4" is pressed.
"StopSwitch_Left"
>=1
R
"MOTOR_ON"
"StopSwitch_Right"
9.7.2.2 Example of detecting the direction of a conveyor belt
Detecting the direction of a conveyor belt
The following figure shows a conveyor belt that is equipped with two photoelectric barriers
(PEB1 and PEB2). The photoelectric barriers are designed to detect the direction in which an
object is moving on the conveyor belt.
Programming the PLC
9.7 Programming examples
STEP 7 Basic V12.0
1398 System Manual, 01/2013,
Implementation
The following table shows the definition of the tags used:
Name Data type Description
PEB1 BOOL Photoelectric barrier 1
PEB2 BOOL Photoelectric barrier 2
RIGHT BOOL Display during movement to right
LEFT BOOL Display during movement to left
CM1 BOOL Edge bit memory 1
CM2 BOOL Edge bit memory 2
The following networks show the FBD programming for solving this task:
Network 1:
If the signal state changes from "0" to "1" (positive edge) at photoelectric barrier "PEB1" and,
at the same time, the signal state at "PEB2" is "0", the object on the belt is moving to the left.
"PEB2
"PEB1
&
S
"RlGHT
R
"LEFT
P
"CM1
Network 2:
If the signal changes from "0" to "1" (positive edge) at photoelectric barrier "PEB2" and, at the
same time, the signal state at "PEB1" is "0", the object on the belt is moving to the right.
"PEB1
"PEB2
&
S
"RlGHT
R
"LEFT
P
"CM2
9.7.2.3 Example of detecting the fill level of a storage area
Detecting the fill level of a storage area
The following figure shows a system with two conveyor belts and a temporary storage area
between them. Conveyor belt 1 delivers packages to the storage area. A photoelectric barrier
at the end of conveyor belt 1 near the storage area detects how many packages are delivered
to the storage area. Conveyor belt 2 transports packages from the temporary storage area to
a loading dock onto which the packages are loaded for delivery to customers by truck. A
photoelectric barrier at the storage area exit detects how many packages leave the storage
Programming the PLC
9.7 Programming examples
STEP 7 Basic V12.0
System Manual, 01/2013, 1399
area to be transported to the loading dock. Five display lamps indicate the capacity of the
temporary storage area.
When a conveyor belt is restarted, the current count value is set to the number of packages
available in the storage area.
Display panel
Storage area
empty
incoming
packages
outgoing
packages
Storage area
not empty
Storage area
50% full
Storage area
90% full
Storage area
full
Temporary
storage area
for 100
packages
Conveyor belt 1 Conveyor belt 2
Photoelectric barrier 1 Photoelectric barrier 2
Implementation
The following table shows the definition of the tags used:
Name Data type Description
PEB1 BOOL Photoelectric barrier 1
PEB2 BOOL Photoelectric barrier 2
RESET BOOL Reset counter
LOAD BOOL Set counter to value of "CV"
parameter
STOCK INT Stock at restart
PACKAGECOUNT INT Number of packages in the
storage area (current count
value)
STOCK_PACKAGES BOOL Is set if the current count value
is greater than or equal to the
value of the tag "STOCK".
STOR_EMPTY BOOL Display lamp: Storage area
empty
STOR_NOT_EMPTY BOOL Display lamp: Storage area not
empty
STOR_50%_FULL BOOL Display lamp: Storage area 50%
full
Programming the PLC
9.7 Programming examples
STEP 7 Basic V12.0
1400 System Manual, 01/2013,
Name Data type Description
STOR_90%_FULL BOOL Display lamp: Storage area 90%
full
STOR_FULL BOOL Display lamp: Storage area full
VOLUME_50 INT Comparison value: 50 packages
VOLUME_90 INT Comparison value: 90 packages
VOLUME_100 INT Comparison value: 100
packages
The following networks show the FBD programming for activating the lamps:
Network 1:
When a package is delivered to the storage area, the signal state at "PEB1" switches from "0"
to "1" (positive signal edge). On a positive signal edge at "PEB1", the "Up" counter is enabled,
and the current count value of "PACKAGECOUNT" is increased by one.
When a package is delivered from the storage area to the loading dock, the signal state at
"PEB2" switches from "0" to "1" (positive signal edge). On a positive signal edge at "PEB2",
the "Down" counter is enabled, and the current count value of "PACKAGECOUNT" is
decreased by one.
If there are no packages in the storage area ("PACKAGECOUNT" = "0"), the "STOR_EMPTY"
tag is set to signal state "1", and the "Storage area empty" lamp is switched on.
The current count value can be reset to "0" if the "RESET" tag is set to signal state "1".
If the "LOAD" tag is set to signal state "1", the current count value is set to the value of the
"STOCK" tag. If the current count value is greater than or equal to the value of the "STOCK"
tag, the "STOCK_PACKAGES" tag supplies the signal state "1".
"CTUD_DB"
"STOCK"
CTUD
"LOAD"
"RESET"
"PEB2"
"PEB1"
"PACKAGECOUNT"
"STOR_EMPTY"
"STOCK_PACKAGE"
=
CU
CD
LD
QD
QU
CV
PV
R
lNT
Network 2:
As long as there are packages in the storage area, the "STOR_NOT_EMPTY" tag is set to
signal state "1", and the "Storage area not empty" lamp is switched on.
"STOR_EMPTY"
"STOR_NOT_EMPTY"
=
Network 3:
Programming the PLC
9.7 Programming examples
STEP 7 Basic V12.0
System Manual, 01/2013, 1401
If the number of packages in the storage area is greater than or equal to 50, the lamp for the
"Storage area 50% full" message switches on.
"VOLUME_50"
"PACKAGECOUNT"
"STOR_50%_FULL"
=
lN1
> =
lNT
lN2
<
"VOLUME_90"
"PACKAGECOUNT"
lNT
&
lN1
lN2
Network 4:
If the number of packages in the storage area is greater than or equal to 90, the "Storage area
90% full" lamp switches on.
"VOLUME_90"
"PACKAGECOUNT"
"STOR_90%_FULL"
=
lN1
> =
lNT
lN2
<
"VOLUME_100"
"PACKAGECOUNT"
lNT
&
lN1
lN2
Network 5:
If the number of packages in the storage area reaches 100, the lamp for the "Storage area
full" message switches on.
"VOLUME_100"
"PACKAGECOUNT"
"STOR_FULL"
=
lN1
> =
lNT
lN2
9.7.2.4 Example of controlling room temperature
Controlling room temperature
In a cold room, the temperature must be maintained below zero degrees Celsius. Any
temperature fluctuations are monitored by a sensor. If the temperature rises above zero
Programming the PLC
9.7 Programming examples
STEP 7 Basic V12.0
1402 System Manual, 01/2013,
degrees Celsius, the cooling system switches on for a preset time. The "Cooling system on"
lamp is lit during this time.
The cooling system and the lamp are turned off if one of the following conditions is met:
The sensor reports a temperature fall below zero degrees Celsius.
The preset cooling time has elapsed.
The pushbutton switch "Stop" has been pressed.
If the preset cooling time has expired and the temperature in the cold room is still too high, the
cooling system can be restarted by means of the pushbutton switch "RESET".
COOLlNG-
SYSTEM
TEMPERATURE
SENSOR
LAMP
RESET
STOP
Implementation
The following table shows the definition of the tags used:
Name Data type Comment
Sensor BOOL Temperature sensor signal
RESET BOOL Restart
STOP BOOL The cooling system is switched
off.
MaxCoolTime TIME Preset cooling time
This tag is defined in the
"DB_Cool" data block.
CurrCoolTime TIME Currently elapsed cooling time
This tag is defined in the
"DB_Cool" data block.
Cooling system BOOL The cooling system is switched
on.
Lamp BOOL The lamp for the "Cooling
system on" message is switched
on.
TempVariable BOOL Temporary tag
This tag stores the signal state
of the IEC time TP.
The following network shows the FBD programming for controlling room temperature:
Network 1:
Programming the PLC
9.7 Programming examples
STEP 7 Basic V12.0
System Manual, 01/2013, 1403
"Sensor"
&
"Reset"
"DB_Cooling".
MaxCoolTime
"DB_Cooling".
CurrCoolTime
"TP_DB"
=
"TempVariable"
TP
Time
lN
PT
ET
Q
Network 2:
=
"CoolSystem"
=
"Lamp"
"Sensor"
"Stop"
&
"TempVariable"
When the temperature in the cold room rises above zero degrees Celsius, the signal state at
the "Sensor" operand switches from "0" to "1" (positive signal edge). In the case of a positive
signal edge at the input IN of the time function, the preset cooling time is started and the
"TempVariable" receives the signal state "1". The signal state "1" of the "TempVariable" has
the result in network 2 that the cooling system as well as the display lamp are turned on. The
outputs "Sensor", "Cooling system" and "Lamp" must be programmed in network 2, because
you can program only one coil at output Q of the time function.
If the temperature in the cold room falls below zero degrees Celsius, the signal state of the
sensor switches back to "0". This switches the cooling system and lamp off.
If the sensor does not signal a temperature drop, the cooling system and lamp are switched
off after the preset cooling time has elapsed, at the latest. In this case, the cooling process
can be restarted by pressing the pushbutton switch "RESET". Pressing and releasing the
pushbutton switch generates a new positive signal edge at input IN, which restarts the cooling
system.
Using the pushbutton switch "STOP", the cooling system and the display lamp can be turned
off at any time.
9.7.3 STL programming examples
9.7.3.1 Example: Bit logic instructions
Controlling a conveyor belt
The following figure shows a conveyor belt that can be activated electrically. There are two
pushbutton switches at the beginning of the conveyor belt: S1 for START and S2 for STOP.
Programming the PLC
9.7 Programming examples
STEP 7 Basic V12.0
1404 System Manual, 01/2013,
There are also two pushbutton switches at the end of the conveyor belt: S3 for START and
S4 for STOP. It is possible to start and stop the conveyor belt from either end.
MOTOR_ON
S1
S2
S3
S4
O start
O stop
O start
O stop
Implementation
The following table shows the definition of the tags used:
Operand Declaration Data type Description
StartSwitch_Left (S1) Input BOOL Start switch on the left
side of the conveyor belt
StopSwitch_Left (S2) Input BOOL Stop switch on the left
side of the conveyor belt
StartSwitch_Right (S3) Input BOOL Start switch on the right
side of the conveyor belt
StopSwitch_Right (S4) Input BOOL Stop switch on the right
side of the conveyor belt
MOTOR_ON/OFF Output BOOL Switching the conveyor
belt motor on/off
The following STL program shows how to implement this task:
STL Explanation
O #S1 // Scan start switch S1 for "1".
O #S3 // Scan start switch S3 for "1".
S #"MOTOR_ON/OFF" // If one of the start switches (S1 or S3) returns the signal
state "1", the conveyor belt motor will be turned on.
O #S2 // Scan stop switch S2 for "1".
O #S4 // Scan stop switch S4 for "1".
R #"MOTOR_ON/OFF" // If one of the stop switches (S2 or S4) returns the signal
state "1", the conveyor belt motor will be turned off.
Programming the PLC
9.7 Programming examples
STEP 7 Basic V12.0
System Manual, 01/2013, 1405
9.7.3.2 Example of detecting the direction of a conveyor belt
Detecting the direction of a conveyor belt
The following figure shows a conveyor belt that is equipped with two photoelectric barriers
(PEB1 and PEB2). The photoelectric barriers are designed to detect the direction in which an
object is moving on the conveyor belt.
Implementation
The following table shows the definition of the tags used:
Name Declaration Data type Description
S1 Input BOOL Photoelectric barrier 1
S2 Input BOOL Photoelectric barrier 2
TM1 Input BOOL Edge bit memory 1
TM2 Input BOOL Edge bit memory 2
RIGHT Output BOOL Display for movement
to the right
LEFT Output BOOL Display for movement
to the left
The following STL program shows how to implement this example:
STL Explanation
A #S1 // Scan photoelectric barrier "S1" for "1"
FP #TM1 // Query positive edge
AN #S2 // Scan photoelectric barrier "S2" for "0"
S #LEFT //If the signal state changes from "0" to "1" (positive edge)
at the photoelectric barrier "S1" and, at the same time, the
signal state at the photoelectric barrier "S2" is "0", the
object on the belt is moving to the left.
// The display for movement to the left is activated.
A #S2 // Scan photoelectric barrier "S2" for "1"
FP #TM2 // Query positive edge
Programming the PLC
9.7 Programming examples
STEP 7 Basic V12.0
1406 System Manual, 01/2013,
STL Explanation
AN #S1 // Scan photoelectric barrier "S1" for "0"
S #RIGHT //If the signal state changes from "0" to "1" (positive edge)
at photoelectric barrier "S2" and, at the same time, the signal
state at photoelectric barrier "S1" is "0", the object on the
belt is moving to the right.
// The display for movement to the right is activated.
AN #S1 // Scan photoelectric barrier "S1" for "0"
AN #S2 // Scan photoelectric barrier "S2" for "0"
R #LEFT // The display for movement to the left will be turned off when
the signal state at both photoelectric barriers is "0".
R #RIGHT // The display for movement to the right will be turned off when
the signal state at both photoelectric barriers is "0".
9.7.3.3 Example of detecting the fill level of a storage area
Detecting the fill level of a storage area
The following figure shows a system with two conveyor belts and a temporary storage area
between them. Conveyor belt 1 delivers packages to the storage area. A photoelectric barrier
at the end of conveyor belt 1 near the storage area detects how many packages are delivered
to the storage area. Conveyor belt 2 transports packages from the temporary storage area to
a loading dock onto which the packages are loaded for delivery to customers by truck. A
photoelectric barrier at the storage area exit detects how many packages leave the storage
area to be transported to the loading dock. Five display lamps indicate the capacity of the
temporary storage area.
When a conveyor belt is restarted, the current count value is set to the number of packages
available in the storage area.
Display panel
Storage area
empty
incoming
packages
outgoing
packages
Storage area
not empty
Storage area
50% full
Storage area
90% full
Storage area
full
Temporary
storage area
for 100
packages
Conveyor belt 1 Conveyor belt 2
Photoelectric barrier 1 Photoelectric barrier 2
Programming the PLC
9.7 Programming examples
STEP 7 Basic V12.0
System Manual, 01/2013, 1407
Implementation
The following table shows the definition of the tags used:
Name Data type Address Description
PACKAGECOUNT COUNTER C1 Number of packages in
the storage area
(current count value)
Name Section Data type Description
LS1 Input BOOL Photoelectric barrier 1
LS2 Input BOOL Photoelectric barrier 2
STOR_EMPTY Output BOOL Display lamp: Storage
area empty
STOR_NOT_EMPTY Output BOOL Display lamp: Storage
area not empty
STOR_50%_FULL Output BOOL Display lamp: Storage
area 50% full
STOR_90%_FULL Output BOOL Display lamp: Storage
area 90% full
STOR_FULL Output BOOL Display lamp: Storage
area full
The following STL program shows how to implement this example:
STL Explanation
A #LS1 // Scan photoelectric barrier "LS1" for "1".
CU "PACKAGECOUNT" // At a positive edge at photoelectric barrier "LS1", the count
value of counter "PACKAGECOUNT" is increased by one.
A #LS2 // Scan photoelectric barrier "LS2" for "1".
CD "PACKAGECOUNT" // At a positive edge at photoelectric barrier "LS2", the count
value of counter "PACKAGECOUNT" is decreased by one.
AN "PACKAGECOUNT" // Scan count value for "0".
= #STOR_EMPTY // With a count value of "0" the display lamp "storage area
empty" is switched on.
A "PACKAGECOUNT" // Scan count value for "1".
= #STOR_NOT_EMPTY // With a count value greater than "0" the display lamp "Storage
area not empty" is switched on.
L 50 // Load the comparison value "50" to accumulator 1.
L "PACKAGECOUNT" // Move the comparison value to accumulator 2.
// Load the current count value to accumulator 1.
<=I // Compare values
= #"STOR_50%_FULL" // With a count value greater than or equal to "50" the display
lamp "Storage area 50% full" is switched on.
L 90 // Move the counter value to accumulator 2.
// Load the comparison value "90" to accumulator 1.
>=I // Compare values
Programming the PLC
9.7 Programming examples
STEP 7 Basic V12.0
1408 System Manual, 01/2013,
STL Explanation
= #"STOR_90%_FULL" // With a count value greater than or equal to "90" the display
lamp "Storage area 90% full" is switched on.
L "PACKAGECOUNT" // Load the current count value to accumulator 1.
L 100 // Move the counter value to accumulator 2.
// Load the comparison value "100" to accumulator 1.
>=I // Compare values
= #STOR_FULL // At a count value greater than "100" the display lamp "Storage
area full" is switched on.
9.7.3.4 Example of calculating an equation
Calculating an equation
The sample program shows you how to use three math instructions to calculate the following
equation:
RESULT = ((A + B) x C) /D
Implementation
The following table shows the declaration of the operands used in the PLC tag table:
Name Data type Comment
A INT First value for addition
B INT Second value for addition
C INT Multiplier
D INT Divisor
RESULT INT End result
The following STL program shows how to implement this example:
STL Explanation
L "A" // Load value of the operand "A" to accumulator 1
L "B" // Load value of operand "A" to accumulator 2
// Load value of the operand "B" to accumulator 1
+I // Add the values of accumulator 1 and 2
// Store sum in accumulator 1
L "C" // Move the sum to accumulator 2
// Load value of the operand "C" to accumulator 1
*I // Multiply the values of accumulator 1 and 2
// Store product in accumulator 1
L "D" // Move the product to accumulator 2
// Load value of the operand "D" to accumulator 1
/I // Divide the value of accumulator 2 by the value of accumulator
1
Programming the PLC
9.7 Programming examples
STEP 7 Basic V12.0
System Manual, 01/2013, 1409
STL Explanation
// Store result in accumulator 1
T "RESULT" // Transfer the result to operand "RESULT"
9.7.3.5 Example: Word logic instructions
Heating an oven
The following illustration shows an oven that is turned on with a start switch. The heating
process is started when the start switch is pressed. The heating period is set with digital
thumbwheels. The heating period is set in seconds using the BCD format.
Oven
lB0
Digital thumbwheels for setting the heating period
lB1
lW0
Bit
Byte
Start switch l 0.7
7... ...0 7... ...0
X X X X 0 0 0 1 1 0 0 1 0 0 0 1
4 4 4
Programming the PLC
9.7 Programming examples
STEP 7 Basic V12.0
1410 System Manual, 01/2013,
Implementation
The following table shows the declaration of the operands used in the PLC tag table:
Name Data type Address Comment
DURATION WORD EW0 Heating period in
seconds
I1.0 to I1.3:
Thumbwheels for
ones
I1.4 to I1.7:
Thumbwheels for
tens
I0.0 to I0.3:
Thumbwheels for
hundreds
HEATING TIMER T1 Time that is started with
the preset heating
period.
The following table shows the declaration of the operands used in the block interface of the
code block:
Name Section Data type Comment
START Input BOOL Start switch
START_HEATING Output BOOL Start of the heating
process
The following STL program shows how to implement this example:
STL Explanation
A "HEATING" // Scan to see if time has started
= #START_HEATING // Start the heating process
BEC // For RLO=1 End processing of block
// This prevents the "HEATING" time from being restarted if the
button is pressed
L "DURATION" // Load the heating period in accumulator 1
AW W#16#0FFF // Reset input bits I0.4 to I0.7 to "0"
OW W#16#4000 // Set seconds in bits I1.2 and I1.3 of accumulator 1
A #START // Scan start switch for "1"
SE "HEATING" // Start heating process as an extended pulse with a positive
edge at the start switch
Programming the PLC
9.7 Programming examples
STEP 7 Basic V12.0
System Manual, 01/2013, 1411
9.7.3.6 Example of a step sequence
Programming a step sequence
The following figure shows a station for removing glass containers from a pallet. The pallets
are transported on a conveyor belt to the station. When a pallet with glass containers reaches
the station, the conveyor belt will be stopped and a gripper moves from its basic position (P0)
to the position above the pallet (P2). Once the gripper is above the pallet, the gripping clamps
will open and the gripper lowered. Sensors detect the actual position of the gripper and the
status of the gripping clamps. The sequence of the gripper movement in this example is
implemented by a step sequence. You can program the additional steps required for removing
the bottles and transporting them on an additional conveyor belt.
Implementation
The following table shows the declaration of the operands used in the PLC tag table:
Name Data type Comment
NUMBER INT Step number
Tag_Error BOOL Operand that is set when the
step number is greater than 3 or
if one of the steps was not
executed.
The following table shows the declaration of the operands used in the block interface of the
code block:
Name Section Data type Comment
POS_0 Input BOOL Gripper in basic
position (P0)
POS_1 Input BOOL Gripper in position 1
(P1)
POS_2 Input BOOL Gripper in position 2
(P2)
GRIPPER_OPEN Input BOOL Gripping clamps open
OUT_POS_1 Output BOOL Move gripper to position
1
Programming the PLC
9.7 Programming examples
STEP 7 Basic V12.0
1412 System Manual, 01/2013,
Name Section Data type Comment
OUT_POS_2 Output BOOL Move gripper to position
2
OUT_GRIPPER Output BOOL Open gripping clamps
OUT_POS_3 Output BOOL Move gripper to position
3
The following STL program shows how to implement this example:
STL Explanation
L "NUMBER" // Load the step number to accumulator 1.
JL END // Start of the jump list
JU POSITION_0 // At a value of "0" in the accumulator 1 jump to jump
label "POSITION_0".
JU POSITION_1 // At a value of "1" in the accumulator 1 jump to jump
label "POSITION_1".
JU POSITION_2 // At a value of "2" in the accumulator 1 jump to jump
label "POSITION_2".
JU POSITION_3 // At a value of "3" in the accumulator 1 jump to jump
label "POSITION_3".
END: JU ERROR // End of the jump list
// At a step number greater than 3 jump to jump label
"ERROR".
POSITION_0: A #POS_0 // Jump label "POSITION_0"
// Scan to see if gripper is in basic position (P0).
= #OUT_POS_1 // If condition is met, set output "OUT_POS_1" and
move gripper to position 1 (P1).
JCN ERROR // With RLO "0" jump to jump label "ERROR".
JC NEXT // With RLO "1" jump to jump label "NEXT".
POSITION_1: A #POS_1 // Jump label "POSITION_1"
// Scan to see if gripper is in position 1 (P1).
= #OUT_POS_2 // If condition is met, set output "OUT_POS_2" and
move gripper to position 2 (P2).
JCN ERROR // With RLO "0" jump to jump label "ERROR".
JC NEXT // With RLO "1" jump to jump label "NEXT".
POSITION_2: A #POS_2 // Jump label "POSITION_2"
// Scan to see if gripper is in position 2 (P2).
= #OUT_GRIPPER // If condition is met, set output "OUT_GRIPPER" and
open gripping clamps.
JCN ERROR // With RLO "0" jump to jump label "ERROR".
JC NEXT // With RLO "1" jump to jump label "NEXT".
POSITION_3: A #POS_2 // Jump label "POSITION_3"
// Scan to see if gripper is in position 2 (P2).
A #GRIPPER_OPEN // Scan to see if the gripping clamps are open
= #OUT_POS_3 // If condition is met, set output "OUT_POS_3" and
move gripper to position 3 (P3).
JCN ERROR // With RLO "0" jump to jump label "ERROR".
JC NEXT // With RLO "1" jump to jump label "NEXT".
Programming the PLC
9.7 Programming examples
STEP 7 Basic V12.0
System Manual, 01/2013, 1413
STL Explanation
NEXT: INC 1 // Jump label "NEXT"
// Increase step number in accumulator 1 by one.
T "NUMBER" // Transfer step number to operand "NUMBER".
L 3 // Move the current step number to accumulator 2.
// Load value 3 to accumulator 1.
>I // Scan to see if current step number is greater than
3.
JC RESET_NUMBER // With a scan result "1" jump to jump label
"RESET_NUMBER" and continue with program processing
BEU // End block
RESET_NUMBER: L 0 // Jump label "RESET_NUMBER"
// Load value "0" in accumulator 1.
T "NUMBER" // Assign value "0" to operands "NUMBER" (step
number).
BEU // End block
ERROR: NOT // Jump label "ERROR"
= "Tag_Error" // Assign negated RLO to the operand "Tag_Error".
BEU // End block
9.7.4 SCL programming examples
9.7.4.1 Example: Bit logic instructions
Controlling a conveyor belt
The following figure shows a conveyor belt that can be activated electrically. There are two
pushbutton switches at the beginning of the conveyor belt: S1 for START and S2 for STOP.
There are also two pushbutton switches at the end of the conveyor belt: S3 for START and
S4 for STOP. It is possible to start and stop the conveyor belt from either end.
MOTOR_ON
S1
S2
S3
S4
O start
O stop
O start
O stop
Programming the PLC
9.7 Programming examples
STEP 7 Basic V12.0
1414 System Manual, 01/2013,
Implementation
The following table shows the definition of the tags used:
Operand Declaration Data type Description
StartSwitch_Left (S1) Input BOOL Start switch on the left
side of the conveyor belt
StopSwitch_Left (S2) Input BOOL Stop switch on the left
side of the conveyor belt
StartSwitch_Right (S3) Input BOOL Start switch on the right
side of the conveyor belt
StopSwitch_Right (S4) Input BOOL Stop switch on the right
side of the conveyor belt
MOTOR_ON Output BOOL Turn on the conveyor
belt motor
MOTOR_OFF Output BOOL Turn off the conveyor
belt motor
The following SCL program shows how to implement this task:
SCL
IF "StartSwitch_Left" OR "StartSwitch_Right" = 1 THEN 1 := "MOTOR_ON";
IF "StopSwitch_Left" OR "StopSwitch_Right" = 1 THEN 1 := "MOTOR_OFF";
The conveyor belt motor is switched on when start switch "StartSwitch_Left" or
"StartSwitch_Right" is pressed. The conveyor belt motor is switched off when stop switch
"StopSwitch_Left" or "StopSwitch_Right" is pressed.
See also
Logical expressions (Page 1161)
Programming the PLC
9.7 Programming examples
STEP 7 Basic V12.0
System Manual, 01/2013, 1415
9.7.4.2 Example of detecting the direction of a conveyor belt
Detecting the direction of a conveyor belt
The following figure shows a conveyor belt that is equipped with two photoelectric barriers
(PEB1 and PEB2). The photoelectric barriers are designed to detect the direction in which an
object is moving on the conveyor belt.
Implementation
The following table shows the definition of the tags used:
Name Declaration Data type Description
LS1 Input BOOL Photoelectric barrier 1
LS2 Input BOOL Photoelectric barrier 2
RIGHT Output BOOL Display for movement
to the right
LEFT Output BOOL Display for movement
to the left
The following SCL program shows how to implement this example:
SCL
IF "LS1" = 1 AND NOT "LS2" = 0 THEN 1 := "LEFT";
IF "LS2" = 1 AND NOT "LS1" = 0 THEN 1 := "RIGHT";
IF "LS2" = 0 THEN 0 := "RIGHT";
IF "LS1" = 0 THEN 0 := "LEFT";
If the photoelectric barrier "PEB1" has signal state "1" and the photoelectric barrier "PEB2"
has signal state "0" at the same time, the object on the belt is moving to the left. If the
photoelectric barrier "PEB2" has signal state "1" and the photoelectric barrier "PEB1" has signal
state "0" at the same time, the object on the belt is moving to the right. The displays for a
movement to the left or right will be turned off when the signal state at both photoelectric
barriers is "0".
Programming the PLC
9.7 Programming examples
STEP 7 Basic V12.0
1416 System Manual, 01/2013,
See also
Logical expressions (Page 1161)
9.7.4.3 Example of detecting the fill level of a storage area
Detecting the fill level of a storage area
The following figure shows a system with two conveyor belts and a temporary storage area
between them. Conveyor belt 1 delivers packages to the storage area. A photoelectric barrier
at the end of conveyor belt 1 near the storage area detects how many packages are delivered
to the storage area. Conveyor belt 2 transports packages from the temporary storage area to
a loading dock onto which the packages are loaded for delivery to customers by truck. A
photoelectric barrier at the storage area exit detects how many packages leave the storage
area to be transported to the loading dock. Five display lamps indicate the capacity of the
temporary storage area.
When a conveyor belt is restarted, the current count value is set to the number of packages
available in the storage area.
Display panel
Storage area
empty
incoming
packages
outgoing
packages
Storage area
not empty
Storage area
50% full
Storage area
90% full
Storage area
full
Temporary
storage area
for 100
packages
Conveyor belt 1 Conveyor belt 2
Photoelectric barrier 1 Photoelectric barrier 2
Implementation
The following table shows the definition of the tags used:
Name Declaration Data type Description
PEB1 Input BOOL Photoelectric barrier 1
PEB2 Input BOOL Photoelectric barrier 2
RESET Input BOOL Reset counter
Programming the PLC
9.7 Programming examples
STEP 7 Basic V12.0
System Manual, 01/2013, 1417
Name Declaration Data type Description
LOAD Input BOOL Set counter to value of
"CV" parameter
STOCK Input INT Stock at restart
PACKAGECOUNT Output INT Number of packages in
the storage area
(current count value)
STOCK_PACKAGES Output BOOL Is set if the current
count value is greater
than or equal to the
value of the tag
"STOCK".
STOR_EMPTY Output BOOL Display lamp: Storage
area empty
STOR_NOT_EMPTY Output BOOL Display lamp: Storage
area not empty
STOR_50%_FULL Output BOOL Display lamp: Storage
area 50% full
STOR_90%_FULL Output BOOL Display lamp: Storage
area 90% full
STOR_FULL Output BOOL Display lamp: Storage
area full
VOLUME_50 Input INT Comparison value: 50
packages
VOLUME_90 Input INT Comparison value: 90
packages
VOLUME_100 Input INT Comparison value: 100
packages
The following SCL program shows how to implement this example:
When a package is delivered to the storage area, the signal state at "PEB1" switches from "0"
to "1" (positive signal edge). On a positive signal edge at "PEB1", the "Up" counter is enabled,
and the current count value of "PACKAGECOUNT" is increased by one.
When a package is delivered from the storage area to the loading dock, the signal state at
"PEB2" switches from "0" to "1" (positive signal edge). On a positive signal edge at "PEB2",
the "Down" counter is enabled, and the current count value of "PACKAGECOUNT" is
decreased by one.
If there are no packages in the storage area ("PACKAGECOUNT" = "0"), the "STOR_EMPTY"
tag is set to signal state "1", and the "Storage area empty" lamp is switched on.
The current count value can be reset to "0" if the "RESET" tag is set to signal state "1".
If the "LOAD" tag is set to signal state "1", the current count value is set to the value of the
"STOCK" tag. If the current count value is greater than or equal to the value of the "STOCK"
tag, the "STOCK_PACKAGES" tag supplies the signal state "1".
SCL
"CTUD_DB".CTUD(CU := "PEB1",
CD := "PEB2",
R := "RESET",
Programming the PLC
9.7 Programming examples
STEP 7 Basic V12.0
1418 System Manual, 01/2013,
SCL
LD := "LOAD",
PV := "STOCK",
QU := "STOCK_PACKAGES",
QD := "STOR_EMPTY",
CV := "PACKAGECOUNT");
As long as there are packages in the storage area, the "STOR_NOT_EMPTY" tag is set to
signal state "1", and the "Storage area not empty" lamp is switched on.
SCL
"STOR_NOT_EMPTY" := NOT "STOR_EMPTY"
If the number of packages in the storage area is greater than or equal to 50, the lamp for
the"Storage area 50% full" message switches on.
SCL
IF "PACKAGECOUNT" >= "VOLUME_50" THEN "STOR_50%_FULL" := 1;
IF "PACKAGECOUNT" <= "VOLUME_90" THEN "STOR_50%_FULL" := 1;
If the number of packages in the storage area is greater than or equal to 90, the "Storage area
90% full" lamp switches on.
SCL
IF "PACKAGECOUNT" >= "VOLUME_90" THEN "STOR_90%_FULL" := 1;
IF "PACKAGECOUNT" <= "VOLUME_100" THEN "STOR_90%_FULL" := 1;
If the number of packages in the storage area reaches 100, the lamp for the "Storage area
full" message switches on.
SCL
IF "PACKAGECOUNT" >= "VOLUME_100" THEN "STOR_FULL" := 1;
See also
Logical expressions (Page 1161)
Programming the PLC
9.7 Programming examples
STEP 7 Basic V12.0
System Manual, 01/2013, 1419
9.8 References
9.8.1 General parameters of the instructions
9.8.1.1 Meaning of the parameters REQ, RET_VAL and BUSY with asynchronous instructions
Asynchronous instructions
For instructions that work asynchronously, the function is executed with several calls.
Identification of the job
If you use asynchronous instructions to trigger a process interrupt, output control commands
to DP slaves, start a data transfer, or abort a non-configured connection with one of the SFCs
listed above and then call the same SFC again before the current job is completed, then the
reaction of the SFC will depend on whether the second call involves the same job.
Parameter REQ
The input parameter REQ (request) is used solely to start the job:
If you call the instruction for a job that is not currently active, the job is started with REQ =
1 (case 1).
If a particular job has been started and not yet completed and you call the instruction again
to perform the same job (for example, in a cyclic interrupt OB), then REQ is not evaluated
by the instruction (case 2).
Parameter RET_VAL and BUSY
The output parameters RET_VAL and BUSY indicate the status of the job.
Pay attention to the note in section: Evaluating errors with output parameter RET_VAL
(Page 1422)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1420 System Manual, 01/2013,
In case 1 (first call with REQ=1), the input parameter will be entered in
RET_VALW#16#7001 if system resources are available and supply is correct. BUSY will
be set.
If the required system resources are currently being used or the input parameters have
errors, the corresponding error code is entered in RET_VAL and BUSY has the value 0.
In case 2 (interim call) W#16#7002 will be entered in RET_VAL (this corresponds to a
warning: Job still being processed!), and BUSY will be set.
The following applies to the last call for a job:
For instruction "DPNRM_DG (Page 2156)", the number of data in bytes will entered as
integer in RET_VAL in case there are no errors in data transmission. BUSY has the
value "0" in this case.
If there is an error, then the error information will be entered in RET_VAL and you should
not evaluate BUSY in this case.
For all other instructions, "0" will be entered in RET_VAL if the job was executed without
errors and BUSY has the value "0" in this case. If there is an error, the error code is
entered in RET_VAL and BUSY has the value "0" in this case.
Note
If the first and last call coincide, the reaction is the same for RET_VAL and BUSY as
described for the last call.
Overview
The following table provides you with an overview of the relationships explained above. In
particular, it shows the possible values of the output parameters if the execution of the job is
not completed after an instruction call has been completed.
Note
Following every call, you must evaluate the relevant output parameters in your program.
Relationship between call, REQ, RET_VAL and BUSY during execution of a "running" job.
Number of the
call
Type of call REQ RET_VAL BUSY
1 First call 1 W#16#7001 1
Error code 0
2 to (n - 1) Intermediate call irrelevant W#16#7002 1
n Last call irrelevant W#16#0000, if no errors have occurred. 0
Error code if errors occurred 0
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1421
9.8.1.2 Evaluating errors with output parameter RET_VAL
Types of error information
An executed instruction indicates in the user program whether or not the CPU was able to
execute the function of the instruction successfully.
You can obtain information about any errors that occurred in two ways:
In the BR bit of the status word
in the output parameter RET_VAL (return value).
Note
Before evaluating the output parameters specific to an instruction, you should always
follow the steps below:
First, evaluate the BR bit of the status word.
Then check the output parameter RET_VAL.
If the BR bit indicates that an error has occurred or if RET_VAL contains a general error
code, you should not evaluate the instruction-specific output parameters.
Error information in the return value
An instruction indicates that an error occurred during its execution by entering the value "0" in
the binary result bit (BR) of the status word. Some instructions provide an additional error code
at an output parameter known as the return value (RET_VAL). If a general error is entered in
the output parameter RET_VAL (see below for explanation), this is only indicated by the value
"0" in the BR bit of the status word.
The return value is of the data type integer (INT). The relationship of the return value to the
value "0" indicates whether or not an error occurred during execution of the function.
CPU execution of the
instruction
BR Return value Sign of the integer
With error(s) 0 less than "0" negative
(sign bit is "1")
Without error 1 greater than or
equal to "0"
positive
(sign bit is "0")
Reacting to error information
There are two types of error codes in RET_VAL:
A general error code that all instructions can output and
A specific error code that an instruction can output and which relates to its specific function.
You can write your program so that it reacts to the errors that occur during execution of an
instruction. This way you prevent further errors occurring as a result of the first error.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1422 System Manual, 01/2013,
General and specific error information
The return value (RET_VAL) of an instruction provides one of the two following types of error
codes:
A general error code that relates to errors that can occur in any instruction.
A specific error code that relates only to the particular instruction.
Even though the data type of the output parameter RET_VAL is an integer (INT), the error
codes for the instruction are grouped according to hexadecimal values. If you want to examine
a return value and compare the value with the error codes listed in this documentation, then
display the error code in hexadecimal format.
The figure below shows the structure of a system function error code in hexadecimal format.
Event number or error class and single error
Error code, e.g. W#16#8081
lf x = '0', then you are dealing with a specific error code of an instruction. The
specific error code is included in the description of the individual instruction.
lf x > = '0', then you are dealing with a general error code of an instruction. ln this
case x is the number of the instruction parameter that has caused the error. The
possible general error codes are listed in the following table.
Sign bit = 1 indicates that an error has occurred.
15 8 7 0
1
x
General error information
The general error code indicates errors that can occur in all instructions. A general error code
consists of the following two numbers:
A parameter number from 1 to 111, where 1 indicates the first parameter of the called
instruction, 2 the second parameter, and so forth.
An event number from 0 to 127. The event number indicates that a synchronous error
occurred.
The following table lists the codes for general errors and an explanation of each error.
Bits
Parameter number Event number
Sign
15 8 7 0
1
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1423
Note
If a general error code was entered in RET_VAL, then the following situations are possible:
The action associated with the instruction may have been started or already completed.
A specific instruction error may have occurred when the action was performed. As a result
of a general error that occurred later, the specific error could, however, no longer be
indicated.
Specific error information
Some instructions have a return value that provides an error code specific for the instruction.
A specific error code indicates errors that can occur only in specific instructions.
A specific error code consists of the following two numbers:
An error class from 0 to 7.
An error number from 0 to 15.
Bits
Error class Single error
Sign
15 8 7 0
1
4 3
0 1
General error codes
The following table explains the general error codes of a return value. The error code is shown
in hexadecimal format. The letter x in each code number is simply a place holder and
represents the number of the system function parameter that caused the error.
General error codes
Error code
(W#16#...)
Explanation
8x7F Internal error
This error code indicates an internal error at parameter x.
8x01 Illegal syntax ID at an VARIANT parameter
8x22 Range length error when reading a parameter.
8x23 Range length error when writing a parameter.
This error code indicates that the parameter x is located either entirely or partly outside
the range of an address, or that the length of a bit range is not a multiple of 8 with an
VARIANT parameter.
8x24 Range error when reading a parameter.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1424 System Manual, 01/2013,
Error code
(W#16#...)
Explanation
8x25 Range error when writing a parameter.
This error code indicates that the parameter x is located in a range that is illegal for
the system function. Refer to the descriptions of the individual functions for information
about the illegal ranges.
8x26 The parameter contains a timer cell number that is too high.
This error code indicates that the timer cell specified in parameter x does not exist.
8x27 The parameter contains a counter cell number that is too high (counter number error).
This error code indicates that the counter cell specified in parameter x does not exist.
8x28 Alignment error when reading a parameter.
8x29 Alignment error when writing a parameter.
This error code indicates that the reference to parameter x is an operand with bit
address that is not equal to 0.
8x30 The parameter is located in a read-only global DB.
8x31 The parameter is located in a read-only instance DB.
This error code indicates that parameter x is located in a read-only data block. If the
data block was opened by the system function itself, the system function always
returns the value W#16#8x30.
8x32 The parameter contains a DB number that is too high (DB number error).
8x34 The parameter contains an FC number that is too high (FC number error).
8x35 The parameter contains an FB number that is too high (FB number error).
This error code indicates that parameter x contains a block number higher than the
highest permitted number.
8x3A The parameter contains the number of a DB that is not loaded.
8x3C The parameter contains the number of an FC that is not loaded.
8x3E The parameter contains the number of an FB that is not loaded.
8x42 An access error occurred while the system was attempting to read a parameter from
the peripheral input area.
8x43 An access error occurred while the system was attempting to write a parameter to the
peripheral output area.
8x44 Error in the nth (n > 1) read access after an error occurred.
8x45 Error in the nth (n > 1) write access after an error occurred.
This error code indicates that access to the required parameter is denied.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1425
9.8.2 Basic instructions
9.8.2.1 LAD
Bit logic operations
---| |---: Normally open contact
Description
The activation of the normally open contact depends on the signal state of the associated
operand. When the operand has signal state "1", the normally open contact closes and the
signal state at the output is set to the signal state of the input.
When the operand has signal state "0", the normally open contact is not activated and the
signal state at the output of the instruction is reset to "0".
Two or more normally open contacts are linked bit-by-bit by AND when connected in series.
With a series connection, power flows when all contacts are closed.
The normally open contacts are linked by OR when connected in parallel. With a parallel
connection, power flows when one of the contacts is closed.
Parameter
The following table shows the parameters of the instruction:
Paramete
r
Declaratio
n
Data
type
Memory area Description
S7-1200 S7-1500
<Operan
d>
Input BOOL I, Q, M, D, L I, Q, M, D, L, T, C Operand whose
signal state is
queried.
Example
The following example shows how the instruction works:
"Tagln_1" "Tagln_2" "TagOut"
"Tagln_3"
The "TagOut" operand is set when one of the following conditions is fulfilled:
The operands "TagIn_1" and "TagIn_2" have signal state "1".
The operand "TagIn_3" has the signal state "1".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1426 System Manual, 01/2013,
See also
Overview of the valid data types (Page 899)
---| / |---: Normally closed contact
Description
The activation of the normally closed contact depends on the signal state of the associated
operand. When the operand has signal state "1", the normally closed contact opens and the
signal state at the output of the instruction is reset to "0".
When the operand has signal state "0", the normally closed contact is not enabled and the
signal state of the input is transferred to the output.
Two or more normally closed contacts are linked bit-by-bit by AND when connected in series.
With a series connection, power flows when all contacts are closed.
The normally closed contacts are linked by OR when connected in parallel. With a parallel
connection, power flows when one of the contacts is closed.
Parameter
The following table shows the parameters of the instruction:
Parameter Declaratio
n
Data type Memory area Description
S7-1200 S7-1500
<Operand> Input BOOL I, Q, M, D, L I, Q, M, D, L, T, C Operand
whose signal
state is
queried.
Example
The following example shows how the instruction works:
"Tagln_1" "Tagln_2" "TagOut"
"Tagln_3"
The "TagOut" operand is set when one of the following conditions is fulfilled:
The operands "TagIn_1" and "TagIn_2" have signal state "1".
The operand "TagIn_3" has the signal state "0".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1427
See also
Overview of the valid data types (Page 899)
--|NOT|--: Invert RLO
Description
You use the "Invert RLO" instruction to invert the signal state of the result of logic operation
(RLO). If the signal state is "1" at the input of the instruction, the output of the instruction has
signal state "0". If the signal state is "0" at the input of the instruction, the output has the signal
state "1".
Example
The following example shows how the instruction works:
NOT
"Tagln_1"
"Tagln_2"
"TagOut"
"Tagln_3"
Operand "TagOut" is reset when one of the following conditions is fulfilled:
The operand "TagIn_1" has the signal state "1".
The signal state of the operands "TagIn_2" and "TagIn_3" is "1".
---( )---: Assignment
Description
You can use the "Assignment" instruction to set the bit of a specified operand. If the result of
logic operation (RLO) at the input of the coil has signal state "1", the specified operand is set
to signal state "1". If the signal state is "0" at the input of the coil, the bit of the specified operand
is reset to "0".
The instruction does not influence the RLO. The RLO at the input of the coil is sent directly to
the output.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1428 System Manual, 01/2013,
Parameter
The following table shows the parameters of the "Assignment" instruction:
Parameter Declaration Data type Memory area Description
<Operand> Output BOOL I, Q, M, D, L Operand to which
the RLO is
assigned.
Example
The following example shows how the instruction works:
"Tagln_1" "Tagln_2" "TagOut_1"
"TagOut_2" "Tagln_3" "Tagln_4"
The "TagOut_1" operand is set when one of the following conditions is fulfilled:
The operands "TagIn_1" and "TagIn_2" have signal state "1".
The signal state of the operand "TagIn_3" is "0".
The "TagOut_2" operand is set when one of the following conditions is fulfilled:
Operands "TagIn_1", "TagIn_2", and "TagIn_4" have signal state "1".
The signal state of the "TagIn_3" operand is "0" and the signal state of the "TagIn_4"
operand is "1".
See also
Overview of the valid data types (Page 899)
--( / )--: Negate assignment
Description
The "Negate assignment" instruction inverts the result of logic operation (RLO) and assigns it
to the specified operand. When the RLO at the input of the coil is "1", the operand is reset.
When the RLO at the input of the coil is "0", the operand is set to signal state "1".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1429
Parameter
The following table shows the parameters of the "Negate assignment" instruction:
Parameter Declaration Data type Memory area Description
<Operand> Output BOOL I, Q, M, D, L Operand to which
the RLO is
assigned.
Example
The following example shows how the instruction works:
/
"Tagln_1" "Tagln_2" "TagOut_1"
"TagOut_2" "Tagln_3" "Tagln_4"
Operand "TagOut_1" is reset when one of the following conditions is fulfilled:
The operands "TagIn_1" and "TagIn_2" have signal state "1".
The signal state of the operand "TagIn_3" is "0".
See also
Overview of the valid data types (Page 899)
---( R )---: Reset output
Description
You can use the "Reset output" instruction to reset the signal state of a specified operand to
"0".
The instruction is only executed if the result of logic operation (RLO) at the input of the coil is
"1". If power flows to the coil (RLO = "1"), the specified operand is reset to "0". If the RLO at
the input of the coil is "0" (no signal flow to the coil), the signal state of the specified operand
remains unchanged.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1430 System Manual, 01/2013,
Parameter
The following table shows the parameters of the "Reset output" instruction:
Parameter Declaration Data type Memory area
S7-1200 S7-1500 Description
<Operand> Output BOOL I, Q, M, D, L I, Q, M, D, L, T,
C
Operand that
is reset when
RLO = "1".
Example
The following example shows how the instruction works:
R
"Tagln_1" "Tagln_2" "TagOut"
"Tagln_3"
Operand "TagOut" is reset when one of the following conditions is fulfilled:
The operands "TagIn_1" and "TagIn_2" have signal state "1".
The signal state of the operand "TagIn_3" is "0".
See also
Overview of the valid data types (Page 899)
---( S )---: Set output
Description
You can use the "Set output" instruction to set the signal state of a specified operand to "1".
The instruction is only executed if the result of logic operation (RLO) at the input of the coil is
"1". If power flows to the coil (RLO = "1"), the specified operand is set to "1". If the RLO at the
input of the coil is "0" (no signal flow to the coil), the signal state of the specified operand
remains unchanged.
Parameter
The following table shows the parameters of the "Set output" instruction:
Parameter Declaration Data type Memory area Description
<Operand> Output BOOL I, Q, M, D, L Operand which is
set with RLO = "1".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1431
Example
The following example shows how the instruction works:
S
"Tagln_1" "Tagln_2" "TagOut"
"Tagln_3"
The "TagOut" operand is set when one of the following conditions is fulfilled:
The operands "TagIn_1" and "TagIn_2" have signal state "1".
The signal state of the operand "TagIn_3" is "0".
See also
Overview of the valid data types (Page 899)
SET_BF: Set bit field
Description
You use the instruction "Set bit field" to set multiple bits starting from a certain address.
You determine the number of bits to be set using the value of <Operand1>. The address of
the first bit to be set is defined by <Operand2>. If the value of <Operand1> is greater than the
number of bits in a selected byte, then the bits of the next byte will be set. The bits remain set
until they are explicitly reset, for example, by another instruction.
The instruction is only executed if the result of logic operation (RLO) at the input of the coil is
"1". If the RLO at the input of the coil is "0", the instruction does not execute.
Parameter
The following table shows the parameters of the "Set bit field" instruction:
Parameter Declaration Data type Memory area Description
<Operand2> Output BOOL I, Q, M
In the case of a DB
or an IDB, an
element of an
ARRAY[..] of
BOOL
Pointer to the first
bit to be set.
<Operand1> Input UINT Constant Number of bits to
be set.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1432 System Manual, 01/2013,
Example
The following example shows how the instruction works:
5
( SET_BF )
"Tagln_1" "Tagln_2" "MyDB".MyBoolArray[4]
If the operands "TagIn_1" and "TagIn_2" have the signal state "1", 5 bits are set starting at the
address of the operand "MyDB".MyBoolArray[4]
See also
Overview of the valid data types (Page 899)
RESET_BF: Reset bit field
Description
You use the "Reset bit field" instruction to reset several bits starting from a certain address.
You specify the number of bits to be reset using the value of <Operand1>. The address of the
first bit to be reset is specified by <Operand2>. If the value of <Operand1> is greater than the
number of bits in a selected byte, the bits of the next byte will be reset. The bits remain reset
until they are explicitly set, for example, by another instruction.
The instruction is only executed if the result of logic operation (RLO) at the input of the coil is
"1". If the RLO at the input of the coil is "0", the instruction does not execute.
Parameter
The following table shows the parameters of the "Reset bit field" instruction:
Parameter Declaration Data type Memory area Description
<Operand2> Output BOOL I, Q, M
In the case of a DB
or an IDB, an
element of an
ARRAY[..] of
BOOL
Pointer to the first
bit to be reset.
<Operand1> Input UINT Constant Number of bits to
be reset.
Example
The following example shows how the instruction works:
5
( RESET_BF )
"Tagln_1" "Tagln_2" "MyDB".MyBoolArray[4]
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1433
If the operands "TagIn_1" and "TagIn_2" have the signal state "1", 5 bits are reset starting at
the address of the operand "MyDB".MyBoolArray[4]
See also
Overview of the valid data types (Page 899)
SR: Set/reset flip-flop
Description
Use the instruction "Set/reset flip-flop" to set or reset the bit of the specified operand, depending
on the signal state of the inputs S and R1. If the signal state is "1" at input S and "0" at input
R1, the specified operand is set to "1". If the signal state is "0" at input S and "1" at input R1,
the specified operand will be reset to "0".
Input R1 takes priority over input S. When the signal state is "1" on both inputs S and R1, the
signal state of the specified operand is reset to "0".
The instruction is not executed if the signal state at the two inputs S and R1 is "0". The signal
state of the operand then remains unchanged.
The current signal state of the operand is transferred to output Q and can be queried there.
Parameter
The following table shows the parameters of the "Set/reset flip-flop" instruction:
Parameter Declaration Data type Memory area Description
S7-1200 S7-1500
S Input BOOL I, Q, M, D, L I, Q, M, D, L Enable setting
R1 Input BOOL I, Q, M, D, L I, Q, M, D, L, T,
C
Enable
resetting
<Operand> InOut BOOL I, Q, M, D, L I, Q, M, D, L Operand that
is set or reset.
Q Output BOOL I, Q, M, D, L I, Q, M, D, L Signal state of
the operand
Example
The following example shows how the instruction works:
S
R1
SR
Q
"Tagln_1"
"Tagln_2"
"TagOut"
"TagSR"
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1434 System Manual, 01/2013,
The operands "TagSR" and "TagOut" are set when the following conditions are fulfilled:
The operand "TagIn_1" has the signal state "1".
The operand "TagIn_2" has the signal state "0".
The operands "TagSR" and "TagOut" are reset when one of the following conditions is fulfilled:
The operand "TagIn_1" has signal state "0" and the operand "TagIn_2" has signal state "1".
The operands "TagIn_1" and "TagIn_2" have signal state "1".
See also
Overview of the valid data types (Page 899)
RS: Reset/set flip-flop
Description
You can use the "Reset/set flip-flop" instruction to reset or set the bit of a specified operand
based on the signal state of the inputs R and S1. If the signal state is "1" at input R and "0" at
input S1, the specified operand will be reset to "0". If the signal state is "0" at input R and "1"
at input S1, the specified operand is set to "1".
Input S1 takes priority over input R. When the signal state is "1" at both inputs R and S1, the
signal state of the specified operand is set to "1".
The instruction is not executed if the signal state at the two inputs R and S1 is "0". The signal
state of the operand then remains unchanged.
The current signal state of the operand is transferred to output Q and can be queried there.
Parameter
The following table shows the parameters of the "Reset/set flip-flop" instruction:
Parameter Declaration Data type Memory area Description
S7-1200 S7-1500
R Input BOOL I, Q, M, D, L I, Q, M, D, L Enable
resetting
S1 Input BOOL I, Q, M, D, L I, Q, M, D, L, T,
C
Enable setting
<Operand> InOut BOOL I, Q, M, D, L I, Q, M, D, L Operand that
is reset or set.
Q Output BOOL I, Q, M, D, L I, Q, M, D, L Signal state of
the operand
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1435
Example
The following example shows how the instruction works:
R
S1
RS
Q
"Tagln_1"
"Tagln_2"
"TagOut"
"TagRS"
The operands "TagRS" and "TagOut" are reset when the following conditions are fulfilled:
The operand "TagIn_1" has the signal state "1".
The operand "TagIn_2" has the signal state "0".
The operands "TagRS" and "TagOut" are set when one of the following conditions is fulfilled:
The operand "TagIn_1" has signal state "0" and the operand "TagIn_2" has signal state "1".
The operands "TagIn_1" and "TagIn_2" have signal state "1".
See also
Overview of the valid data types (Page 899)
--|P|--: Scan operand for positive signal edge
Description
You can use the "Scan operand for positive signal edge" instruction to determine if there is a
"0" to "1" change in the signal state of a specified operand (<Operand1>). The instruction
compares the current signal state of <Operand1> with the signal state of the previous scan
that is saved in an edge memory bit (<Operand2>). If the instruction detects a change in the
result of logic operation (RLO) from "0" to "1", there is a positive, rising edge.
If a positive edge is detected, the output of the instruction has the signal state "1". In all other
cases, the signal state at the output of the instruction is "0".
Specify the operand to be queried (<Operand1>) in the operand placeholder above the
instruction. Specify the edge memory bit (<Operand2>) in the operand placeholder below the
instruction.
Note
The address of the edge memory bit must not be used more than once in the program,
otherwise the bit memory is overwritten. This step influences the edge evaluation and the
result is therefore no longer unique. The memory area of the edge memory bit must be located
in a DB (static area for FB) or in the bit memory area.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1436 System Manual, 01/2013,
Parameter
The following table shows the parameters of the "Scan operand for positive signal edge"
instruction:
Parameter Declaration Data type Memory area Description
S7-1200 S7-1500
<Operand1> Input BOOL I, Q, M, D, L I, Q, M, D, L, T, C Signal to be
scanned
<Operand2> InOut BOOL I, Q, M, D, L I, Q, M, D, L Edge memory bit
in which the
signal state of
the previous
query is saved.
Example
The following example shows how the instruction works:
P
"Tagln_1" "Tagln_2" "Tagln_3" "Tagln_4" "Tagln_5" "TagOut"
"Tag_M"
Operand "TagOut" is set when the following conditions are fulfilled:
The operands "TagIn_1", "TagIn_2", and "TagIn_3" have signal state "1".
There is a rising edge at operand "TagIn_4". The signal state of the previous scan is stored
in the edge memory bit "Tag_M".
The signal state of the operand "TagIn_5" is "1".
See also
Overview of the valid data types (Page 899)
--|N|--: Scan operand for negative signal edge
Description
You can use the "Scan operand for negative signal edge" instruction to determine if there is a
"1" to "0" change in the signal state of a specified operand (<Operand1>). The instruction
compares the current signal state of <Operand1> with the signal state of the previous scan
that is saved in an edge memory bit <Operand2>. If the instruction detects a change in the
result of logic operation (RLO) from "1" to "0", there is a negative, falling edge.
If a negative signal edge is detected, the output of the instruction has the signal state "1". In
all other cases, the signal state at the output of the instruction is "0".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1437
Specify the operand to be queried (<Operand1>) in the operand placeholder above the
instruction. Specify the edge memory bit (<Operand2>) in the operand placeholder below the
instruction.
Note
The address of the edge memory bit must not be used more than once in the program,
otherwise the bit memory is overwritten. This step influences the edge evaluation and the
result is therefore no longer unique. The memory area of the edge memory bit must be located
in a DB (static area for FB) or in the bit memory area.
Parameter
The following table shows the parameters of the "Scan operand for negative signal edge"
instruction:
Parameter Declaration Data type Memory area Description
S7-1200 S7-1500
<Operand1
>
Input BOOL I, Q, M, D, L I, Q, M, D, L, T, C Signal to be
scanned
<Operand2
>
InOut BOOL I, Q, M, D, L I, Q, M, D, L Edge memory bit
in which the
signal state of the
previous query is
saved.
Example
The following example shows how the instruction works:
N
"Tagln_1" "Tagln_2" "Tagln_3" "Tagln_4" "Tagln_5" "TagOut"
"Tag_M"
Operand "TagOut" is set when the following conditions are fulfilled:
The operands "TagIn_1", "TagIn_2", and "TagIn_3" have signal state "1".
There is a negative signal edge at operand "TagIn_4". The signal state of the previous scan
is stored in the edge memory bit "Tag_M".
The signal state of the operand "TagIn_5" is "1".
See also
Overview of the valid data types (Page 899)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1438 System Manual, 01/2013,
--(P)--: Set operand on positive signal edge
Description
You can use the "Set operand on positive signal edge" instruction to set a specified operand
(<Operand1>) when there is a "0" to "1" change in the result of logic operation (RLO). The
instruction compares the current RLO with the RLO from the previous query, which is saved
in the edge memory bit (<Operand2>). If the instruction detects a change in the RLO from "0"
to "1", there is a positive signal edge.
When a positive signal edge is detected, <Operand1> is set to signal state "1" for one program
cycle. In all other cases, the operand has the signal state "0".
Specify the operand to be set (<Operand1>) in the operand placeholder above the instruction.
Specify the edge memory bit (<Operand2>) in the operand placeholder below the instruction.
Note
The address of the edge memory bit must not be used more than once in the program,
otherwise the bit memory is overwritten. This step influences the edge evaluation and the
result is therefore no longer unique. The memory area of the edge memory bit must be located
in a DB (static area for FB) or in the bit memory area.
Parameter
The following table shows the parameters of the "Set operand on positive signal edge"
instruction:
Parameter Declaration Data type Memory area Description
<Operand1> Output BOOL I, Q, M, D, L Operand which is
set by a positive
edge.
<Operand2> InOut BOOL I, Q, M, D, L Edge memory bit
Example
The following example shows how the instruction works:
P
"Tagln_1" "Tagln_2"
"Tagln_3"
"TagOut"
"Tag_M"
Operand "TagOut" is set for one program cycle, when the signal state at the input of the coil
switches from "0" to "1" (positive signal edge). In all other cases, the operand "TagOut" has
the signal state "0".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1439
See also
Overview of the valid data types (Page 899)
--(N)--: Set operand on negative signal edge
Description
You can use the "Set operand on negative signal edge" instruction to set a specified operand
(<Operand1>) when there is a "1" to "0" change in the result of logic operation (RLO). The
instruction compares the current RLO with the RLO from the previous query, which is saved
in the edge memory bit (<Operand2>). If the instruction detects a change in the RLO from "1"
to "0", there is a negative edge.
When a negative signal edge is detected, <Operand1> is set to signal state "1" for one program
cycle. In all other cases, the operand has the signal state "0".
Specify the operand to be set (<Operand1>) in the operand placeholder above the instruction.
Specify the edge memory bit (<Operand2>) in the operand placeholder below the instruction.
Note
The address of the edge memory bit must not be used more than once in the program,
otherwise the bit memory is overwritten. This step influences the edge evaluation and the
result is therefore no longer unique. The memory area of the edge memory bit must be located
in a DB (static area for FB) or in the bit memory area.
Parameter
The following table shows the parameters of the "Set operand on negative signal edge"
instruction:
Parameter Declaration Data type Memory area Description
<Operand1> Output BOOL I, Q, M, D, L Operand which is
set by a negative
edge.
<Operand2> InOut BOOL I, Q, M, D, L Edge memory bit
Example
The following example shows how the instruction works:
N
"Tagln_1" "Tagln_2"
"Tagln_3"
"TagOut"
"Tag_M"
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1440 System Manual, 01/2013,
Operand "TagOut" is set for one program cycle, when the signal state at the input of the coil
switches from "1" to "0" (negative signal edge). In all other cases, the operand "TagOut" has
the signal state "0".
See also
Overview of the valid data types (Page 899)
P_TRIG: Scan RLO for positive signal edge
Description
Use the "Scan RLO for positive signal edge" instruction to query a "0" to "1" change in the
signal state of the result of logic operation (RLO). The instruction compares the current signal
state of the RLO with the signal state of the previous query, which is saved in an edge memory
bit (<operand>). If the instruction detects a change in the RLO from "0" to "1", there is a positive
signal edge.
If a positive edge is detected, the output of the instruction has the signal state "1". In all other
cases, the signal state at the output of the instruction is "0".
Note
The address of the edge memory bit must not be used more than once in the program,
otherwise the bit memory is overwritten. This step influences the edge evaluation and the
result is therefore no longer unique. The memory area of the edge memory bit must be located
in a DB (static area for FB) or in the bit memory area.
Parameter
The following table shows the parameters of the "Scan RLO for positive signal edge" instruction:
Parameter Declaration Data type Memory area Description
CLK Input BOOL I, Q, M, D, L Current RLO
<Operand> InOut BOOL M, D Edge memory bit
in which the RLO
of the previous
query is saved.
Q Output BOOL I, Q, M, D, L Result of edge
evaluation
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1441
Example
The following example shows how the instruction works:
JMP
P_TRlG
CLK Q
CAS1
"Tagln_1" "Tagln_2"
"Tagln_3"
"Tag_M"
The RLO of the previous query is saved in the edge memory bit "Tag_M". If a "0" to "1" change
is detected in the signal state of the RLO, the program jumps to jump label CAS1.
See also
Overview of the valid data types (Page 899)
N_TRIG: Scan RLO for negative signal edge
Description
Use the "Scan RLO for negative signal edge" instruction to query a "1" to "0" change in the
signal state of the result of logic operation (RLO). The instruction compares the current signal
state of the RLO with the signal state of the previous query, which is saved in an edge memory
bit (<operand>). If the instruction detects a change in the RLO from "1" to "0", there is a negative
edge.
If a negative signal edge is detected, the output of the instruction has the signal state "1". In
all other cases, the signal state at the output of the instruction is "0".
Note
The address of the edge memory bit must not be used more than once in the program,
otherwise the bit memory is overwritten. This step influences the edge evaluation and the
result is therefore no longer unique. The memory area of the edge memory bit must be located
in a DB (static area for FB) or in the bit memory area.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1442 System Manual, 01/2013,
Parameter
The following table shows the parameters of the "Scan RLO for negative signal edge"
instruction:
Parameter Declaration Data type Memory area Description
CLK Input BOOL I, Q, M, D, L Current RLO
<Operand> InOut BOOL M, D Edge memory bit
in which the RLO
of the previous
query is saved.
Q Output BOOL I, Q, M, D, L Result of edge
evaluation
Example
The following example shows how the instruction works:
JMP
N_TRlG
CLK Q
CAS1
"Tagln_1" "Tagln_2"
"Tagln_3"
"Tag_M"
The RLO of the previous query is saved in the edge memory bit "Tag_M". If a "1" to "0" change
is detected in the signal state of the RLO, the program jumps to jump label CAS1.
See also
Overview of the valid data types (Page 899)
R_TRIG: Set tag on positive signal edge
Description
You can use the "Set tag on positive signal edge" instruction to set a specified tag in the
instance DB when there is a "0" to "1" change in the result of logic operation (RLO). The
instruction compares the current RLO at the input CLK with the RLO from the previous query,
which is saved in the specified instance DB. If the instruction detects a change in the RLO
from "0" to "1", there is a positive signal edge.
If a positive edge is detected, the tag in the instance DB is set to signal state "1" and the output
Q returns the signal state "1" In all other cases, the signal state at the output of the instruction
is "0".
When you insert the instruction in the program, the "Call options" dialog opens automatically.
In this dialog you can specify whether the edge memory bit is stored in its own data block
(single instance) or as a local tag (multiple instance) in the block interface. If you create a
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1443
separate data block, you will find it in the project tree in the "Program resources" folder under
"Program blocks > System blocks". For additional information on this topic, refer to "See also".
Parameter
The following table shows the parameters of the instruction "Set tag on positive signal edge":
Parameter Declaration Data type Memory area Description
EN Input BOOL I, Q, M, D, L Enable input
ENO Output BOOL I, Q, M, D, L Enable output
CLK Input BOOL I, Q, M, D, L or
constant
Incoming signal
whose edge will
be queried.
Q Output BOOL I, Q, M, D, L Result of edge
evaluation
Example
The following example shows how the instruction works:
R_TRlG
CLK Q
"Tagln_1" "Tagln_2"
"Tagln_3"
"TagOut_Q"
EN ENO
%DB1
"R_TRlG_DB"
The RLO of the preceding query is saved in the instance DB "R_TRIG_DB". If a change is the
signal state of the RLO from "0" to "1" is detected in the operands "TagIn_1" and "TagIn_2" or
in the operand "TagIn_3", the output "TagOut_Q" has signal state "1".
See also
Overview of the valid data types (Page 899)
F_TRIG: Set tag on negative signal edge
Description
You can use the "Set tag on negative signal edge" instruction to set a specified tag in the
instance DB when there is a "1" to "0" change in the result of logic operation (RLO). The
instruction compares the current RLO at the input CLK with the RLO from the previous query,
which is saved in the specified instance DB. If the instruction detects a change in the RLO
from "1" to "0", there is a negative edge.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1444 System Manual, 01/2013,
If a negative edge is detected, the tag in the instance DB is set to signal state "1" and the output
Q returns the signal state "1" In all other cases, the signal state at the output of the instruction
is "0".
When you insert the instruction in the program, the "Call options" dialog opens automatically.
In this dialog you can specify whether the edge memory bit is stored in its own data block
(single instance) or as a local tag (multiple instance) in the block interface. If you create a
separate data block, you will find it in the project tree in the "Program resources" folder under
"Program blocks > System blocks". For additional information on this topic, refer to "See also".
Parameter
The following table shows the parameters of the instruction "Set tag on negative signal edge":
Parameter Declaration Data type Memory area Description
EN Input BOOL I, Q, M, D, L Enable input
ENO Output BOOL I, Q, M, D, L Enable output
CLK Input BOOL I, Q, M, D, L or
constant
Incoming signal
whose edge will
be queried.
Q Output BOOL I, Q, M, D, L Result of edge
evaluation
Example
The following example shows how the instruction works:
F_TRlG
CLK Q
"Tagln_1" "Tagln_2"
"Tagln_3"
"TagOut_Q"
EN ENO
%DB1
"F_TRlG_DB"
The RLO of the preceding query is saved in the instance DB "F_TRIG_DB". If a change is the
signal state of the RLO from "1" to "0" is detected in the operands "TagIn_1" and "TagIn_2" or
in the operand "TagIn_3", the output "TagOut_Q" has signal state "1".
See also
Overview of the valid data types (Page 899)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1445
Timer operations
IEC Timers
TP: Generate pulse
Description
You can use the "Generate pulse" instruction to set the output Q for a programmed duration.
The instruction is started when the result of logic operation (RLO) at input IN changes from "0"
to "1" (positive signal edge). The programmed time PT begins when the instruction starts.
Output Q is set for the duration PT, regardless of the subsequent course of the input signal.
Even if a new positive signal edge is detected, the signal state at the output Q is not affected
as long as the PT time duration is running.
You can scan the current timer value at the ET output. The timer value starts at T#0s and ends
when the value of duration PT is reached. When the duration PT is reached and the signal
state at input IN is "0", the ET output is reset.
Each call of the "Generate pulse" instruction must be assigned to an IEC timer in which the
instruction data is stored.
Note
If the timer is not called in the program because it is skipped, for example, the ET output
returns a constant value as soon as the timer has expired.
For S7-1200 CPU
An IEC timer is a structure of the data type IEC_TIMER or TP_TIME that you can declare as
follows:
Declaration of a data block of system data type IEC_TIMER (for example, "MyIEC_TIMER")
Declaration as a local tag of the type TP_TIME, TP_LTIME or IEC_TIMER in the "Static"
section of a block (for example, #MyIEC_TIMER)
For S7-1500 CPU
An IEC timer is a structure of the data type IEC_TIMER, IEC_LTIMER, TP_TIME or TP_LTIME
that you can declare as follows:
Declaration of a data block of system data type IEC_TIMER or IEC_LTIMER (for example,
"MyIEC_TIMER")
Declaration as a local tag of the type TP_TIME, TP_LTIME, IEC_TIMER or IEC_LTIMER
in the "Static" section of a block (for example, #MyIEC_TIMER)
When you insert the instruction in the program, the "Call options" dialog opens in which you
can specify whether the IEC timer is stored in its own data block (single instance) or as a local
tag (multiple instance) in the block interface. If you create a separate data block, you will find
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1446 System Manual, 01/2013,
it in the project tree in the "Program resources" folder under "Program blocks > System blocks".
For additional information on this topic, refer to "See also".
The instruction data is updated both when the instruction is called and also each time the
outputs Q or ET are accessed.
The execution of the "Generate pulse" instruction requires a preceding logic operation. It can
be placed within or at the end of the network.
Parameter
The following table shows the parameters of the "Generate pulse" instruction:
Parameter Declaration Data type Memory area Description
S7-1200 S7-1500
IN Input BOOL BOOL I, Q, M, D, L Start input
PT Input TIME TIME, LTIME I, Q, M, D, L or
constant
Duration of the
pulse.
The value of
the PT
parameter
must be
positive.
Q Output BOOL BOOL I, Q, M, D, L Pulse output
ET Output TIME TIME, LTIME I, Q, M, D, L Current timer
value
For additional information on valid data types, refer to "See also".
Timing diagram
The following figure shows the timing diagram of the "Generate pulse" instruction:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1447
See also
Overview of the valid data types (Page 899)
TON: Generate on-delay
Description
You can use the "Generate on-delay" instruction to delay setting of the Q output by the
programmed duration PT. The instruction is started when the result of logic operation (RLO)
at input IN changes from "0" to "1" (positive signal edge). The programmed time PT begins
when the instruction starts. When the duration PT expires, the output Q has the signal state
"1". Output Q remains set as long as the start input is still "1". When the signal state at the
start input changes from "1" to "0", the Q output is reset. The timer function is started again
when a new positive signal edge is detected at the start input.
The current timer value can be queried at the ET output. The timer value starts at T#0s and
ends when the value of duration PT is reached. The ET output is reset as soon as the signal
state at the IN input changes to "0".
Each call of the "Generate on-delay" instruction must be assigned to an IEC timer in which the
instruction data is stored.
Note
If the timer is not called in the program because it is skipped, for example, the ET output
returns a constant value as soon as the timer has expired.
For S7-1200 CPU
An IEC timer is a structure of the data type IEC_TIMER or TON_TIME that you can declare as
follows:
Declaration of a data block of system data type IEC_TIMER (for example, "MyIEC_TIMER")
Declaration as a local tag of the type TON_TIME or IEC_TIMER in the "Static" section of a
block (for example, #MyIEC_TIMER)
For S7-1500 CPU
An IEC timer is a structure of the data type IEC_TIMER, IEC_LTIMER, TON_TIME or
TON_LTIME that you can declare as follows:
Declaration of a data block of system data type IEC_TIMER or IEC_LTIMER (for example,
"MyIEC_TIMER")
Declaration as a local tag of the type TON_TIME, TON_LTIME, IEC_TIMER or IEC_LTIMER
in the "Static" section of a block (for example, #MyIEC_TIMER)
When you insert the instruction in the program, the "Call options" dialog opens in which you
can specify whether the IEC timer is stored in its own data block (single instance) or as a local
tag (multiple instance) in the block interface. If you create a separate data block, you will find
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1448 System Manual, 01/2013,
it in the project tree in the "Program resources" folder under "Program blocks > System blocks".
For additional information on this topic, refer to "See also".
The instruction data is updated both when the instruction is called and also each time the
outputs Q or ET are accessed.
The execution of the "Generate on-delay" instruction requires a preceding logic operation. It
can be placed within or at the end of the network.
Parameter
The following table shows the parameters of the "Generate on-delay" instruction:
Parameter Declaration Data type Memory area Description
S7-1200 S7-1500
IN Input BOOL BOOL I, Q, M, D, L Start input
PT Input TIME TIME, LTIME I, Q, M, D, L or
constant
Duration of the
on-delay
The value of
the PT
parameter
must be
positive.
Q Output BOOL BOOL I, Q, M, D, L Output that is
set when the
PT time
expires.
ET Output TIME TIME, LTIME I, Q, M, D, L Current timer
value
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1449
Timing diagram
The following figure shows the timing diagram of the "Generate on-delay" instruction:
See also
Overview of the valid data types (Page 899)
TOF: Generate off-delay
Description
You can use the "Generate off-delay" instruction to delay resetting of the Q output by the
programmed duration PT. The Q output is set when the result of logic operation (RLO) at input
IN changes from "0" to "1" (positive signal edge). When the signal state at input IN changes
back to "0", the programmed time PT starts. Output Q remains set as long as the duration PT
is running. When duration PT expires, the Q output is reset. If the signal state at input IN
changes to "1" before the PT time duration expires, the timer is reset. The signal state at the
output Q continues to be "1".
The current timer value can be queried at the ET output. The timer value starts at T#0s and
ends when the value of duration PT is reached. When the time duration PT expires, the ET
output remains set to the current value until the IN input changes back to "1". If input IN switches
to "1" before the duration PT has expired, the ET output is reset to the value T#0s.
Each call of the "Generate off-delay" instruction must be assigned to an IEC timer in which the
instruction data is stored.
Note
If the timer is not called in the program because it is skipped, for example, the ET output
returns a constant value as soon as the timer has expired.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1450 System Manual, 01/2013,
For S7-1200 CPU
An IEC timer is a structure of the data type IEC_TIMER or TOF_TIME that you can declare as
follows:
Declaration of a data block of system data type IEC_TIMER (for example, "MyIEC_TIMER")
Declaration as a local tag of the type TOF_TIME or IEC_TIMER in the "Static" section of a
block (for example, #MyIEC_TIMER)
For S7-1500 CPU
An IEC timer is a structure of the data type IEC_TIMER, IEC_LTIMER, TOF_TIME or
TOF_LTIME that you can declare as follows:
Declaration of a data block of system data type IEC_TIMER or IEC_LTIMER (for example,
"MyIEC_TIMER")
Declaration as a local tag of the type TOF_TIME, TOF_LTIME, IEC_TIMER or IEC_LTIMER
in the "Static" section of a block (for example, #MyIEC_TIMER)
When you insert the instruction in the program, the "Call options" dialog opens in which you
can specify whether the IEC timer is stored in its own data block (single instance) or as a local
tag (multiple instance) in the block interface. If you create a separate data block, you will find
it in the project tree in the "Program resources" folder under "Program blocks > System blocks".
For additional information on this topic, refer to "See also".
The instruction data is updated both when the instruction is called and also each time the
outputs Q or ET are accessed.
The execution of the "Generate off-delay" instruction requires a preceding logic operation. It
can be placed within or at the end of the network.
Parameter
The following table shows the parameters of the "Generate off-delay" instruction:
Parameter Declaration Data type Memory area Description
S7-1200 S7-1500
IN Input BOOL BOOL I, Q, M, D, L Start input
PT Input TIME TIME, LTIME I, Q, M, D, L or
constant
Duration of the
off delay
The value of
the PT
parameter
must be
positive.
Q Output BOOL BOOL I, Q, M, D, L Output that is
reset when the
timer PT
expires.
ET Output TIME TIME, LTIME I, Q, M, D, L Current timer
value
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1451
Timing diagram
The following figure shows the timing diagram of the "Generate off-delay" instruction:
See also
Overview of the valid data types (Page 899)
TONR: Time accumulator
Description
The "Time accumulator" instruction is used to accumulate time values within a period set by
the PT parameter. When the signal state at input IN changes from "0" to "1" (positive signal
edge), the instruction executes and the duration PT starts. While the duration PT is running,
the timer values are accumulated that are recorded when the IN input has signal state "1". The
accumulated time is written to output ET and can be queried there. When the duration PT
expires, the output Q has the signal state "1". The Q parameter remains set to "1", even when
the signal state at the IN parameter changes from "1" to "0" (negative signal edge).
The R input resets the outputs ET and Q regardless of the signal state at the start input.
Each call of the "Time accumulator" instruction must be assigned to an IEC timer in which the
instruction data is stored.
For S7-1200 CPU
An IEC timer is a structure of the data type IEC_TIMER or TONR_TIME that you can declare
as follows:
Declaration of a data block of system data type IEC_TIMER (for example, "MyIEC_TIMER")
Declaration as a local tag of the type TONR_TIME or IEC_TIMER in the "Static" section of
a block (for example, #MyIEC_TIMER)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1452 System Manual, 01/2013,
For S7-1500 CPU
An IEC timer is a structure of the data type IEC_TIMER, IEC_LTIMER, TONR_TIME or
TONR_LTIME that you can declare as follows:
Declaration of a data block of system data type IEC_TIMER or IEC_LTIMER (for example,
"MyIEC_TIMER")
Declaration as a local tag of the type TONR_TIME, TONR_LTIME, IEC_TIMER or
IEC_LTIMER in the "Static" section of a block (for example, #MyIEC_TIMER)
When you insert the instruction in the program, the "Call options" dialog opens in which you
can specify whether the IEC timer is stored in its own data block (single instance) or as a local
tag (multiple instance) in the block interface. If you create a separate data block, you will find
it in the project tree in the "Program resources" folder under "Program blocks > System blocks".
For additional information on this topic, refer to "See also".
The instruction data is updated both when the instruction is called and also each time the
outputs Q or ET are accessed.
The execution of the Time accumulator" instruction requires a preceding logic operation. It can
be placed within or at the end of the network.
Parameter
The following table shows the parameters of the "Time accumulator" instruction:
Parameter Declaration Data type Memory area Description
S7-1200 S7-1500
IN Input BOOL BOOL I, Q, M, D, L Start input
R Input BOOL BOOL I, Q, M, D, L or
constant
Reset input
PT Input TIME TIME, LTIME I, Q, M, D, L or
constant
Maximum
duration of
time recording
The value of
the PT
parameter
must be
positive.
Q Output BOOL BOOL I, Q, M, D, L Output that is
set when the
PT time
expires.
ET Output TIME TIME, LTIME I, Q, M, D, L Accumulated
time
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1453
Timing diagram
The following figure shows the timing diagram of the "Time accumulator" instruction:
See also
Overview of the valid data types (Page 899)
---( TP )---: Start pulse timer
Description
Use the "Start pulse timer" instruction to start an IEC timer with a specified duration as pulse.
The IEC timer is started when the result of logic operation (RLO) changes from "0" to "1"
(positive signal edge). The IEC timer runs for the specified duration regardless of any
subsequent changes in the RLO. The run of the IEC timer is also not affected by the detection
of a new positive signal edge. As long as the IEC timer is running, the querying of the timer
status for "1" returns the signal state "1". When the IEC timer has expired, the timer status
returns the signal state "0".
Note
You can start and query the IEC timer at various execution levels, as each querying of the
outputs Q or ET updates the IEC_TIMER structure.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1454 System Manual, 01/2013,
For S7-1200 CPU
The instruction "Start pulse timer" stores its data in a structure of the data type IEC_TIMER or
TP_TIME. You can declare the structure as follows:
Declaration of a data block of system data type IEC_TIMER (for example, "MyIEC_TIMER")
Declaration as a local tag of the type TP_LTIME or IEC_TIMER in the "Static" section of a
block (for example, #MyIEC_TIMER)
For S7-1500 CPU
The instruction "Start pulse timer" stores its data in a structure of the data type IEC_TIMER,
IEC_LTIMER, TP_TIME or TP_LTIME. You can declare the structure as follows:
Declaration of a data block of system data type IEC_TIMER or IEC_LTIMER (for example,
"MyIEC_TIMER")
Declaration as a local tag of the type TP_TIME, TP_LTIME, IEC_TIMER or IEC_LTIMER
in the "Static" section of a block (for example, #MyIEC_TIMER)
The instruction data is updated both when the instruction is called and also each time the
assigned timer is accessed.
The current timer status is stored in the Q structure component of the IEC timer. You can use
a normally open contact to query timer status for "1" or a normally closed contact for "0". The
query on Q or ET (for example, "MyTimer".Q or "MyTimer".ET) updates the IEC_TIMER
structure.
The execution of the "Start pulse timer" instruction assumes a preceding logic operation. It can
be placed only at the end of the network.
Parameter
The following table shows the parameters of the "Start pulse timer" instruction:
Parameter Declaration Data type Memory area Description
S7-1200 S7-1500
<Time
duration>
Input TIME TIME, LTIME I, Q, M, D, L or
constant
Duration with
which the IEC
timer runs.
<IEC timer> InOut IEC_TIMER,
TP_TIME
IEC_TIMER,
IEC_LTIMER,
TP_TIME,
TP_LTIME
D, L IEC timer that
is started.
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1455
Example
The following example shows how the instruction works:
TP
"Tag_lnput"
"TagTime"
"DB1".
MylEC_TlMER
The "Start pulse timer" instruction is executed when the signal state of the operand "Tag_Input"
changes from "0" to "1". The timer "DB1".MyIEC_TIMER is started for the time stored in the
operand "TagTime".
"Tag_Output"
"DB1".
MylEC_TlMER.Q
As long as the timer "DB1". MyIEC_TIMER is running, the timer status
("DB1".MyIEC_TIMER.Q) has signal state "1" and the operand "Tag_Output" is set. When the
IEC timer has expired, the signal state of the time status changes back to "0" and the
"Tag_Output" operand is reset.
See also
Overview of the valid data types (Page 899)
---( TON )---: Start on-delay timer
Description
Use the "Start on-delay timer" instruction to start an IEC timer with a specified duration as on-
delay. The IEC timer is started when the result of logic operation (RLO) changes from "0" to
"1" (positive signal edge). The IEC timer runs for the specified time. The output returns the
signal state "1" if the RLO at the input of the instruction has the signal state "1". If the RLO
changes to "0" before the time expires, the IEC timer is reset. In this case, querying the timer
status for "1" returns signal state "0". The IEC timer restarts when the next positive signal edge
is detected at the input of the instruction.
Note
You can start and query the IEC timer at various execution levels, as each querying of the
outputs Q or ET updates the IEC_TIMER structure.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1456 System Manual, 01/2013,
For S7-1200 CPU
The instruction "Start on-delay timer" stores its data in a structure of the data type IEC_TIMER
or TON_TIME. You can declare the structure as follows:
Declaration of a data block of system data type IEC_TIMER (for example, "MyIEC_TIMER")
Declaration as a local tag of the type TON_TIME or IEC_TIMER in the "Static" section of a
block (for example, #MyIEC_TIMER)
For S7-1500 CPU
The "Start on-delay timer" instruction stores its data in a structure of the data type IEC_TIMER,
IEC_LTIMER, TON_TIME or TON_LTIME. You can declare the structure as follows:
Declaration of a data block of system data type IEC_TIMER or IEC_LTIMER (for example,
"MyIEC_TIMER")
Declaration as a local tag of the type TON_TIME, TON_LTIME, IEC_TIMER or IEC_LTIMER
in the "Static" section of a block (for example, #MyIEC_TIMER)
The instruction data is updated both when the instruction is called and also each time the
assigned timer is accessed.
The current timer status is stored in the ET structure component of the IEC timer. You can use
a normally open contact to query timer status for "1" or a normally closed contact for "0". The
query on Q or ET (for example, "MyTimer".Q or "MyTimer".ET) updates the IEC_TIMER
structure.
The execution of the "Start on-delay timer" instruction assumes a preceding logic operation.
It can be placed only at the end of the network.
Parameter
The following table shows the parameters of the "Start on-delay timer" instruction:
Parameter Declaration Data type Memory area Description
S7-1200 S7-1500
<Time
duration>
Input TIME TIME, LTIME I, Q, M, D, L or
constant
Duration with
which the IEC
timer runs.
<IEC timer> InOut IEC_TIMER,
TON_TIME
IEC_TIMER,
IEC_LTIMER,
TON_TIME,
TON_LTIME
D, L IEC timer that
is started.
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1457
Example
The following example shows how the instruction works:
TON
"Tag_lnput"
"TagTime"
"MylEC_TlMER"
The "Start on-delay timer" instruction is executed when the signal state of the operand
"Tag_Input" changes from "0" to "1". The "MyIEC_TIMER timer is started for the time stored
in the "TagTime" operand.
"Tag_Output" "MylEC_TlMER".Q
If the timer "MyIEC_TIMER" has expired and the operand "Tag_Input" has the signal state "1",
querying the timer status ("MyIEC_TIMER).Q) returns signal state "1" and the "Tag_Output"
operand is set. When the signal state of the operand "Tag_Input" changes to "0", the querying
of the timer status returns the signal state "0" and the operand "Tag_Output" is reset.
See also
Overview of the valid data types (Page 899)
---( TOF )---: Start off-delay timer
Description
Use the "Start off-delay timer" instruction to start an IEC timer with a specified duration as on-
delay. The query of the timer status for "1" returns the signal state "0" if the result of logic
operation (RLO) at the input of the instruction has the signal state "1". When the RLO changes
from "1" to "0" (negative signal edge), the IEC timer starts with the specified time. The timer
status remains at signal state "1" as long as the IEC timer is running. When the timer has run
out and the RLO at the input of the instruction has the signal state "0", the timer status is set
to the signal state "0". If the RLO changes to "1" before the time expires, the IEC timer is reset
and the timer status remains at signal state "1".
Note
You can start and query the IEC timer at various execution levels, as each querying of the
outputs Q or ET updates the IEC_TIMER structure.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1458 System Manual, 01/2013,
For S7-1200 CPU
The instruction "Start off-delay timer" stores its data in a structure of the data type IEC_TIMER
or TOF_TIME. You can declare the structure as follows:
Declaration of a data block of system data type IEC_TIMER (for example, "MyIEC_TIMER")
Declaration as a local tag of the type TOF_TIME or IEC_TIMER in the "Static" section of a
block (for example, #MyIEC_TIMER)
For S7-1500 CPU
The "Start off-delay timer" instruction stores its data in a structure of the data type IEC_TIMER,
IEC_LTIMER, TOF_TIME or TOF_LTIME. You can declare the structure as follows:
Declaration of a data block of system data type IEC_TIMER or IEC_LTIMER (for example,
"MyIEC_TIMER")
Declaration as a local tag of the type TOF_TIME, TOF_LTIME, IEC_TIMER or IEC_LTIMER
in the "Static" section of a block (for example, #MyIEC_TIMER)
The instruction data is updated both when the instruction is called and also each time the
assigned timer is accessed.
The current timer status is stored in the ET structure component of the IEC timer. You can use
a normally open contact to query timer status for "1" or a normally closed contact for "0". The
query on Q or ET (for example, "MyTimer".Q or "MyTimer".ET) updates the IEC_TIMER
structure.
The execution of the "Start off-delay timer" instruction assumes a preceding logic operation.
It can be placed only at the end of the network.
Parameters
The following table shows the parameters of the "Start off-delay timer" instruction:
Parameter Declaration Data type Memory area Description
S7-1200 S7-1500
<Time
duration>
Input TIME TIME, LTIME I, Q, M, D, L or
constant
Duration with
which the IEC
timer runs.
<IEC timer> InOut IEC_TIMER,
TOF_TIME
IEC_TIMER,
IEC_LTIMER,
TOF_TIME,
TOF_LTIME
D, L IEC timer that
is started.
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1459
Example
The following example shows how the instruction works:
TOF
"Tag_lnput"
"TagTime"
#MylEC_TlMER
The "Start off-delay timer" instruction is executed when the signal state of the operand
"Tag_Input" changes from "1" to "0". The timer #MyIEC_TIMER is started for the time stored
in the operand "TagTime".
"Tag_Output" #MylEC_TlMER.Q
As long as timer #MyIEC_TIMER is running, the query of the time status (#MyIEC_TIMER.Q)
returns the signal state "1" and operand "Tag_Output" is set. If the timer has expired and the
operand "Tag_Input" has the signal state "0", the query of the timer status returns the signal
state "0". If the signal state of the operand "Tag_Input" changes to "1" before timer
#MyIEC_TIMER expires, the timer is reset. When the signal state of the operand "Tag_Input"
is "1", the query of the timer status returns the signal state "1".
See also
Overview of the valid data types (Page 899)
---( TONR )---: Time accumulator
Description
You can use the "Time accumulator" instruction to record how long the signal is at the input
of instruction "1". The instruction is started when the result of logic operation (RLO) changes
from "0" to "1" (positive signal edge). The time is recorded as long at the RLO is "1". If the RLO
changes to "0", the instruction is halted. If the RLO changes back to "1", the time recording is
continued. The query of the timer status for "1" returns the signal state "1" if the recorded time
exceeds the value of the specified duration and the RLO at the input of coil is "1".
The timer status and the currently expired timer can be reset to "0" using the "Reset timer"
instruction.
Note
You can start and query the IEC timer at various execution levels, as each querying of the
outputs Q or ET updates the IEC_TIMER structure.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1460 System Manual, 01/2013,
For S7-1200 CPU
The "Time accumulator" instruction stores its data in a structure of the data type IEC_TIMER
or TONR_TIME. You can declare the structure as follows:
Declaration of a data block of system data type IEC_TIMER (for example, "MyIEC_TIMER")
Declaration as a local tag of the type TONR_TIME or IEC_TIMER in the "Static" section of
a block (for example, #MyIEC_TIMER)
For S7-1500 CPU
The "Time accumulator" instruction stores its data in a structure of the data type IEC_TIMER,
IEC_LTIMER, TONR_TIME or TONR_LTIME. You can declare the structure as follows:
Declaration of a data block of system data type IEC_TIMER or IEC_LTIMER (for example,
"MyIEC_TIMER")
Declaration as a local tag of the type TONR_TIME, TONR_LTIME, IEC_TIMER or
IEC_LTIMER in the "Static" section of a block (for example, #MyIEC_TIMER)
The instruction data is updated both when the instruction is called and also each time the
assigned timer is accessed.
The current timer status is stored in the ET structure component of the IEC timer. You can use
a normally open contact to query timer status for "1" or a normally closed contact for "0". The
query on Q or ET (for example, "MyTimer".Q or "MyTimer".ET) updates the IEC_TIMER
structure.
The execution of the Time accumulator" instruction requires a preceding logic operation. It can
be placed only at the end of the network.
Parameter
The following table shows the parameters of the "Time accumulator" instruction:
Parameter Declaration Data type Memory area Description
S7-1200 S7-1500
<Time
duration>
Input TIME TIME, LTIME I, Q, M, D, L or
constant
Duration with
which the IEC
timer runs.
<IEC timer> InOut IEC_TIMER,
TONR_TIME
IEC_TIMER,
IEC_LTIMER,
TONR_TIME,
TONR_LTIME
D, L IEC timer that
is started.
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1461
Example
The following example shows how the instruction works:
TONR
"Tag_lnput"
"TagTime"
"MylEC_TlMER"
The "Time accumulator" instruction executes on a positive signal edge in the RLO. The time
is recorded as long as the operand "Tag_Input" has the signal state "1".
"Tag_Output" "MylEC_TlMER".Q
If the recorded time exceeds the value of the operand "TagTime", then the query of the timer
status ("MyIEC_TIMER".Q) will return the signal state "1" and the operand "Tag_Output" will
be set.
See also
Overview of the valid data types (Page 899)
---( RT )---: Reset timer
Description
You can use the "Reset timer" instruction to reset an IEC timer to "0". The instruction is only
executed if the result of logic operation (RLO) at the input of the coil is "1". If current is flowing
to the coil (RLO is "1"), the structure components of the timer in the specified data block are
reset to "0". If the RLO at the input of the instruction is "0", the timer remains unchanged.
The instruction does not influence the RLO. The RLO at the input of the coil is sent directly to
the output of the coil.
You assign the "Reset timer" instruction an IEC timer that has been declared in the program.
The instruction data is updated only when the instruction is called and not each time the
assigned IEC timer is accessed. Querying the data is only identical from the call of the
instruction to the next call of the instruction.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1462 System Manual, 01/2013,
Parameters
The following table shows the parameters of the "Reset timer" instruction":
Parameter Declaration Data type Memory area Description
S7-1200 S7-1500
<IEC timer> Output IEC_TIMER,
TP_TIME,
TON_TIME,
TOF_TIME,
TONR_TIME
IEC_TIMER,
IEC_LTIMER,
TP_TIME,
TP_LTIME,
TON_TIME,
TON_LTIME,
TOF_TIME,
TOF_LTIME,
TONR_TIME,
TONR_LTIME
D, L IEC timer that
is reset.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
"Tag_lnput_1"
"TON_DB"
TON
TlME
lN Q
PT ET
"Tag_Status"
"Tag_PT" "Tag_ET"
The "Generate on-delay" instruction executes when the signal state of the "Tag_Input_1"
operand changes from "0" to "1". The timer stored in the "TON_DB" instance data block starts
running for the time duration specified by operand "Tag_PT".
RT
"Tag_lnput_2"
"TON_DB"
"Tag_lnput_3"
If operands "Tag_Input_2" and "Tag_Input_3" have the signal state "1", the "Reset timer"
instruction is executed and the timer stored in the "TON_DB" data block.
See also
Overview of the valid data types (Page 899)
---( PT )---: Load time duration
Description
You can use the "Load time duration" instruction to set the time for an IEC timer. The instruction
is executed in every cycle when the result of logic operation (RLO) at the input of the instruction
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1463
has the signal state "1". The instruction writes the specified time to the structure of the specified
IEC timer.
Note
If the specified IEC timer is running while the instruction executes, the instruction overwrites
the current time of the specified IEC timer. This can change the timer status of the IEC timer.
You assign an IEC timer declared in the program to the "Load time duration" instruction.
The instruction data is updated only when the instruction is called and each time the assigned
IEC timer is accessed. The query on Q or ET (for example, "MyTimer".Q or "MyTimer".ET)
updates the IEC_TIMER structure.
Parameter
The following table shows the parameters of the "Load time duration" instruction:
Parameter Declaration Data type Memory area Description
S7-1200 S7-1500
<Time
duration>
Input TIME TIME, LTIME I, Q, M, D, L or
constant
Duration with
which the IEC
timer runs.
<IEC timer> Output IEC_TIMER,
TP_TIME,
TON_TIME,
TOF_TIME,
TONR_TIME
IEC_TIMER,
IEC_LTIMER,
TP_TIME,
TP_LTIME,
TON_TIME,
TON_LTIME,
TOF_TIME,
TOF_LTIME,
TONR_TIME,
TONR_LTIME
D, L IEC timer, the
duration of
which is set.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
"Tag_lnput_1"
"TON_DB"
TON
TlME
lN Q
PT ET
"Tag_Status"
"Tag_PT" "Tag_ET"
The "Generate on-delay" instruction executes when the signal state of the "Tag_Input_1"
operand changes from "0" to "1". The IEC timer stored in the instance data block "TON_DB"
is started with the time duration that is specified by the operand "Tag_PT".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1464 System Manual, 01/2013,
PT
"Tag_lnput_2"
"Tag_PT_2"
"TON_DB"
The "Load time duration" instruction is executed when the operand "Tag_Input_2" has the
signal state "1". The instruction writes the time duration "Tag_PT_2" in the instance data block
"TON_DB" and at the same time overwrites the value of the operand "Tag_PT" within the data
block. The signal state of the timer status may therefore change at the next query or when
"MyTimer".Q or "MyTimer".ET are accessed.
See also
Overview of the valid data types (Page 899)
SIMATIC Timers
S_PULSE: Assign pulse timer parameters and start
Description
The "Assign pulse timer parameters and start" instruction starts a programmed timer when a
change from "0" to "1" (positive signal edge) is detected in the result of logic operation (RLO)
at input S. The timer expires with the programmed duration (TV) as soon as the signal state
at input S is "1". If the signal state at input S changes to "0" before the programmed duration
expires, the timer is stopped. In this case, the signal state at output Q is "0".
The duration is made up internally of a timer value and a time base and is programmed at
parameter TV. When the instruction is started, the programmed timer value is counted down
towards zero. The time base indicates the time period with which the timer value is changed.
The current timer value is output BI-coded at output BI and BCD-coded at output BCD.
If the timer is running and the signal state at input R changes to "1" then the current timer value
and the time base are also set to zero. If the timer is not running, the signal state "1" at the R
input has no effect.
The "Assign pulse timer parameters and start" instruction requires a preceding logic operation
for edge evaluation and can be placed within or at the end of the network.
The instruction data is updated at every access. It can therefore happen that the query of the
data at the start of the cycle returns different values than at the end of the cycle.
Note
In each case, the instruction decrements a specific value by one unit in an interval that is
defined by its time basis until the time value is equal to "0". The decrementation takes place
asynchronous to the user program. The resulting timer is therefore always up to one time
interval shorter than the time base.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1465
Parameter
The following table shows the parameters of the instruction "Assign pulse timer parameters
and start":
Parameter Declaration Data type Memory area Description
<Timer> InOut/Input TIMER T Timer of the
instruction
The number of
timers depends on
the CPU.
S Input BOOL I, Q, M, D, L Start input
TV Input S5TIME, WORD I, Q, M, D, L or
constant
Preset timer value
R Input BOOL I, Q, M, T, C, D, L,
P or constant
Reset input
BI Output WORD I, Q, M, D, L, P Current timer
value (BI-coded)
BCD Output WORD I, Q, M, D, L, P Current timer
value (BCD
format)
Q Output BOOL I, Q, M, D, L Status of the timer
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1466 System Manual, 01/2013,
Timing diagram
The following figure shows the timing diagram of the instruction "Assign pulse timer parameters
and start":
RLO at input S
Time running
Query "1"
Query "0"
RLO at input R
t = programmed time
t t t
Example
The following example shows how the instruction works:
S
TV
R
S_PULSE
Q
Bl
BCD
"Tagln_1" "TagOut"
"Tagln_Number"
"TagValue_1"
"TagValue_2"
"Tagln_2"
"Timer_1"
The timer "Timer_1" is started when the signal state of the operand "TagIn_1" changes from
"0" to "1". The timer expires with the timer value of the operand "TagIn_Number" as long as
the operand "TagIn_1" has the signal state "1". If the signal state of the operand "TagIn_1"
changes from "1" to "0" before the timer expires, the timer "Timer_1" is stopped. The operand
"TagOut" is reset to "0" in this case.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1467
The operand "TagOut" has the signal state "1" as long as the timer is running and the operand
"TagIn_1" has the signal state "1". When the timer expires or is reset, the operand "TagOut"
is reset to "0".
See also
Overview of the valid data types (Page 899)
S_PEXT: Assign extended pulse timer parameters and start
Description
The "Assign extended pulse timer parameters and start" instruction starts a programmed timer
when a change from "0" to "1" (positive signal edge) is detected in the result of logic operation
(RLO) at input S. The timer expires with the programmed duration (TV), even if the signal state
at input S changes to "0". As long as the timer is running, the output Q has the signal state "1".
When the timer expires, the output Q is reset to "0". If the signal state at input S changes from
"0" to "1" while the timer is running, the timer is restarted with the duration programmed at
input TV.
The duration is made up internally of a timer value and a time base and is programmed at
parameter TV. When the instruction is started, the programmed timer value is counted down
towards zero. The time base indicates the time period with which the timer value is changed.
The current timer value is output BI-coded at output BI and BCD-coded at output BCD.
If the timer is running and the signal state at input R changes to "1" then the current timer value
and the time base are also set to zero. If the timer is not running, the signal state "1" at the R
input has no effect.
The "Assign extended pulse timer parameters and start" instruction requires a preceding logic
operation for edge evaluation and can be placed within or at the end of the network.
The instruction data is updated at every access. It can therefore happen that the query of the
data at the start of the cycle returns different values than at the end of the cycle.
Note
In each case, the instruction decrements a specific value by one unit in an interval that is
defined by its time basis until the time value is equal to "0". The decrementation takes place
asynchronous to the user program. The resulting timer is therefore always up to one time
interval shorter than the time base.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1468 System Manual, 01/2013,
Parameter
The following table shows the parameters of the instruction "Assign extended pulse timer
parameters and start":
Parameter Declaration Data type Memory area Description
<Timer> InOut/Input TIMER T Timer of the
instruction
The number of
timers depends on
the CPU.
S Input BOOL I, Q, M, D, L Start input
TV Input S5TIME, WORD I, Q, M, D, L or
constant
Preset timer value
R Input BOOL I, Q, M, T, C, D, L,
P or constant
Reset input
BI Output WORD I, Q, M, D, L, P Current timer
value (BI-coded)
BCD Output WORD I, Q, M, D, L, P Current timer
value (BCD
format)
Q Output BOOL I, Q, M, D, L Status of the timer
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1469
Timing diagram
The following figure shows the timing diagram of the "Assign extended pulse timer parameters
and start" instruction:
RLO at input S
Timer is running
Query "1"
Query "0"
RLO at input R
t = programmed timer
t t t
Example
The following example shows how the instruction works:
S
TV
R
S_PEXT
Q
Bl
BCD
"Tagln_1" "TagOut"
"Tagln_Number" "TagValue_1"
"TagValue_2"
"Tagln_2"
"Timer_1"
The timer "Timer_1" is started when the signal state of the operand "TagIn_1" changes from
"0" to "1". The timer expires with the timer value of the operand "TagIn_Number" without being
affected by a negative edge at input S. If the signal state of the operand "TagIn_1" changes
from "0" to "1" before the timer expires, the timer is restarted.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1470 System Manual, 01/2013,
The operand "TagOut" has the signal state "1" as long as the timer is running. When the timer
expires or is reset, the operand "TagOut" is reset to "0".
See also
Overview of the valid data types (Page 899)
S_ODT: Assign on-delay timer parameters and start
Description
The "Assign on-delay timer parameters and start" instruction starts a programmed timer when
a change from "0" to "1" (positive signal edge) is detected in the result of logic operation (RLO)
at input S. The timer expires with the programmed duration (TV) as soon as the signal state
at input S is "1". If the timer has expired correctly and input S still has signal state "1" then
output Q returns signal state "1". If the signal state at input S changes from "1" to "0" while the
timer is running, the timer is stopped. In this case, output Q is reset to signal state "0".
The duration is made up internally of a timer value and a time base and is programmed at
parameter TV. When the instruction is started, the programmed timer value is counted down
towards zero. The time base indicates the time period with which the timer value is changed.
The current timer value is output BI-coded at output BI and BCD-coded at output BCD.
If the time is running and the signal state at input R changes from "0" to "1" then the current
timer value and the time base are also set to zero. In this case, the signal state at output Q is
"0". The timer is reset if the signal state is "1" at the R input even if the timer is not running and
the RLO at input S is "1".
Specify the timer of the instruction in the placeholder above the box. The timer must be declared
with the data type TIMER.
The "Assign on-delay timer parameters and start" instruction requires a preceding logic
operation for edge evaluation and can be placed within or at the end of the network.
The instruction data is updated at every access. It can therefore happen that the query of the
data at the start of the cycle returns different values than at the end of the cycle.
Note
In each case, the instruction decrements a specific value by one unit in an interval that is
defined by its time basis until the time value is equal to "0". The decrementation takes place
asynchronous to the user program. The resulting timer is therefore always up to one time
interval shorter than the time base.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1471
Parameter
The following table shows the parameters of the "Assign on-delay timer parameters and start"
instruction:
Parameter Declaration Data type Memory area Description
<Timer> InOut/Input TIMER T Timer of the
instruction
The number of
timers depends on
the CPU.
S Input BOOL I, Q, M, D, L Start input
TV Input S5TIME, WORD I, Q, M, D, L or
constant
Preset timer value
R Input BOOL I, Q, M, T, C, D, L,
P or constant
Reset input
BI Output WORD I, Q, M, D, L, P Current timer
value (BI-coded)
BCD Output WORD I, Q, M, D, L, P Current timer
value (BCD
format)
Q Output BOOL I, Q, M, D, L Status of the timer
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1472 System Manual, 01/2013,
Timing diagram
The following figure shows the timing diagram of the "Assign on-delay timer parameters and
start" instruction:
RLO at input S
Timer is running
Query "1"
Query "0"
RLO at input R
t = programmed timer
t t t
Example
The following example shows how the instruction works:
"Tagln_1" "TagOut"
"Tagln_Number"
"TagValue_1"
"TagValue_2"
"Tagln_2"
"Timer_1"
S
TV
R
S_ODT
Q
Bl
BCD
The timer "Timer_1" is started when the signal state of the operand "TagIn_1" changes from
"0" to "1". The timer expires with the timer value of the operand "TagIn_Number". If the timer
expires and the operand has the signal state "1", the operand "TagOut" is set to "1". If the
signal state of the operand "TagIn_1" changes from "1" to "0" before the timer expires, the
timer is stopped. The operand "TagOut" has the signal state "0" in this case.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1473
See also
Overview of the valid data types (Page 899)
S_ODTS: Assign retentive on-delay timer parameters and start
Description
The "Assign retentive on-delay timer parameters and start" instruction starts a programmed
timer when a change from "0" to "1" (positive signal edge) is detected in the result of logic
operation (RLO) at input S. The timer expires with the programmed duration (TV), even if the
signal state at input S changes to "0". If the timer has expired, the "Q" output returns signal
state "1" regardless of the signal state at input "S". If the signal state at input S changes from
"0" to "1" while the timer is running, the timer is restarted with the duration programmed at
input (TV).
The duration is made up internally of a timer value and a time base and is programmed at
parameter TV. When the instruction is started, the programmed timer value is counted down
towards zero. The time base indicates the time period with which the timer value is changed.
The current timer value is output BI-coded at output BI and BCD-coded at output BCD.
Signal state "1" at input R resets the current timer value and time base to "0" regardless of the
signal state at start input S. In this case, the signal state at output Q is "0".
The "Assign retentive on-delay timer parameters and start" instruction requires a preceding
logic operation for edge evaluation and can be placed within or at the end of the network.
The instruction data is updated at every access. It can therefore happen that the query of the
data at the start of the cycle returns different values than at the end of the cycle.
Note
In each case, the instruction decrements a specific value by one unit in an interval that is
defined by its time basis until the time value is equal to "0". The decrementation takes place
asynchronous to the user program. The resulting timer is therefore always up to one time
interval shorter than the time base.
Parameter
The following table shows the parameters of the "Assign retentive on-delay timer parameters
and start" instruction:
Parameter Declaration Data type Memory area Description
<Timer> InOut/Input TIMER T Timer of the
instruction
The number of
timers depends on
the CPU.
S Input BOOL I, Q, M, D, L Start input
TV Input S5TIME, WORD I, Q, M, D, L or
constant
Preset timer value
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1474 System Manual, 01/2013,
Parameter Declaration Data type Memory area Description
R Input BOOL I, Q, M, T, C, D, L,
P or constant
Reset input
BI Output WORD I, Q, M, D, L, P Current timer
value (BI-coded)
BCD Output WORD I, Q, M, D, L, P Current timer
value (BCD
format)
Q Output BOOL I, Q, M, D, L Status of the timer
For additional information on valid data types, refer to "See also".
Timing diagram
The following figure shows the timing diagram of the "Assign retentive on-delay timer
parameters and start" instruction:
RLO at input S
Timer is running
Query "1"
Query "0"
RLO at input R
t = programmed timer
t t t
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1475
Example
The following example shows how the instruction works:
"Tagln_1" "TagOut"
"Tagln_Number"
"TagValue_1"
"TagValue_2"
"Tagln_2"
"Timer_1"
S
TV
R
S_ODTS
Q
Bl
BCD
The timer "Timer_1" is started when the signal state of the operand "TagIn_1" changes from
"0" to "1". The timer expires with the timer value of the operand "TagIn_Number", even if the
signal state of the operand "TagIn_1" changes to "0". When the timer expires, the operand
"TagOut" is set to "1". If the signal state of the operand "TagIn_1" changes from "0" to "1" while
the timer is running, the timer is restarted.
See also
Overview of the valid data types (Page 899)
S_OFFDT: Assign off-delay timer parameters and start
Description
The "Assign off-delay timer parameters and start" instruction starts a programmed timer when
a change from "1" to "0" (negative signal edge) is detected in the result of logic operation (RLO)
at input S. The timer expires with the programmed duration (TV). As long as the timer is running
or input S returns signal state "1", then output Q has signal state "1". When the timer expires
and the signal state at input S is "0", output Q is reset to the signal state "0". If the signal state
at input S changes from "0" to "1" while the timer is running, the timer is stopped. The timer is
only restarted after a falling signal edge is detected at input S.
The duration is made up internally of a timer value and a time base and is programmed at
parameter TV. When the instruction is started, the programmed timer value is counted down
towards zero. The time base indicates the time period with which the timer value is changed.
The current timer value is output BI-coded at output BI and BCD-coded at output BCD.
Signal state "1" at input R resets the current timer value and time base to "0". In this case, the
signal state at output Q is "0".
The "Assign off-delay timer parameters and start" instruction requires a preceding logic
operation for edge evaluation and can be placed within or at the end of the network.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1476 System Manual, 01/2013,
The instruction data is updated at every access. It can therefore happen that the query of the
data at the start of the cycle returns different values than at the end of the cycle.
Note
In each case, the instruction decrements a specific value by one unit in an interval that is
defined by its time basis until the time value is equal to "0". The decrementation takes place
asynchronous to the user program. The resulting timer is therefore always up to one time
interval shorter than the time base.
Parameter
The following table shows the parameters of the "Assign off-delay timer parameters and start"
instruction:
Parameter Declaration Data type Memory area Description
<Timer> InOut/Input TIMER T Timer of the
instruction
The number of
timers depends on
the CPU.
S Input BOOL I, Q, M, D, L Start input
TV Input S5TIME, WORD I, Q, M, D, L or
constant
Preset timer value
R Input BOOL I, Q, M, T, C, D, L,
P or constant
Reset input
BI Output WORD I, Q, M, D, L, P Current timer
value (BI-coded)
BCD Output WORD I, Q, M, D, L, P Current timer
value (BCD
format)
Q Output BOOL I, Q, M, D, L Status of the timer
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1477
Timing diagram
The following figure shows the timing diagram of the "Assign off-delay timer parameters and
start" instruction:
RLO at input S
Timer is running
Query "1"
Query "0"
RLO at input R
t = programmed timer
t t t t
Example
The following example shows how the instruction works:
S
TV
R
S_OFFDT
Q
Bl
BCD
"Tagln_1" "TagOut"
"Tagln_Number"
"TagValue_1"
"TagValue_2"
"Tagln_2"
"Timer_1"
The timer "Timer_1" is started when the signal state of the operand "TagIn_1" changes from
"1" to "0". The timer expires with the timer value of the operand "TagIn_Number". The operand
"TagOut" is set to "1" when the timer is running and when the operand "TagIn_1" has the signal
state "0". If the signal state of the operand "TagIn_1" changes from "0" to "1" while the timer
is running, the timer is reset.
See also
Overview of the valid data types (Page 899)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1478 System Manual, 01/2013,
---( SP ): Start pulse timer
Description
The "Start pulse timer" instruction starts a programmed timer when a change from "0" to "1"
(positive signal edge) is detected in the result of logic operation (RLO). The time runs with the
specified duration as long as the RLO has the signal state "1". As long as the timer is running,
the querying of the timer status for "1" returns the signal state "1". If there is a change from "1"
to "0" in the RLO before the timer value has elapsed, the timer stops. In this case, the querying
of the timer status for "1" returns the signal state "0".
The duration is made up internally of a timer value and a time base. When the instruction is
started, the programmed timer value is counted down towards zero. The time base indicates
the time period with which the timer value is changed.
The "Start pulse timer" instruction requires a preceding logic operation for edge evaluation and
can only be placed at the right side of the network.
Note
In each case, the instruction decrements a specific value by one unit in an interval that is
defined by its time basis until the time value is equal to "0". The decrementation takes place
asynchronous to the user program. The resulting timer is therefore always up to one time
interval shorter than the time base.
Parameter
The following table shows the parameters of the "Start pulse timer" instruction:
Parameter Declaration Data type Memory area Description
<Time duration> Input S5TIME, WORD I, Q, M, D, L or
constant
Duration with
which the timer
expires.
<Timer> InOut/Input TIMER T Timer which is
started.
The number of
timers depends on
the CPU.
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1479
Example
The following example shows how the instruction works:
SP
Network 1
Network 2
Network 3
R
"Tagln_1" "Timer_1"
"Timer_1"
"Timer_1"
"TagOut"
"Tagln_Number"
"Tagln_2"
The timer "Timer_1" is started when the signal state of the operand "TagIn_1" changes from
"0" to "1". The timer expires with the timer value of the operand "TagIn_Number" as long as
the signal state of the operand "TagIn_1" is "1". If the signal state of the operand "TagIn_1"
changes from "1" to "0" before the timer expires, the timer is stopped. As long as the timer is
running, the operand "TagOut" has the signal state "1". A signal state change of the operand
"TagIn_1" from "0" to "1" resets the timer, which stops the timer and sets the current timer
value to "0".
See also
Overview of the valid data types (Page 899)
---( SE ): Start extended pulse timer
Description
The "Start extended pulse timer" instruction starts a programmed timer when a change from
"0" to "1" (positive signal edge) is detected in the result of logic operation (RLO). The timer
expires with the specified duration, even if the RLO changes to the signal state "0". As long
as the timer is running, the querying of the timer status for "1" returns the signal state "1". If
the RLO changes from "0" to "1" while the timer is running, the timer is restarted with the
programmed duration. The querying of the timer status for "1" returns the signal state "0" when
the timer expires.
The duration is made up internally of a timer value and a time base. When the instruction is
started, the programmed timer value is counted down towards zero. The time base indicates
the time period with which the timer value is changed.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1480 System Manual, 01/2013,
The "Start extended pulse timer" instruction requires a preceding logic operation for edge
evaluation and can only be placed at the right side of the network.
Note
In each case, the instruction decrements a specific value by one unit in an interval that is
defined by its time basis until the time value is equal to "0". The decrementation takes place
asynchronous to the user program. The resulting timer is therefore always up to one time
interval shorter than the time base.
Parameter
The following table shows the parameters of the "Start extended pulse timer" instruction:
Parameter Declaration Data type Memory area Description
<Time duration> Input S5TIME, WORD I, Q, M, D, L or
constant
Duration with
which the timer
expires.
<Timer> InOut/Input TIMER T Timer which is
started.
The number of
timers depends on
the CPU.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
SE
Network 1
Network 2
Network 3
R
"Tagln_1" "Timer_1"
"Timer_1"
"Timer_1"
"TagOut"
"Tagln_Number"
"Tagln_2"
The timer "Timer_1" is started when the signal state of the operand "TagIn_1" changes from
"0" to "1". The timer expires with the timer value of the operand "TagIn_Number" without being
affected by a negative edge in the RLO. As long as the timer is running, the operand "TagOut"
has the signal state "1". If the signal state of the operand "TagIn_1" changes from "0" to "1"
before the timer expires, the timer is restarted.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1481
See also
Overview of the valid data types (Page 899)
---( SD ): Start on-delay timer
Description
The "Start on-delay timer" instruction starts a programmed timer when a change from "0" to
"1" (positive signal edge) is detected in the result of logic operation (RLO). The timer runs for
the specified duration as long as the RLO is "1". If the timer has expired and the RLO still has
the signal state "1", the query of the timer status for "1" returns the signal state "1". If the RLO
changes from "1" to "0" while the timer is running, the timer is stopped. In this case, the querying
of the timer status for "1" returns the signal state "0".
The duration is made up internally of a timer value and a time base. When the instruction is
started, the programmed timer value is counted down towards zero. The time base indicates
the time period with which the timer value is changed.
The "Start on-delay timer" instruction requires a preceding logic operation for edge evaluation
and can only be placed at the right side of the network.
Note
In each case, the instruction decrements a specific value by one unit in an interval that is
defined by its time basis until the time value is equal to "0". The decrementation takes place
asynchronous to the user program. The resulting timer is therefore always up to one time
interval shorter than the time base.
Parameter
The following table shows the parameters of the "Start on-delay timer" instruction:
Parameter Declaration Data type Memory area Description
<Time duration> Input S5TIME, WORD I, Q, M, D, L or
constant
Duration with
which the timer
expires.
<Timer> InOut/Input TIMER T Timer which is
started.
The number of
timers depends on
the CPU.
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1482 System Manual, 01/2013,
Example
The following example shows how the instruction works:
SD
Network 1
Network 2
Network 3
R
"Tagln_1" "Timer_1"
"Timer_1"
"Timer_1"
"TagOut"
"Tagln_Number"
"Tagln_2"
The timer "Timer_1" is started when the signal state of the operand "TagIn_1" changes from
"0" to "1". The timer expires with the timer value of the operand "TagIn_Number". If the timer
expires and the RLO has the signal state "1", the operand "TagOut" is set to "1". If the signal
state of the operand "TagIn_1" changes from "1" to "0" before the timer expires, the timer is
stopped. If the signal state of the operand "TagIn_2" is "1", the timer "Timer_1" is reset, which
stops the timer and sets the current timer value to "0".
See also
Overview of the valid data types (Page 899)
---( SS ): Start retentive on-delay timer
Description
The "Start retentive on-delay timer" instruction starts a programmed timer when a change from
"0" to "1" (positive signal edge) is detected in the result of logic operation (RLO). The timer
expires with the specified duration, even if the RLO changes to the signal state "0". When the
timer expires, the querying of the timer status for "1" returns the signal state "1". After expiry
of the timer, the timer can only be restarted if it is explicitly reset.
The duration is made up internally of a timer value and a time base. When the instruction is
started, the programmed timer value is counted down towards zero. The time base indicates
the time period with which the timer value is changed.
The "Start retentive on-delay timer" instruction requires a preceding logic operation for edge
evaluation and can only be placed at the right side of the network.
Note
In each case, the instruction decrements a specific value by one unit in an interval that is
defined by its time basis until the time value is equal to "0". The decrementation takes place
asynchronous to the user program. The resulting timer is therefore always up to one time
interval shorter than the time base.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1483
Parameter
The following table shows the parameters of the "Start retentive on-delay timer" instruction:
Parameter Declaration Data type Memory area Description
<Time duration> Input S5TIME, WORD I, Q, M, D, L or
constant
Duration with
which the timer
expires.
<Timer> InOut/Input TIMER T Timer which is
started.
The number of
timers depends on
the CPU.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
SS
Network 1
Network 2
Network 3
R
"Tagln_1" "Timer_1"
"Timer_1"
"Timer_1"
"TagOut"
"Tagln_Number"
"Tagln_2"
The timer "Timer_1" is started when the signal state of the operand "TagIn_1" changes from
"0" to "1". The timer expires with the timer value of the operand "TagIn_Number". When the
timer expires, the operand "TagOut" is set to "1". If the signal state of the operand "TagIn_1"
changes from "0" to "1" while the timer is running, the timer is restarted. If the signal state of
the operand "TagIn_2" is "1", the timer "Timer_1" is reset, which stops the timer and sets the
current timer value to "0".
See also
Overview of the valid data types (Page 899)
---( SF ): Start off-delay timer
Description
The "Start off-delay timer" instruction starts a programmed timer when a change from "1" to
"0" (negative signal edge) is detected in the result of logic operation (RLO). The timer expires
with the specified duration. As long as the timer is running, the querying of the timer status for
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1484 System Manual, 01/2013,
"1" returns the signal state "1". If the RLO changes from "0" to "1" while the timer is running,
the timer is reset. The timer is always restarted when the RLO changes from "1" to "0".
The duration is made up internally of a timer value and a time base. When the instruction is
started, the programmed timer value is counted down towards zero. The time base indicates
the time period with which the timer value is changed.
The "Start off-delay timer" instruction requires a preceding logic operation for edge evaluation
and can only be placed at the right side of the network.
Note
In each case, the instruction decrements a specific value by one unit in an interval that is
defined by its time basis until the time value is equal to "0". The decrementation takes place
asynchronous to the user program. The resulting timer is therefore always up to one time
interval shorter than the time base.
Parameter
The following table shows the parameters of the "Start off-delay timer" instruction:
Parameter Declaration Data type Memory area Description
<Time duration> Input S5TIME, WORD I, Q, M, D, L or
constant
Duration with
which the timer
expires.
<Timer> InOut/Input TIMER T Timer which is
started.
The number of
timers depends on
the CPU.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
SF
Network 1
Network 2
Network 3
R
"Tagln_1" "Timer_1"
"Timer_1"
"Timer_1"
"TagOut"
"Tagln_Number"
"Tagln_2"
The timer "Timer_1" is started when the signal state of the operand "TagIn_1" changes from
"1" to "0". The timer expires with the timer value of the operand "TagIn_Number". As long as
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1485
the timer is running, the operand "TagOut" is set to "1". If the signal state of the operand
"TagIn_1" changes from "1" to "0" while the timer is running, the timer is restarted. If the signal
state of the operand "TagIn_2" is "1", the timer "Timer_1" is reset, which stops the timer and
sets the current timer value to "0".
See also
Overview of the valid data types (Page 899)
Counter operations
IEC Counters
CTU: Count up
Description
You can use the "Count up" instruction to increment the value at output CV. When the signal
state at the CU input changes from "0" to "1" (positive signal edge), the instruction executes
and the current counter value at the CV output is incremented by one. When the instruction
executes for the first time, the current counter value at the CV output is set to zero. The counter
value is incremented each time a positive signal edge is detected, until it reaches the high limit
for the data type specified at the CV output. When the high limit is reached, the signal state at
the CU input no longer has an effect on the instruction.
You can scan the counter status at the Q output. The signal state at the Q output is determined
by the parameter PV. If the current counter value is greater than or equal to the value of the
PV parameter, the Q output is set to signal state "1". In all other cases, the Q output has signal
state "0". You can also specify a constant for the PV parameter.
The value at the CV output is reset to zero when the signal state at input R changes to "1". As
long as the R input has signal state "1", the signal state at the CU input has no effect on the
instruction.
Note
Only use a counter at a single location in the program to avoid risk of counting errors.
Each call of the "Count up" instruction must be assigned an IEC counter in which the instruction
data is stored. An IEC counter is a structure with one of the following data types:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1486 System Manual, 01/2013,
For S7-1200 CPU
Data block of system data type IEC_counter
(global DB)
Local tag
IEC_SCOUNTER / IEC_USCOUNTER
IEC_COUNTER / IEC_UCOUNTER
IEC_DCOUNTER / IEC_UDCOUNTER
CTU_SINT / CTU_USINT
CTU_INT / CTU_UINT
CTU_DINT / CTU_UDINT
IEC_SCOUNTER / IEC_USCOUNTER
IEC_COUNTER / IEC_UCOUNTER
IEC_DCOUNTER / IEC_UDCOUNTER
For S7-1500 CPU
Data block of system data type IEC_counter
(global DB)
Local tag
IEC_SCOUNTER / IEC_USCOUNTER
IEC_COUNTER / IEC_UCOUNTER
IEC_DCOUNTER / IEC_UDCOUNTER
IEC_LCOUNTER / IEC_ULCOUNTER
CTU_SINT / CTU_USINT
CTU_INT / CTU_UINT
CTU_DINT / CTU_UDINT
CTU_LINT / CTU_ULINT
IEC_SCOUNTER / IEC_USCOUNTER
IEC_COUNTER / IEC_UCOUNTER
IEC_DCOUNTER / IEC_UDCOUNTER
IEC_LCOUNTER / IEC_ULCOUNTER
You can declare an IEC counter as follows:
Declaration of a data block of system data type IEC_COUNTER (for example,
"MyIEC_COUNTER")
Declaration as a local tag of the type CTU or IEC_COUNTER in the "Static" section of a
block (for example, #MyIEC_COUNTER)
When you insert the instruction in the program, the "Call options" dialog opens in which you
can specify whether the IEC counter is stored in its own data block (single instance) or as a
local tag (multiple instance) in the block interface. If you create a separate data block, you will
find it in the project tree in the "Program resources" folder under "Program blocks > System
blocks". For additional information on this topic, refer to "See also".
The execution of the "Count up" instruction requires a preceding logic operation. It can be
placed within or at the end of the network.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1487
Parameters
The following table shows the parameters of the "Count up" instruction:
Parameter Declaration Data type Memory area Description
CU Input BOOL I, Q, M, D, L or
constant
Count input
R Input BOOL I, Q, M, T, C, D, L,
P or constant
Reset input
PV Input Integers I, Q, M, D, L, P or
constant
Value at which the
output Q is set.
Q Output BOOL I, Q, M, D, L Counter status
CV Output Integers, CHAR,
DATE
I, Q, M, D, L, P Current counter
value
You can select the data type for the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
CU
R
PV
Q
CV
"Tagln_1"
"Tagln_2"
"Tag_PV"
"Tag_CV"
"TagOut"
"CTU_DB"
CTU
lNT
When the signal state of the "TagIn_1" operand changes from "0" to "1", the "Count up"
instruction executes and the current counter value of the operand "Tag_CV" is incremented
by one. With each additional positive signal edge, the counter value is incremented until the
high limit value of the data type (INT = 32767) is reached.
The value of the PV parameter is adopted as the limit for determining the "TagOut" output.
The "TagOut" output has signal state "1" as long as the current counter value is greater than
or equal to the value of the "Tag_PV" operand. In all other cases, the "TagOut" output has
signal state "0".
See also
Overview of the valid data types (Page 899)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1488 System Manual, 01/2013,
CTD: Count down
Description
You can use the "Count down" instruction to decrement the value at output CV. When the
signal state at the CD input changes from "0" to "1" (positive signal edge), the instruction
executes and the current counter value at the CV output is decremented by one. When the
instruction executes the first time, the counter value of the CV parameter is set to the value of
the PV parameter. Each time a positive signal edge is detected, the counter value is
decremented until it reaches the low limit value of the specified data type. When the low limit
is reached, the signal state at the CD input no longer has an effect on the instruction.
You can scan the counter status at the Q output. If the current counter value is less than or
equal to zero, the Q output is set to signal state "1". In all other cases, the Q output has signal
state "0". You can also specify a constant for the PV parameter.
The value at the CV output is set to the value of the PV parameter when the signal state at the
LD input changes to "1". As long as the LD input has signal state "1", the signal state at the
CD input has no effect on the instruction.
Note
Only use a counter at a single location in the program to avoid risk of counting errors.
Each call of the "Count down" instruction must be assigned an IEC counter in which the
instruction data is stored. An IEC counter is a structure with one of the following data types:
For S7-1200 CPU
Data block of system data type IEC_counter
(global DB)
Local tag
IEC_SCOUNTER / IEC_USCOUNTER
IEC_COUNTER / IEC_UCOUNTER
IEC_DCOUNTER / IEC_UDCOUNTER
CTD_SINT / CTD_USINT
CTD_INT / CTD_UINT
CTD_DINT / CTD_UDINT
IEC_SCOUNTER / IEC_USCOUNTER
IEC_COUNTER / IEC_UCOUNTER
IEC_DCOUNTER / IEC_UDCOUNTER
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1489
For S7-1500 CPU
Data block of system data type IEC_counter
(global DB)
Local tag
IEC_SCOUNTER / IEC_USCOUNTER
IEC_COUNTER / IEC_UCOUNTER
IEC_DCOUNTER / IEC_UDCOUNTER
IEC_LCOUNTER / IEC_ULCOUNTER
CTD_SINT / CTD_USINT
CTD_INT / CTD_UINT
CTD_DINT / CTD_UDINT
CTD_LINT / CTD_ULINT
IEC_SCOUNTER / IEC_USCOUNTER
IEC_COUNTER / IEC_UCOUNTER
IEC_DCOUNTER / IEC_UDCOUNTER
IEC_LCOUNTER / IEC_ULCOUNTER
You can declare an IEC counter as follows:
Declaration of a data block of system data type IEC_COUNTER (for example,
"MyIEC_COUNTER")
Declaration as a local tag of the type CTD or IEC_COUNTER in the "Static" section of a
block (for example, #MyIEC_COUNTER)
When you insert the instruction in the program, the "Call options" dialog opens in which you
can specify whether the IEC counter is stored in its own data block (single instance) or as a
local tag (multiple instance) in the block interface. If you create a separate data block, you will
find it in the project tree in the "Program resources" folder under "Program blocks > System
blocks". For additional information on this topic, refer to "See also".
The execution of the "Count down" instruction requires a preceding logic operation. It can be
placed within or at the end of the network.
Parameter
The following table shows the parameters of the "Count down" instruction:
Parameter Declaration Data type Memory area Description
CD Input BOOL I, Q, M, D, L or
constant
Count input
LD Input BOOL I, Q, M, T, C, D, L,
P or constant
Load input
PV Input Integers I, Q, M, D, L, P or
constant
Value at which the
output Q is set.
Q Output BOOL I, Q, M, D, L Counter status
CV Output Integers, CHAR,
DATE
I, Q, M, D, L, P Current counter
value
You can select the data type for the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1490 System Manual, 01/2013,
Example
The following example shows how the instruction works:
CD
LD
PV
Q
CV
"Tagln_1"
"Tagln_2"
"Tag_PV"
"Tag_CV"
"TagOut"
"CTD_DB"
CTD
lNT
When the signal state of the "TagIn_1" operand changes from "0" to "1", the "Count down"
instruction is executed and the value at the "Tag_CV" output is decremented by one. With each
additional positive signal edge, the counter value is decremented until the low limit of the
specified data type (INT = -32768) is reached.
The "TagOut" output has signal state "1" as long as the current counter value is less than or
equal to zero. In all other cases, the "TagOut" output has signal state "0".
See also
Overview of the valid data types (Page 899)
CTUD: Count up and down
Description
You can use the "Count up and down" instruction to increment and decrement the counter
value at the CV output. If the signal state at the CU input changes from "0" to "1" (positive
signal edge), the current counter value is incremented by one and stored at the CV output. If
the signal state at the CD input changes from "0" to "1" (positive signal edge), the counter
value at the CV output is decremented by one. If there is a positive signal edge at the CU and
CD inputs in one program cycle, the current counter value at the CV output remains unchanged.
The counter value can be incremented until it reaches the high limit of the data type specified
at the CV output. When the high limit value is reached, the counter value is no longer
incremented on a positive signal edge. When the low limit of the specified data type is reached,
the counter value is not decremented any further.
When the signal state at the LD input changes to "1", the counter value at the CV output is set
to the value of the PV parameter. As long as the LD input has the signal state "1", the signal
state at the CU and CD inputs has no effect on the instruction.
The counter value is set to zero when the signal state at the R input changes to "1". As long
as the R input has signal state "1", a change in the the signal state of the CU, CD and LD inputs
has no effect on the "Count up and down" instruction.
You can scan the current status of the up counter at the QU output. If the current counter value
is greater than or equal to the value of the PV parameter, the QU output is set to signal state
"1". In all other cases, the QU output has signal state "0". You can also specify a constant for
the PV parameter.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1491
You can scan the current status of the down counter at the QD output. If the current counter
value is less than or equal to zero, the QD output is set to signal state "1". In all other cases,
the QD output has signal state "0".
Note
Only use a counter at a single location in the program to avoid risk of counting errors.
Each call of the "Count up and down" instruction must be assigned an IEC counter in which
the instruction data is stored. An IEC counter is a structure with one of the following data types:
For S7-1200 CPU
Data block of system data type IEC_counter
(global DB)
Local tag
IEC_SCOUNTER / IEC_USCOUNTER
IEC_COUNTER / IEC_UCOUNTER
IEC_DCOUNTER / IEC_UDCOUNTER
CTUD_SINT / CTUD_USINT
CTUD_INT / CTUD_UINT
CTUD_DINT / CTUD_UDINT
IEC_SCOUNTER / IEC_USCOUNTER
IEC_COUNTER / IEC_UCOUNTER
IEC_DCOUNTER / IEC_UDCOUNTER
For S7-1500 CPU
Data block of system data type IEC_counter
(global DB)
Local tag
IEC_SCOUNTER / IEC_USCOUNTER
IEC_COUNTER / IEC_UCOUNTER
IEC_DCOUNTER / IEC_UDCOUNTER
IEC_LCOUNTER / IEC_ULCOUNTER
CTUD_SINT / CTUD_USINT
CTUD_INT / CTUD_UINT
CTUD_DINT / CTUD_UDINT
CTUD_LINT / CTUD_ULINT
IEC_SCOUNTER / IEC_USCOUNTER
IEC_COUNTER / IEC_UCOUNTER
IEC_DCOUNTER / IEC_UDCOUNTER
IEC_LCOUNTER / IEC_ULCOUNTER
You can declare an IEC counter as follows:
Declaration of a data block of system data type IEC_COUNTER (for example,
"MyIEC_COUNTER")
Declaration as a local tag of the type CTUD or IEC_COUNTER in the "Static" section of a
block (for example, #MyIEC_COUNTER)
When you insert the instruction in the program, the "Call options" dialog opens in which you
can specify whether the IEC counter is stored in its own data block (single instance) or as a
local tag (multiple instance) in the block interface. If you create a separate data block, you will
find it in the project tree in the "Program resources" folder under "Program blocks > System
blocks". For additional information on this topic, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1492 System Manual, 01/2013,
The execution of the "Count up and down" instruction requires a preceding logic operation. It
can be placed within or at the end of the network.
Parameters
The following table shows the parameters of the "Count up and down" instruction:
Parameter Declaration Data type Memory area Description
CU Input BOOL I, Q, M, D, L or
constant
Count up input
CD Input BOOL I, Q, M, D, L or
constant
Count down input
R Input BOOL I, Q, M, T, C, D, L,
P or constant
Reset input
LD Input BOOL I, Q, M, T, C, D, L,
P or constant
Load input
PV Input Integers I, Q, M, D, L, P or
constant
Value at which the
output QU is set.
QU Output BOOL I, Q, M, D, L Status of the
counter up
QD Output BOOL I, Q, M, D, L Status of the
down-counter
CV Output Integers, CHAR,
DATE
I, Q, M, D, L, P Current counter
value
You can select the data type for the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
CU
LD
PV
QU
CV
CD
R
QD
"Tagln_1"
"Tagln_2"
"Tagln_3"
"Tagln_4"
"Tag_PV"
"Tag_CV"
"TagOut"
"TagOut_QD"
CTUD
lNT
"CTUD_DB"
If the signal state at the "TagIn_1" or "TagIn_2" input changes from "0" to "1" (positive signal
edge), the "Count up and down" instruction is executed. When there is a positive signal edge
at the "TagIn_1" input, the current counter value is incremented by one and stored at the
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1493
"Tag_CV" output. When there is a positive signal edge at the "TagIn_2" input, the counter value
is decremented by one and stored at the "Tag_CV" output. When there is a positive signal
edge at the CU input, the counter value is incremented until it reaches the high limit of 32767.
If input CD has a positive signal edge, the counter value is decremented until it reaches the
low limit value of INT = -32768.
The "TagOut" output has signal state "1" as long as the current counter value is greater than
or equal to the value at the "Tag_PV" input. In all other cases, the "TagOut" output has signal
state "0".
The "TagOut_QD" output has signal state "1" as long as the current counter value is less than
or equal to zero. In all other cases, the "TagOut_QD" output has signal state "0".
See also
Overview of the valid data types (Page 899)
SIMATIC Counters
S_CUD: Assign parameters and count up / down
Description
You can use the "Assign parameters and count up / down" instruction to increment or
decrement the value of a counter. If the signal state at the CU input changes from "0" to "1"
(positive signal edge), the current counter value is incremented by one. If the signal state at
the CD input changes from "0" to "1" (positive signal edge), the counter value is decremented
by one. The current counter value is output as a hexadecimal value at output CV and BCD-
coded at output CV_BCD. If there is a positive signal edge at the CU and CD inputs in one
program cycle, the counter value remains unchanged.
The counter value can be incremented until the high limit of "999" is reached. When the high
limit value is reached, the counter value is no longer incremented on a positive signal edge.
When the low limit "0" is reached, the counter value is not decremented any further.
When the signal state at input S changes from "0" to "1", the counter value is set to the value
of the PV parameter. If the counter is set and if RLO is "1" at the inputs CU and CD, the counter
counts accordingly in the next scan cycle, even if no change in the signal edge was detected.
The counter value is set to zero when the signal state at the R input changes to "1". As long
as the R input has the signal state "1", processing of the signal state of the CU, CD and S
inputs has no effect on the counter value.
The signal state at output Q is "1" if the counter value is greater than zero. If the counter value
is equal to zero, output Q has the signal state "0".
Note
Only use a counter at a single location in the program to avoid risk of counting errors.
The "Assign parameters and count up / down" instruction requires a preceding logic operation
for edge evaluation and can be placed within or at the end of the network.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1494 System Manual, 01/2013,
Parameters
The following table shows the parameters of the "Assign parameters and count up / down"
instruction:
Parameter Declaration Data type Memory area Description
<Counter> InOut/Input COUNTER C Counter of the
instruction
The number of
counters depends
on the CPU.
CU Input BOOL I, Q, M, D, L Count up input
CD Input BOOL I, Q, M, D, L, T, C
or constant
Count down input
S Input BOOL I, Q, M, D, L, T, C
or constant
Input for
presetting counter
PV Input WORD I, Q, M, D, L, C or
constant
Preset counter
value (C#0 to
C#999)
R Input BOOL I, Q, M, D, L, T, C
or constant
Reset input
BI Output WORD, S5TIME,
DATE
I, Q, M, D, L Current counter
value
(hexadecimal)
CV_BCD Output WORD, S5TIME,
DATE
I, Q, M, D, L Current counter
value (BCD
format)
Q Output BOOL I, Q, M, D, L Status of the
counter
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
S_CUD
CU Q
CV
CD
PV CV_BCD
R
S
"Tagln_2"
"Tagln_1"
"Tagln_3"
"Tagln_4"
"TagPresetValue"
"TagValue_1"
"TagOut"
"TagValue_2"
"Counter_1"
If the signal state at the "TagIn_1"" or "TagIn_2" input changes from "0" to "1" (positive signal
edge), the "Assign parameters and count up / down" instruction is executed. When there is a
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1495
positive signal edge at the "TagIn_1" input and the current counter value is less than "999",
the counter value is incremented by one. When there is a positive signal edge at the "TagIn_2"
input and the current counter value is greater than "0", the counter value is decremented by
one.
When the signal state at input "TagIn_3" changes from "0" to "1", the counter value is set to
the value of the operand "TagPresetValue". The counter value is reset to "0" when the
"TagIn_4" operand has signal state "1".
The current counter value is saved as a hexadecimal value in the operand "TagValue_1" and
BCD-coded in the operand "TagValue_2".
The "TagOut" output has the signal state "1" as long as the current counter value is not equal
to "0".
See also
Overview of the valid data types (Page 899)
S_CU: Assign parameters and count up
Description
You can use the "Assign parameters and count up" instruction to increment the value of a
counter. If the signal state at the CU input changes from "0" to "1" (positive signal edge), the
current counter value is incremented by one. The current counter value is output as a
hexadecimal value at output CV and BCD-coded at output CV_BCD. The counter value can
be incremented until the limit of "999" is reached. When the limit is reached, the counter value
is no longer incremented on a positive signal edge.
When the signal state at input S changes from "0" to "1", the counter value is set to the value
of the PV parameter. If the counter is set and if RLO at input CU is "1", the counter will count
accordingly in the next scan cycle, even when no change has been detected in the signal edge.
The counter value is set to zero when the signal state at the R input changes to "1". As long
as the R input has the signal state "1", processing of the signal state of the CU and S inputs
has no effect on the counter value.
The signal state at output Q is "1" if the counter value is greater than zero. If the counter value
is equal to zero, output Q has the signal state "0".
Note
Only use a counter at a single location in the program to avoid risk of counting errors.
The "Assign parameters and count up" instruction requires a preceding logic operation for edge
evaluation and can be placed within or at the end of the network.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1496 System Manual, 01/2013,
Parameter
The following table shows the parameters of the "Assign parameters and count up" instruction:
Parameter Declaration Data type Memory area Description
<Counter> InOut/Input COUNTER C Counter of the
instruction
The number of
counters depends
on the CPU.
CU Input BOOL I, Q, M, D, L Count up input
S Input BOOL I, Q, M, D, L, T, C
or constant
Input for
presetting counter
PV Input WORD I, Q, M, D, L, C or
constant
Preset counter
value (C#0 to
C#999)
R Input BOOL I, Q, M, D, L, T, C
or constant
Reset input
BI Output WORD, S5TIME,
DATE
I, Q, M, D, L Current counter
value
(hexadecimal)
BCD Output WORD, S5TIME,
DATE
I, Q, M, D, L Current counter
value (BCD
format)
Q Output BOOL I, Q, M, D, L Status of the
counter
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
"TagOut"
S_CU
CU
PV
R
S
Q
CV
CV_BCD
"Tagln_2"
"Tagln_1"
"Tagln_3"
"TagPresetValue" "TagValue_1"
"TagValue_2"
"Counter_1"
When the signal state at the "TagIn_1" input changes from "0" to "1" (positive signal edge) and
the current counter value is less than "999", the counter value is incremented by one. When
the signal state at input "TagIn_2" changes from "0" to "1", the counter value is set to the value
of the operand "TagPresetValue". The counter value is reset to "0" when the "TagIn_3" operand
has signal state "1".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1497
The current counter value is saved as a hexadecimal value in the operand "TagValue_1" and
BCD-coded in the operand "TagValue_2".
The "TagOut" output has the signal state "1" as long as the current counter value is not equal
to "0".
See also
Overview of the valid data types (Page 899)
S_CD: Assign parameters and count down
Description
You can use the "Assign parameters and count down" instruction to decrement the value of a
counter. If the signal state at the CD input changes from "0" to "1" (positive signal edge), the
counter value is decremented by one. The current counter value is output as a hexadecimal
value at output CV and BCD-coded at output CV_BCD. The counter value can be decremented
until the low limit of "0" is reached. When the low limit is reached, the counter value is no longer
decremented on a positive signal edge.
When the signal state at input S changes from "0" to "1", the counter value is set to the value
of the PV parameter. If the counter is set and if RLO at input CD is "1", the counter will count
accordingly in the next scan cycle, even when no change has been detected in the signal edge.
The counter value is set to zero when the signal state at the R input changes to "1". As long
as the R input has the signal state "1", processing of the signal state of the CD and S inputs
has no effect on the counter value.
The signal state at output Q is "1" if the counter value is greater than zero. If the counter value
is equal to zero, output Q has the signal state "0".
Note
Only use a counter at a single location in the program to avoid risk of counting errors.
The "Assign parameters and count down" instruction requires a preceding logic operation for
edge evaluation and can be placed within or at the end of the network.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1498 System Manual, 01/2013,
Parameter
The following table shows the parameters of the "Assign parameters and count down"
instruction:
Parameter Declaration Data type Memory area Description
<Counter> InOut/Input COUNTER C Counter of the
instruction
The number of
counters depends
on the CPU.
CD Input BOOL I, Q, M, D, L or
constant
Count down input
S Input BOOL I, Q, M, D, L, T, C
or constant
Input for
presetting counter
PV Input WORD I, Q, M, D, L, C or
constant
Preset counter
value (C#0 to
C#999)
R Input BOOL I, Q, M, D, L, T, C
or constant
Reset input
CV Output WORD, S5TIME,
DATE
I, Q, M, D, L Current counter
value
(hexadecimal)
BCD Output WORD, S5TIME,
DATE
I, Q, M, D, L Current counter
value (BCD
format)
Q Output BOOL I, Q, M, D, L Status of the
counter
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
"TagOut"
CD
PV
R
S
Q
CV
CV_BCD
S_CD
"Tagln_2"
"Tagln_1"
"Tagln_3"
"TagPresetValue" "TagValue_1"
"TagValue_2"
"Counter_1"
When the signal state at the "TagIn_1" input changes from "0" to "1" (positive signal edge) and
the current counter value is greater than "0", the counter value is decremented by one. When
the signal state at input "TagIn_2" changes from "0" to "1", the counter value is set to the value
of the operand "TagPresetValue". The counter value is reset to "0" when the "TagIn_3" operand
has signal state "1".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1499
The current counter value is saved as a hexadecimal value in the operand "TagValue_1" and
BCD-coded in the operand "TagValue_2".
The "TagOut" output has the signal state "1" as long as the current counter value is not equal
to "0".
See also
Overview of the valid data types (Page 899)
---( SC ): Set counter value
Description
You can use the "Set counter value" instruction to set the value of a counter. The instruction
is executed when the result of logic operation (RLO) at the input changes from "0" to "1". When
the instruction is executed, the counter is set to the specified counter value.
The "Set counter value" instruction requires a preceding logic operation for edge evaluation
and can only be placed at the right side of the network.
Parameter
The following table shows the parameters of the "Set counter value" instruction:
Parameter Declaration Data type Memory area Description
<Count value> Input WORD I, Q, M, D, L or
constant
Value with which
the counter is
preset in the BCD
format.
(C#0 to C#999)
<Counter> InOut/Input COUNTER C Counter that is
preset
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
SC
"Tagln" "Counter_1"
C#100
The counter "Counter_1" is preset with the value "100" when the signal state of the operand
"TagIn" changes from "0" to "1".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1500 System Manual, 01/2013,
See also
Overview of the valid data types (Page 899)
---( CU ): Count up
Description
With the "Count up" instruction you can increment the value of the specified counter by one if
there is a positive signal edge in the result of logic operation (RLO). The counter value can be
incremented until the limit of "999" is reached. When the limit is reached, the counter value is
no longer incremented on a positive signal edge.
The "Count up" instruction requires a preceding logic operation for edge evaluation and can
only be placed at the right side of the network.
Parameter
The following table shows the parameters of the "Count up" instruction:
Parameter Declaration Data type Memory area Description
<Counter> InOut/Input COUNTER C Counter whose
value is
incremented.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
CU
SC
R
Network 1
Network 2
Network 3
"Tagln_2"
"Tagln_1"
"Tagln_3"
C#100
"Counter_1"
"Counter_1"
"Counter_1"
When the signal state of the "TagIn_1" operand changes from "0" to "1" (positive signal edge),
the counter "Counter_1" is preset with the value "100".
The value of the counter "Counter_1" is incremented by one when the signal state of the
operand "TagIn_2" changes from "0" to "1".
When the operand "TagIn_3" has the signal state "1", the value of the counter "Counter_1" is
reset to "0".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1501
See also
Overview of the valid data types (Page 899)
---( CD ): Count down
Description
With the "Count down" instruction you can increment the value of the specified counter by one
if there is a positive signal edge in the result of logic operation (RLO). The counter value can
be decremented until the limit of "0" is reached. When the limit is reached, the counter value
is no longer changed on a positive signal edge.
The "Count down" instruction requires a preceding logic operation for edge evaluation and can
only be placed at the right side of the network.
Parameter
The following table shows the parameters of the "Count down" instruction:
Parameter Declaration Data type Memory area Description
<Counter> InOut/Input COUNTER C Counter whose
value is
decremented.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
CD
SC
R
Network 1
Network 2
Network 3
"Tagln_2"
"Tagln_1"
"Tagln_3"
C#100
"Counter_1"
"Counter_1"
"Counter_1"
When the signal state of the "TagIn_1" operand changes from "0" to "1" (positive signal edge),
the counter "Counter_1" is preset with the value "100".
The value of the counter "Counter_1" is decremented by one when the signal state of the
operand "TagIn_2" changes from "0" to "1".
When the operand "TagIn_3" has the signal state "1", the value of the counter "Counter_1" is
reset to "0".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1502 System Manual, 01/2013,
See also
Overview of the valid data types (Page 899)
Comparator operations
CMP ==: Equal
Description
You can use the "Equal" instruction to determine if a first comparison value (<Operand1>) is
equal to a second comparison value (<Operand2>).
If the condition of the comparison is fulfilled, the instruction returns the result of logic operation
(RLO) "1". If the comparison condition is not fulfilled, the instruction returns RLO "0". The RLO
of the instruction is logically combined with the RLO of the entire rung as follows:
By AND, when the comparison instruction is connected in series.
By OR, when the comparison instruction is connected in parallel.
Specify the first comparison value (<Operand1>) at the operand placeholder above the
instruction. Specify the second comparison value (<Operand2>) at the operand placeholder
below the instruction.
The individual characters are compared by means of their ASCII code (for example, 'a' is
greater than 'A') during the comparison of the strings. The comparison is performed from left
to right. The first character that is different decides the result of the comparison.
The following table shows examples of string comparisons:
<Operand1> <Operand2> RLO of instruction
'AA' 'AA' 1
'Hello World' 'HelloWorld' 0
'AA' 'aa' 0
You can also use the "Equal" instruction to compare individual characters of a string (STRING).
The number of the character to be compared is given in brackets next to the operand name.
"MyString[2]", for example, compares the second character of the "MyString" string.
When IEC Check is selected, the operands to be compared must have the same data type. If
IEC Check is not selected, the width (length) of the operands must be the same. When floating-
point numbers are compared, the operands to be compared must have the same data type
regardless of the setting for the IEC Check.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1503
Parameters
The following table shows the parameters of the "Equal" instruction:
Parameter Declaration Data type Memory area Description
S7-1200 S7-1500
<Operand1> Input Bit strings,
integers,
floating-point
numbers,
strings, TIME,
DATE, TOD,
DTL
Bit strings,
integers,
floating-point
numbers,
character
strings, TIME,
LTIME, DATE,
TOD, LTOD,
DTL, DT, LDT
I, Q, M, D, L, P
or constant
First
comparison
value
<Operand2> Input Bit strings,
integers,
floating-point
numbers,
strings, TIME,
DATE, TOD,
DTL
Bit strings,
integers,
floating-point
numbers,
character
strings, TIME,
LTIME, DATE,
TOD, LTOD,
DTL, DT, LDT
I, Q, M, D, L, P
or constant
Second value
to compare
You can select the data type for the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also":
Example
The following example shows how the instruction works:
==
S
lNT
"Tagln_1" "Tagln_2"
"Tag_Value1"
"Tag_Value2"
"TagOut"
The "TagOut" output is set when the following conditions are fulfilled:
The operands "TagIn_1" and "TagIn_2" have the signal state "1".
The condition of the comparison instruction is fulfilled if ("Tag_Value1" = "Tag_Value2").
See also
Overview of the valid data types (Page 899)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1504 System Manual, 01/2013,
CMP <>: Not equal
Description
You can use the "Not equal" instruction to determine if a first comparison value (<Operand1>)
is not equal to a second comparison value (<Operand2>).
If the condition of the comparison is fulfilled, the instruction returns the result of logic operation
(RLO) "1". If the comparison condition is not fulfilled, the instruction returns RLO "0". The RLO
of the instruction is logically combined with the RLO of the entire rung as follows:
By AND, when the comparison instruction is connected in series.
By OR, when the comparison instruction is connected in parallel.
Specify the first comparison value (<Operand1>) at the operand placeholder above the
instruction. Specify the second comparison value (<Operand2>) at the operand placeholder
below the instruction.
The individual characters are compared by means of their ASCII code (for example, 'a' is
greater than 'A') during the comparison of the strings. The comparison is performed from left
to right. The first character that is different decides the result of the comparison.
The following table shows examples of string comparisons:
<Operand1> <Operand2> RLO of instruction
'AA' 'aa' 1
'Hello World' 'HelloWorld' 1
'AA' 'AA' 0
You can also use the "Not equal" instruction to compare individual characters of a string
(STRING). The number of the character to be compared is given in brackets next to the operand
name. "MyString[2]", for example, compares the second character of the "MyString" string.
When IEC Check is selected, the operands to be compared must have the same data type. If
IEC Check is not selected, the width (length) of the operands must be the same. When floating-
point numbers are compared, the operands to be compared must have the same data type
regardless of the setting for the IEC Check.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1505
Parameters
The following table shows the parameters of the "Not equal" instruction:
Parameter Declaration Data type Memory area Description
S7-1200 S7-1500
<Operand1> Input Bit strings,
integers,
floating-point
numbers,
strings, TIME,
DATE, TOD,
DTL
Bit strings,
integers,
floating-point
numbers,
character
strings, TIME,
LTIME, DATE,
TOD, LTOD,
DTL, DT, LDT
I, Q, M, D, L, P
or constant
First
comparison
value
<Operand2> Input Bit strings,
integers,
floating-point
numbers,
strings, TIME,
DATE, TOD,
DTL
Bit strings,
integers,
floating-point
numbers,
character
strings, TIME,
LTIME, DATE,
TOD, LTOD,
DTL, DT, LDT
I, Q, M, D, L, P
or constant
Second value
to compare
You can select the data type for the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
<>
S
lNT
"Tagln_1" "Tagln_2"
"Tag_Value1"
"Tag_Value2"
"TagOut"
The "TagOut" output is set when the following conditions are fulfilled:
The operands "TagIn_1" and "TagIn_2" have signal state "1".
The condition of the comparison instruction is fulfilled if ("Tag_Value1" <> "Tag_Value2").
See also
Overview of the valid data types (Page 899)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1506 System Manual, 01/2013,
CMP >=: Greater or equal
Description
You can use the "Greater or equal" instruction to determine if a first comparison value
(<Operand1>) is greater than or equal to a second comparison value (<Operand2>). Both
values to be compared must be of the same data type.
If the condition of the comparison is fulfilled, the instruction returns the result of logic operation
(RLO) "1". If the comparison condition is not fulfilled, the instruction returns RLO "0". The RLO
of the instruction is logically combined with the RLO of the entire rung as follows:
By AND, when the comparison instruction is connected in series.
By OR, when the comparison instruction is connected in parallel.
Specify the first comparison value (<Operand1>) at the operand placeholder above the
instruction. Specify the second comparison value (<Operand2>) at the operand placeholder
below the instruction.
The individual characters are compared by means of their ASCII code (for example, 'a' is
greater than 'A') during the comparison of the strings. The comparison is performed from left
to right. The first character that is different decides the result of the comparison. If the left part
of the longer string is identical to the shorter string, the longer string is considered greater.
The following table shows examples of string comparisons:
<Operand1> <Operand2> RLO of instruction
'BB' 'AA' 1
'AAA' 'AA' 1
'Hello World' 'Hello World' 1
'Hello World' 'HelloWorld' 0
'AA' 'aa' 0
'AAA' 'a' 0
You can also use the "Greater or equal" instruction to compare individual characters of a string
(STRING). The number of the character to be compared is given in brackets next to the operand
name. "MyString[2]", for example, compares the second character of the "MyString" string.
When time values are compared, the RLO of the instruction is "1" if the point of time at
<Operand1> is greater (more recent) than or equal to the point of time at <Operand2>.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1507
Parameters
The following table shows the parameters of the "Greater or equal" instruction:
Parameter Declaration Data type Memory area Description
S7-1200 S7-1500
<Operand1> Input Integers,
floating-point
numbers,
strings, TIME,
DATE, TOD,
DTL
Integers,
floating-point
numbers,
character
strings, TIME,
LTIME, DATE,
TOD, LTOD,
DTL, DT, LDT
I, Q, M, D, L, P
or constant
First
comparison
value
<Operand2> Input Integers,
floating-point
numbers,
strings, TIME,
DATE, TOD,
DTL
Integers,
floating-point
numbers,
character
strings, TIME,
LTIME, DATE,
TOD, LTOD,
DTL, DT, LDT
I, Q, M, D, L, P
or constant
Second value
to compare
You can select the data type for the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
>=
S
lNT
"Tagln_1" "Tagln_2"
"Tag_Value1"
"Tag_Value2"
"TagOut"
The "TagOut" output is set when the following conditions are fulfilled:
The operands "TagIn_1" and "TagIn_2" have signal state "1".
The condition of the comparison instruction is fulfilled if ("Tag_Value1" >= "Tag_Value2").
See also
Overview of the valid data types (Page 899)
Example of detecting the fill level of a storage area (Page 1392)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1508 System Manual, 01/2013,
CMP <=: Less or equal
Description
You can use the "Less or equal" instruction to determine if a first comparison value
(<Operand1>) is less than or equal to a second comparison value (<Operand2>). Both values
to be compared must be of the same data type.
If the condition of the comparison is fulfilled, the instruction returns the result of logic operation
(RLO) "1". If the comparison condition is not fulfilled, the instruction returns RLO "0". The RLO
of the instruction is logically combined with the RLO of the entire rung as follows:
By AND, when the comparison instruction is connected in series.
By OR, when the comparison instruction is connected in parallel.
Specify the first comparison value (<Operand1>) at the operand placeholder above the
instruction. Specify the second comparison value (<Operand2>) at the operand placeholder
below the instruction.
The individual characters are compared by means of their ASCII code (for example, 'a' is
greater than 'A') during the comparison of the strings. The comparison is performed from left
to right. The first character that is different decides the result of the comparison. If the left part
of the longer string is identical to the shorter string, the shorter string is considered smaller.
The following table shows examples of string comparisons:
<Operand1> <Operand2> RLO of instruction
'AA' 'aa' 1
'AAA' 'a' 1
'Hello World' 'Hello World' 1
'HelloWorld' 'Hello World' 0
'BB' 'AA' 0
'AAA' 'AA' 0
You can also use the "Less or equal" instruction to compare individual characters of a string
(STRING). The number of the character to be compared is given in brackets next to the operand
name. "MyString[2]", for example, compares the second character of the "MyString" string.
When time values are compared, the RLO of the instruction is "1" if the point of time at
<Operand1> is less (less recent) than or equal to the point of time at <Operand2>.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1509
Parameters
The following table shows the parameters of the "Less or equal" instruction:
Parameter Declaration Data type Memory area Description
S7-1200 S7-1500
<Operand1> Input Integers,
floating-point
numbers,
strings, TIME,
DATE, TOD,
DTL
Integers,
floating-point
numbers,
character
strings, TIME,
LTIME, DATE,
TOD, LTOD,
DTL, DT, LDT
I, Q, M, D, L, P
or constant
First
comparison
value
<Operand2> Input Integers,
floating-point
numbers,
strings, TIME,
DATE, TOD,
DTL
Integers,
floating-point
numbers,
character
strings, TIME,
LTIME, DATE,
TOD, LTOD,
DTL, DT, LDT
I, Q, M, D, L, P
or constant
Second value
to compare
You can select the data type for the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
<=
S
lNT
"Tagln_1" "Tagln_2"
"Tag_Value1"
"Tag_Value2"
"TagOut"
The "TagOut" output is set when the following conditions are fulfilled:
The operands "TagIn_1" and "TagIn_2" have signal state "1".
The condition of the comparison instruction is fulfilled if ("Tag_Value1" <= "Tag_Value2").
See also
Overview of the valid data types (Page 899)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1510 System Manual, 01/2013,
CMP >: Greater than
Description
You can use the "Greater than" instruction to determine if a first comparison value
(<Operand1>) is greater than a second comparison value (<Operand2>). Both values to be
compared must be of the same data type.
If the condition of the comparison is fulfilled, the instruction returns the result of logic operation
(RLO) "1". If the comparison condition is not fulfilled, the instruction returns RLO "0". The RLO
of the instruction is logically combined with the RLO of the entire rung as follows:
By AND, when the comparison instruction is connected in series.
By OR, when the comparison instruction is connected in parallel.
Specify the first comparison value (<Operand1>) at the operand placeholder above the
instruction. Specify the second comparison value (<Operand2>) at the operand placeholder
below the instruction.
The individual characters are compared by means of their ASCII code (for example, 'a' is
greater than 'A') during the comparison of the strings. The comparison is performed from left
to right. The first character that is different decides the result of the comparison. If the left part
of the longer string is identical to the shorter string, the longer string is considered greater.
The following table shows examples of string comparisons:
<Operand1> <Operand2> RLO of instruction
'BB' 'AA' 1
'AAA' 'AA' 1
'AA' 'aa' 0
'AAA' 'a' 0
You can also use the "Greater than" instruction to compare individual characters of a string
(STRING). The number of the character to be compared is given in brackets next to the operand
name. "MyString[2]", for example, compares the second character of the "MyString" string.
When time values are compared, the RLO of the instruction is "1" if the point of time at
<Operand1> is greater (more recent) than the point of time at <Operand2>.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1511
Parameters
The following table shows the parameters of the "Greater than" instruction:
Parameter Declaration Data type Memory area Description
S7-1200 S7-1500
<Operand1> Input Integers,
floating-point
numbers,
strings, TIME,
DATE, TOD,
DTL
Integers,
floating-point
numbers,
character
strings, TIME,
LTIME, DATE,
TOD, LTOD,
DTL, DT, LDT
I, Q, M, D, L, P
or constant
First
comparison
value
<Operand2> Input Integers,
floating-point
numbers,
strings, TIME,
DATE, TOD,
DTL
Integers,
floating-point
numbers,
character
strings, TIME,
LTIME, DATE,
TOD, LTOD,
DTL, DT, LDT
I, Q, M, D, L, P
or constant
Second value
to compare
You can select the data type for the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
>
S
lNT
"Tagln_1" "Tagln_2"
"Tag_Value1"
"Tag_Value2"
"TagOut"
The "TagOut" output is set when the following conditions are fulfilled:
The operands "TagIn_1" and "TagIn_2" have signal state "1".
The condition of the comparison instruction is fulfilled if ("Tag_Value1" > "Tag_Value2").
See also
Overview of the valid data types (Page 899)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1512 System Manual, 01/2013,
CMP <: Less than
Description
You can use the "Less than" instruction to determine if a first comparison value (<Operand1>)
is less than a second comparison value (<Operand2>). Both values to be compared must be
of the same data type.
If the condition of the comparison is fulfilled, the instruction returns the result of logic operation
(RLO) "1". If the comparison condition is not fulfilled, the instruction returns RLO "0". The RLO
of the instruction is logically combined with the RLO of the entire rung as follows:
By AND, when the comparison instruction is connected in series.
By OR, when the comparison instruction is connected in parallel.
Specify the first comparison value (<Operand1>) at the operand placeholder above the
instruction. Specify the second comparison value (<Operand2>) at the operand placeholder
below the instruction.
The individual characters are compared by means of their ASCII code (for example, 'a' is
greater than 'A') during the comparison of the strings. The comparison is performed from left
to right. The first character that is different decides the result of the comparison. If the left part
of the longer string is identical to the shorter string, the shorter string is considered smaller.
The following table shows examples of string comparisons:
<Operand1> <Operand2> RLO of instruction
'AA' 'aa' 1
'AAA' 'a' 1
'BB' 'AA' 0
'AAA' 'AA' 0
You can also use the "Less than" instruction to compare individual characters of a string
(STRING). The number of the character to be compared is given in brackets next to the operand
name. "MyString[2]", for example, compares the second character of the "MyString" string.
When time values are compared, the RLO of the instruction is "1" if the point of time at
<Operand1> is less (less recent) than the point of time at <Operand2>.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1513
Parameters
The following table shows the parameters of the "Less than" instruction:
Parameter Declaration Data type Memory area Description
S7-1200 S7-1500
<Operand1> Input Integers,
floating-point
numbers,
strings, TIME,
DATE, TOD,
DTL
Integers,
floating-point
numbers,
character
strings, TIME,
LTIME, DATE,
TOD, LTOD,
DTL, DT, LDT
I, Q, M, D, L, P
or constant
First
comparison
value
<Operand2> Input Integers,
floating-point
numbers,
strings, TIME,
DATE, TOD,
DTL
Integers,
floating-point
numbers,
character
strings, TIME,
LTIME, DATE,
TOD, LTOD,
DTL, DT, LDT
I, Q, M, D, L, P
or constant
Second value
to compare
You can select the data type for the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
<
S
lNT
"Tagln_1" "Tagln_2"
"Tag_Value1"
"Tag_Value2"
"TagOut"
The "TagOut" output is set when the following conditions are fulfilled:
The operands "TagIn_1" and "TagIn_2" have signal state "1".
The condition of the comparison instruction is fulfilled if ("Tag_Value1" < "Tag_Value2").
See also
Overview of the valid data types (Page 899)
Example of detecting the fill level of a storage area (Page 1392)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1514 System Manual, 01/2013,
IN_RANGE: Value within range
Description
You can use the "Value within range" instruction to determine if the value at the VAL input is
within a specific value range.
You specify the limits of the value range with the MIN and MAX inputs. The "Value within range"
instruction compares the value at the VAL input with the values of the MIN and MAX inputs
and sends the result to the box output. If the value at the VAL input fulfills the comparison MIN
<= VAL or VAL <= MAX, the box output has the signal state "1". If the comparison is not fulfilled,
the box output has the signal state "0".
If the box input has the signal state "0", the "Value within range" instruction is not executed.
The comparison function can only execute if the values to be compared are of the same data
type and the box input is interconnected.
Parameters
The following table shows the parameters of the "Value within range" instruction:
Parameter Declaration Data type Memory area Description
Box input Input BOOL I, Q, M, D, L Result of the
previous logic
operation
MIN Input Integers, floating-
point numbers
I, Q, M, D, L or
constant
Low limit of the
value range
VAL Input Integers, floating-
point numbers
I, Q, M, D, L or
constant
Comparison value
MAX Input Integers, floating-
point numbers
I, Q, M, D, L or
constant
High limit of the
value range
Box output Output BOOL I, Q, M, D, L Result of the
comparison
You can select the data type for the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also":
Example
The following example shows how the instruction works:
lN_RANGE
MlN
MAX
VAL
REAL
"Tagln_1"
"Tag_Min"
"Tag_Value"
"Tag_Max"
"Tagln_2" "Tagln_3" "TagOut"
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1515
The "TagOut" output is set when the following conditions are fulfilled:
The operands "TagIn_1" and "TagIn_2" have signal state "1".
The value of the operand "Tag_Value" is within the value range that is specified by the
current values of the operands "Tag_Min" and "Tag_Max" (MIN <= VAL or VAL <= MAX).
The operand "TagIn_3" has the signal state "1".
See also
Overview of the valid data types (Page 899)
OUT_RANGE: Value outside range
Description
You can use the "Value outside range" instruction to determine if the value at the VAL input is
outside a specific value range.
You specify the limits of the value range with the MIN and MAX inputs. The "Value outside
range" instruction compares the value at the VAL input with the values of the MIN and MAX
inputs and sends the result to the box output. If the value at the VAL input fulfills the comparison
MIN > VAL or VAL > MAX, the box output has the signal state "1". The box output also has
the signal state "1" if a specified operand with the REAL data type shows an invalid value.
The box output returns the signal state "0", if the value at input VAL does not satisfy the MIN
> VAL or VAL > MAX condition.
If the box input has the signal state "0", the "Value outside range" instruction is not executed.
The comparison function can only execute if the values to be compared are of the same data
type and the box input is interconnected.
Parameters
The following table shows the parameters of the "Value outside range" instruction:
Parameter Declaration Data type Memory area Description
Box input Input BOOL I, Q, M, D, L Result of the
previous logic
operation
MIN Input Integers, floating-
point numbers
I, Q, M, D, L or
constant
Low limit of the
value range
VAL Input Integers, floating-
point numbers
I, Q, M, D, L or
constant
Comparison value
MAX Input Integers, floating-
point numbers
I, Q, M, D, L or
constant
High limit of the
value range
Box output Output BOOL I, Q, M, D, L Result of the
comparison
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1516 System Manual, 01/2013,
You can select the data type for the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
OUT_RANGE
MlN
MAX
VAL
REAL
"Tagln_1"
"Tag_Min"
"Tag_Value"
"Tag_Max"
"Tagln_2" "Tagln_3" "TagOut"
The "TagOut" output is set when the following conditions are fulfilled:
The operands "TagIn_1" and "TagIn_2" have signal state "1".
The value of the operand "Tag_Value" is outside the value range that is specified by the
values of the operands "Tag_Min" and "Tag_Max" (MIN > VAL or VAL > MAX).
The operand "TagIn_3" has the signal state "1".
See also
Overview of the valid data types (Page 899)
----I OK I----: Check validity
Description
You can use the "Check validity" instruction to check if the value of an operand (<operand>)
is a valid floating-point number. The query is started in each program cycle when the signal
state at the input of the instruction is "1".
The output of the instruction has signal state "1" when the value of the operand is a valid
floating-point number at the time of the query and the input of the instruction has signal state
"1". In all other cases, the signal state at the output of the "Check validity" instruction is "0".
You can use the "Check validity" instruction together with the EN mechanism. If you connect
the instruction box to an EN enable input, the enable input is set only when the result of the
validity query of the value is positive. You can use this function to ensure that an instruction is
enabled only when the value of the specified operand is a valid floating-point number.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1517
Parameters
The following table shows the parameters of the "Check validity" instruction:
Parameter Declaration Data type Memory area Description
<Operand> Input Floating-point
numbers
I, Q, M, D, L Value to be
queried.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
MUL
ENO EN
lN2
lN1
OUT
OK OK
REAL
"TagOut" "Tag_Value1"
"Tag_Result"
"Tag_Value2"
"Tag_Value2"
"Tag_Value1"
When the values of the operands "Tag_Value1" and "Tag_Value2" show valid floating-point
numbers, the "Multiply" (MUL) instruction is activated and the ENO output is set. During the
execution of the "Multiply" (MUL) instruction, the value of the operand "Tag_Value1" is
multiplied with the value of the operand "Tag_Value2". The product of the multiplication is then
stored in the operand "Tag_Result". If the instruction is executed without errors, the ENO and
"TagOut" outputs are set to signal state "1".
See also
Overview of the valid data types (Page 899)
----I NOT_OK I----: Check invalidity
Description
You can use the "Check invalidity" instruction to check if the value of an operand (<operand>)
is an invalid floating-point number. The query is started in each program cycle when the signal
state at the input of the instruction is "1".
The output of the instruction has signal state "1" when the value of the operand is an invalid
floating-point number at the time of the query and the input of the instruction has signal state
"1". In all other cases, the signal state at the output of the "Check invalidity" instruction is "0".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1518 System Manual, 01/2013,
Parameters
The following table shows the parameters of the "Check invalidity" instruction:
Parameter Declaration Data type Memory area Description
<Operand> Input Floating-point
numbers
I, Q, M, D, L Value to be
queried.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
MOVE
ENO EN
lN OUT
NOT_OK NOT
"Tagln_Value"
"Tagln_Value"
"TagOut_Value"
"TagOut"
When the value of operand "TagIn_Value" is an invalid floating-point number, the "Move value"
(MOVE) instruction will not be executed. The "TagOut" output is reset to signal state "0".
See also
Overview of the valid data types (Page 899)
Math functions
CALCULATE: Calculate
Description
The "Calculate" instruction is used to define and execute an expression for the calculation of
mathematical operations or complex logic operations depending on the selected data type.
You can select the data type of the instruction from the "<???>" drop-down list of the instruction
box. Depending on the data type selected, you can combine the functions of certain instructions
to perform a complex calculation. The information for the expression to be calculated is entered
in a dialog, which you can open with the icon at the upper right edge of the instruction box.
The expression can contain names of input parameters and the syntax of the instructions.
Operand names and operand addresses cannot be specified.
The following table shows the instructions that can be combined in the expression of the
"Calculate" instruction, depending on the selected data type:
Data type Instruction Syntax Example
Bit strings AND: AND logic operation AND IN1 AND IN2 OR IN3
OR: OR logic operation OR
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1519
Data type Instruction Syntax Example
XOR: EXCLUSIVE OR logic operation XOR
INV: Create ones complement NOT
SWAP: Swap
1)
SWAP
Integers ADD: Add + (IN1 + IN2) * IN3;
(ABS(IN2))*(ABS(IN1
))
SUB: Subtract -
MUL: Multiply *
DIV: Divide /
MOD: Return remainder of division MOD
INV: Create ones complement NOT
NEG: Create twos complement -(in1)
ABS: Form absolute value ABS( )
Floating-point numbers ADD: Add + ((SIN(IN2)*SIN(IN2)+
(SIN(IN3)*SIN(IN3))/
IN3;
(SQR(SIN(IN2))+
(SQR(COS(IN3))/IN2
SUB: Subtract -
MUL: Multiply *
DIV: Divide /
EXPT: Exponentiate **
ABS: Form absolute value ABS( )
SQR: Form square SQR( )
SQRT: Form square root SQRT( )
LN: Form natural logarithm LN( )
EXP: Form exponential value EXP( )
FRAC: Return fraction FRAC( )
SIN: Form sine value SIN( )
COS: Form cosine value COS( )
TAN: Form tangent value TAN( )
ASIN: Form arcsine value ASIN( )
ACOS: Form arccosine value ACOS( )
ATAN: Form arctangent value ATAN( )
NEG: Create twos complement -(in1)
TRUNC: Truncate numerical value TRUNC( )
ROUND: Round numerical value ROUND( )
CEIL: Generate next higher integer from floating-
point number
CEIL( )
FLOOR: Generate next lower integer from floating-
point number
FLOOR( )
1)
Not possible for data type BYTE.
In its initial state, the instruction box contains at least 2 inputs (IN1 and IN2). The number of
inputs can be extended. The inserted inputs are numbered in ascending order in the box.
The values of the inputs are used to execute the specified expression. Not all of the defined
inputs have to be used in the expression. The result of the instruction is transferred to the
output OUT.
If you use inputs in the expression that are not available in the box, they are inserted
automatically. This requires that there are no gaps in the numbering of the inputs to be newly
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1520 System Manual, 01/2013,
defined in the expression. For example, you cannot use the IN4 input in the expression unless
the IN3 input has been defined.
The ENO enable output has the signal state "0" if one of the following conditions is fulfilled:
The EN enable input has the signal state "0".
The result of the "Calculate" instruction is outside the range permitted for the data type
specified at the OUT output.
A floating-point number has an invalid value.
An error occurred during execution of one of the instructions in the expression.
Parameters
The following table shows the parameters of the "Calculate" instruction:
Parameters Declaration Data type Memory area Description
EN Input BOOL I, Q, M, D, L Enable input
ENO Output BOOL I, Q, M, D, L Enable output
IN1 Input Bit strings,
integers, floating-
point numbers
I, Q, M, D, L, P or
constant
First available
input
IN2 Input Bit strings,
integers, floating-
point numbers
I, Q, M, D, L, P or
constant
Second available
input
INn Input Bit strings,
integers, floating-
point numbers
I, Q, M, D, L, P or
constant
Additionally
inserted inputs
OUT Output Bit strings,
integers, floating-
point numbers
I, Q, M, D, L, P Output to which
the end result is to
be transferred.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
ENO
OUT
EN
CALCULATE
lNT
lN1
lN2
lN3
lN4
((lN1+lN2)*lN3)/lN4
"Tag_lnput"
"Tag_Value_1"
"Tag_Value_2"
"Tag_Value_3"
"Tag_Value_4"
"Tag_Result"
"Tag_Output"
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1521
The following table shows how the instruction works using specific operand values:
Parameters Operand Value
IN1 Tag_Value_1 4
IN2 Tag_Value_2 4
IN3 Tag_Value_3 3
IN4 Tag_Value_4 2
OUT Tag_Result 12
If the "Tag_Input" input has the signal state"1", the "Calculate" instruction is executed. The
value of operand "Tag_Value_1" is added to the value of operand "Tag_Value_2". The sum is
multiplied with the value of operand "Tag_Value_3". The product is divided by the value of
operand "Tag_Value_4". The quotient is transferred as end result to the operand "Tag_Result"
at the OUT output of the instruction. If the instruction is executed without errors, the enable
output ENO and operand "Tag_Output" are set to "1".
See also
Using the "Calculate" instruction (Page 1096)
Overview of the valid data types (Page 899)
Inserting additional inputs and outputs in LAD elements (Page 1104)
Removing inputs and outputs (Page 1105)
Basics of the EN/ENO mechanism (Page 987)
ADD: Add
Description
You can use the "Add" instruction to add the value at input IN1 and the value at input IN2 and
query the sum at output OUT (OUT := IN1+IN2).
In its initial state, the instruction box contains at least 2 inputs (IN1 and IN2). The number of
inputs can be extended. The inserted inputs are numbered in ascending order in the box. When
the instruction is executed, the values of all available input parameters are added. The sum is
stored at the OUT output.
The ENO enable output has the signal state "0" if one of the following conditions is fulfilled:
The enable input EN has the signal state "0".
The result of the instruction is outside the range permitted for the data type specified at the
OUT output.
A floating-point number has an invalid value.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1522 System Manual, 01/2013,
Parameters
The following table shows the parameters of the "Add" instruction:
Parameter Declaration Data type Memory area Description
EN Input BOOL I, Q, M, D, L Enable input
ENO Output BOOL I, Q, M, D, L Enable output
IN1 Input Integers, floating-
point numbers
I, Q, M, D, L, P or
constant
First number to be
added
IN2 Input Integers, floating-
point numbers
I, Q, M, D, L, P or
constant
Second number to
be added
INn Input Integers, floating-
point numbers
I, Q, M, D, L, P or
constant
Optional input
values that are
added.
OUT Output Integers, floating-
point numbers
I, Q, M, D, L, P Sum
You can select the data type for the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also":
Example
The following example shows how the instruction works:
ADD
ENO S EN
lN2
lN1
OUT
lNT
"Tag_Result"
"Tag_Value2"
"Tag_Value1"
"TagOut" "Tagln"
If operand "TagIn" has the signal state "1", the "Add" instruction is executed. The value of
operand "Tag_Value1" is added to the value of operand "Tag_Value2". The result of the
addition is stored in operand "Tag_Result". If the instruction is executed without errors, the
ENO enable output has the signal state "1" and the "TagOut" output is set.
See also
Overview of the valid data types (Page 899)
Removing inputs and outputs (Page 1105)
Basics of the EN/ENO mechanism (Page 987)
Selecting a data type (Page 1089)
Inserting additional inputs and outputs in LAD elements (Page 1104)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1523
SUB: Subtract
Description
You can use the "Subtract" instruction to subtract the value at input IN2 from the value at input
IN1 and query the difference at output OUT (OUT := IN1-IN2).
The ENO enable output has the signal state "0" if one of the following conditions is fulfilled:
The EN enable input has the signal state "0".
The result of the instruction is outside the range permitted for the data type specified at the
OUT output.
A floating-point number has an invalid value.
Parameters
The following table shows the parameters of the "Subtract" instruction:
Parameter Declaration Data type Memory area Description
EN Input BOOL I, Q, M, D, L Enable input
ENO Output BOOL I, Q, M, D, L Enable output
IN1 Input Integers, floating-
point numbers
I, Q, M, D, L, P or
constant
Minuend
IN2 Input Integers, floating-
point numbers
I, Q, M, D, L, P or
constant
Subtracting
OUT Output Integers, floating-
point numbers
I, Q, M, D, L, P Difference
You can select the data type for the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
SUB
ENO S EN
lN2
lN1
OUT
lNT
"Tag_Result"
"Tag_Value2"
"Tag_Value1"
"TagOut" "Tagln"
If operand "TagIn" has the signal state "1", the "Subtract" instruction is executed. The value of
operand "Tag_Value2" is subtracted from the value of operand "Tag_Value1". The result of
the subtraction is stored in operand "Tag_Result". If the instruction is executed without errors,
the ENO enable output has the signal state "1" and the "TagOut" output is set.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1524 System Manual, 01/2013,
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
Selecting a data type (Page 1089)
MUL: Multiply
Description
You can use the "Multiply" instruction to multiply the value at input IN1 with the value at input
IN2 and query the product at output OUT (OUT := IN1*IN2).
The number of inputs can be expanded in the instruction box. The added inputs are numbered
in ascending order in the box. When the instruction is executed, the values of all available input
parameters are multiplied. The product is stored at the OUT output.
The ENO enable output has the signal state "0" if one of the following conditions is fulfilled:
The EN input has the signal state "0".
The result is outside the range permitted for the data type specified at output OUT.
A floating-point number has an invalid value.
Parameters
The following table shows the parameters of the "Multiply" instruction:
Parameter Declaration Data type Memory area Description
EN Input BOOL I, Q, M, D, L Enable input
ENO Output BOOL I, Q, M, D, L Enable output
IN1 Input Integers, floating-
point numbers
I, Q, M, D, L, P or
constant
Multiplier
IN2 Input Integers, floating-
point numbers
I, Q, M, D, L, P or
constant
Number being
multiplied
INn Input Integers, floating-
point numbers
I, Q, M, D, L, P or
constant
Optional input
values that can be
multiplied.
OUT Output Integers, floating-
point numbers
I, Q, M, D, L, P Product
You can select the data type for the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1525
Example
The following example shows how the instruction works:
REAL
ENO S EN
lN2
lN1
OUT
"Tag_Result"
"Tag_Value2"
"Tag_Value1"
"TagOut" "Tagln"
MUL
If operand "TagIn" has the signal state "1", the "Multiply" instruction is executed. The value of
operand "Tag_Value1" is multiplied by the value of operand "Tag_Value2". The result of the
multiplication is stored in operand "Tag_Result". If the instruction is executed without errors,
the ENO enable output has the signal state "1" and the "TagOut" output is set.
See also
Overview of the valid data types (Page 899)
Removing inputs and outputs (Page 1105)
Basics of the EN/ENO mechanism (Page 987)
Selecting a data type (Page 1089)
Inserting additional inputs and outputs in LAD elements (Page 1104)
DIV: Divide
Description
You can use the "Divide" instruction to divide the value at input IN1 by the value at input IN2
and query the quotient at output OUT (OUT := IN1/IN2).
The ENO enable output has the signal state "0" if one of the following conditions is fulfilled:
The EN enable input has the signal state "0".
The result of the instruction is outside the range permitted for the data type specified at the
OUT output.
A floating-point number has an invalid value.
Parameters
The following table shows the parameters of the "Divide" instruction:
Parameter Declaration Data type Memory area Description
EN Input BOOL I, Q, M, D, L Enable input
ENO Output BOOL I, Q, M, D, L Enable output
IN1 Input Integers, floating-
point numbers
I, Q, M, D, L, P or
constant
Dividend
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1526 System Manual, 01/2013,
Parameter Declaration Data type Memory area Description
IN2 Input Integers, floating-
point numbers
I, Q, M, D, L, P or
constant
Divisor
OUT Output Integers, floating-
point numbers
I, Q, M, D, L, P Quotient value
You can select the data type for the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
REAL
ENO S EN
lN2
lN1
OUT
"Tag_Result"
"Tag_Value2"
"Tag_Value1"
"TagOut" "Tagln"
DlV
If operand "TagIn" has the signal state "1", the "Divide" instruction is executed. The value of
operand "Tag_Value1" is divided by the value of operand "Tag_Value2". The division result is
stored in operand "Tag_Result". If the instruction is executed without errors, the ENO enable
output has the signal state "1" and the "TagOut" output is set.
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
Selecting a data type (Page 1089)
MOD: Return remainder of division
Description
You can use the "Return remainder of division" instruction to divide the value at input IN1 by
the value at input IN2 and query the remainder of division at output OUT.
Parameters
The following table shows the parameters of the "Return remainder of division" instruction:
Parameter Declaration Data type Memory area Description
EN Input BOOL I, Q, M, D, L Enable input
ENO Output BOOL I, Q, M, D, L Enable output
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1527
Parameter Declaration Data type Memory area Description
IN1 Input Integers I, Q, M, D, L, P or
constant
Dividend
IN2 Input Integers I, Q, M, D, L, P or
constant
Divisor
OUT Output Integers I, Q, M, D, L, P Remainder of
division
You can select the data type for the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
ENO S EN
lN2
lN1
OUT
"Tag_Result"
"Tag_Value2"
"Tag_Value1"
"TagOut" "Tagln"
MOD
DlNT
If operand "TagIn" has the signal state "1", the "Return remainder of division" instruction is
executed. The value of operand "Tag_Value1" is divided by the value of operand "Tag_Value2".
The remainder is stored in operand "Tag_Result". If the instruction is executed without errors,
the ENO enable output has the signal state "1" and the "TagOut" output is set.
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
Selecting a data type (Page 1089)
NEG: Create twos complement
Description
You can use the "Create twos complement" instruction to change the sign of the value at the
IN input and query the result at the OUT output. If there is a positive value at input IN, for
example, the negative equivalent of this value is sent to output OUT.
The ENO enable output has the signal state "0" if one of the following conditions is fulfilled:
The EN enable input has the signal state "0".
The result of the instruction is outside the range permitted for the data type specified at the
OUT output.
A floating-point number has an invalid value.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1528 System Manual, 01/2013,
Parameters
The following table shows the parameters of the "Create twos complement" instruction:
Parameter Declaration Data type Memory area Description
S7-1200 S7-1500
EN Input BOOL BOOL I, Q, M, D, L Enable input
ENO Output BOOL BOOL I, Q, M, D, L Enable output
IN Input SINT, INT,
DINT, floating-
point numbers
SINT, INT,
DINT, LINT,
floating-point
numbers
I, Q, M, D, L, P
or constant
Input value
OUT Output SINT, INT,
DINT, floating-
point numbers
SINT, INT,
DINT, LINT,
floating-point
numbers
I, Q, M, D, L, P Twos
complement of
the input value
You can select the data type for the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
EN
NEG
ENO
lN OUT
REAL
"Tagln_Value" "TagOut_Value"
"TagOut" "Tagln"
If operand "TagIn" has the signal state "1", the "Create twos complement" instruction is
executed. The sign of the value at input "TagIn_Value" is changed and the result is provided
at "TagOut_Value" output. If the instruction is executed without errors, the ENO enable output
has the signal state "1" and the "TagOut" output is set.
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
INC: Increment
Description
You can use the "Increment" instruction to change the value of the operand at the IN/OUT
parameter to the next higher value and query the result. The "Increment" instruction is only
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1529
started when the signal state at the EN enable input is "1". If no overflow error occurs during
the execution, the ENO enable output also has the signal state "1".
The ENO enable output has the signal state "0" if one of the following conditions is fulfilled:
The EN enable input has the signal state "0".
A floating-point number has an invalid value.
Parameters
The following table shows the parameters of the "Increment" instruction:
Parameter Declaration Data type Memory area Description
EN Input BOOL I, Q, M, D, L Enable input
ENO Output BOOL I, Q, M, D, L Enable output
IN/OUT InOut Integers I, Q, M, D, L Value to be
incremented.
You can select the data type for the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
lNC
OUT lN/
EN ENO
lNT
"Tag_lnOut"
"TagOut" "Tagln_1" "Tagln_2"
If operands "TagIn_1" and "TagIn_2" have the signal state "1", the value of operand
"Tag_InOut" is incremented by one and the "TagOut" output is set.
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
DEC: Decrement
Description
You can use the "Decrement" instruction to change the value of the operand at the IN/OUT
parameter to the next lower value and query the result. The "Decrement" instruction is only
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1530 System Manual, 01/2013,
started when the signal state at the EN enable input is "1". If the range of values of the selected
data type is not exceeded during processing, the ENO output also has the signal state "1".
The ENO enable output has the signal state "0" if one of the following conditions is fulfilled:
The EN enable input has the signal state "0".
A floating-point number has an invalid value.
Parameter
The following table shows the parameters of the "Decrement" instruction:
Parameter Declaration Data type Memory area Description
EN Input BOOL I, Q, M, D, L Enable input
ENO Output BOOL I, Q, M, D, L Enable output
IN/OUT InOut Integers I, Q, M, D, L Value to be
decremented.
You can select the data type for the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
DEC
OUT lN/
EN ENO
lNT
"Tag_lnOut"
"TagOut" "Tagln_1" "Tagln_2"
If operands "TagIn_1" and "TagIn_2" have the signal state "1", the value of operand
"Tag_InOut" is decremented by one and the "TagOut" output is set.
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
ABS: Form absolute value
Description
You can use the "Form absolute value" instruction to calculate the absolute value of the value
specified at input IN. The result of the instruction is sent to the OUT output and can be queried
there.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1531
The ENO enable output has the signal state "0" if one of the following conditions is fulfilled:
The EN enable input has the signal state "0".
A floating-point number has an invalid value.
Parameters
The following table shows the parameters of the "Form absolute value" instruction:
Parameter Declaration Data type Memory area Description
S7-1200 S7-1500
EN Input BOOL BOOL I, Q, M, D, L Enable input
ENO Output BOOL BOOL I, Q, M, D, L Enable output
IN Input SINT, INT,
DINT, floating-
point numbers
SINT, INT,
DINT, LINT,
floating-point
numbers
I, Q, M, D, L, P
or constant
Input value
OUT Output SINT, INT,
DINT, floating-
point numbers
SINT, INT,
DINT, LINT,
floating-point
numbers
I, Q, M, D, L, P Absolute value
of the input
value
You can select the data type for the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
ABS
ENO EN
lN OUT
REAL
"Tagln_Value" "TagOut_Value"
"TagOut" "Tagln"
The following table shows how the instruction works using specific operand values:
Parameter Operand Value
IN TagIn_Value -6.234
OUT TagOut_Value 6.234
If operand "TagIn" has the signal state "1", the "Form absolute value" instruction is executed.
The instruction calculates the absolute value of the value at input "TagIn_Value" and sends
the result to output "TagOut_Value". If the instruction is executed without errors, the "TagOut"
output is set.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1532 System Manual, 01/2013,
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
MIN: Get minimum
Description
The "Get minimum" instruction compares the values at the available inputs and writes the
lowest value to the OUT output. The number of inputs can be expanded in the instruction box
by additional inputs. The inputs are numbered in ascending order in the box.
A minimum of two and a maximum of 100 inputs must be specified for the execution of the
instruction. All tags at the inputs must have the same data type.
The ENO enable output has the signal state "0" if one of the following conditions is fulfilled:
Enable input EN has the signal state "0".
The specified tags are not of the same data type.
A floating-point number has an invalid value.
Parameters
The following table shows the parameters of the "Get minimum" instruction:
Parameter Declaration Data type Memory area Description
S7-1200 S7-1500
EN Input BOOL BOOL I, Q, M, D, L Enable input
ENO Output BOOL BOOL I, Q, M, D, L Enable output
IN1 Input Integers,
floating-point
numbers,
TIME, TOD,
DATE
Integers, floating-
point numbers,
timers, TOD,
LTOD, DATE, LDT
I, Q, M, D, L, P or
constant
First input value
IN2 Input Integers,
floating-point
numbers,
TIME, TOD,
DATE
Integers, floating-
point numbers,
timers, TOD,
LTOD, DATE, LDT
I, Q, M, D, L, P or
constant
Second input value
INn Input Integers,
floating-point
numbers,
TIME, TOD,
DATE
Integers, floating-
point numbers,
timers, TOD,
LTOD, DATE, LDT
I, Q, M, D, L, P or
constant
Additionally
inserted inputs
whose values are
to be compared.
OUT Output Integers,
floating-point
numbers,
TIME, TOD,
DATE
Integers, floating-
point numbers,
timers, TOD,
LTOD, DATE, LDT
I, Q, M, D, L, P Result
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1533
You can select the data type for the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
MlN
OUT lN1
EN ENO
lNT
lN2 "Tagln_Value2"
lN3 "Tagln_Value3"
"Tagln_Value1" "TagOut_Value"
"TagOut" "Tagln_1" "Tagln_2"
The following table shows how the instruction works using specific operand values:
Parameter Operand Value
IN1 TagIn_Value1 12222
IN2 TagIn_Value2 14444
IN3 TagIn_Value3 13333
OUT TagOut_Value 12222
If the "TagIn_1" and "TagIn_2" operands have signal state "1", the "Get minimum" instruction
is executed. The instruction compares the values of the specified operands and copies the
lowest value ("TagIn_Value1") to output "TagOut_Value". If the instruction is executed without
errors, the "TagOut" output is set.
See also
Overview of the valid data types (Page 899)
Inserting additional inputs and outputs in LAD elements (Page 1104)
Basics of the EN/ENO mechanism (Page 987)
MAX: Get maximum
Description
The "Get maximum" instruction compares the values at the available inputs and writes the
highest value to the OUT output. The number of inputs can be expanded in the instruction box
by additional inputs. The inputs are numbered in ascending order in the box.
A minimum of two and a maximum of 100 inputs must be specified for the execution of the
instruction. All tags at the inputs must have the same data type.
The ENO enable output has the signal state "0" if one of the following conditions is fulfilled:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1534 System Manual, 01/2013,
Enable input EN has the signal state "0".
The specified tags are not of the same data type.
A floating-point number has an invalid value.
Parameters
The following table shows the parameters of the "Get maximum" instruction:
Parameter Declaration Data type Memory area Description
S7-1200 S7-1500
EN Input BOOL BOOL I, Q, M, D, L Enable input
ENO Output BOOL BOOL I, Q, M, D, L Enable output
IN1 Input Integers,
floating-
point
numbers,
TIME, TOD,
DATE
Integers,
floating-point
numbers,
timers, TOD,
LTOD, DATE,
LDT
I, Q, M, D, L, P
or constant
First input value
IN2 Input Integers,
floating-
point
numbers,
TIME, TOD,
DATE
Integers,
floating-point
numbers,
timers, TOD,
LTOD, DATE,
LDT
I, Q, M, D, L, P
or constant
Second input
value
INn Input Integers,
floating-
point
numbers,
TIME, TOD,
DATE
Integers,
floating-point
numbers,
timers, TOD,
LTOD, DATE,
LDT
I, Q, M, D, L, P
or constant
Additionally
inserted inputs
whose values
are to be
compared.
OUT Output Integers,
floating-
point
numbers,
TIME, TOD,
DATE
Integers,
floating-point
numbers,
timers, TOD,
LTOD, DATE,
LDT
I, Q, M, D, L, P Result
You can select the data type for the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1535
Example
The following example shows how the instruction works:
MAX
OUT lN1
EN ENO
lNT
lN2 "Tagln_Value2"
lN3 "Tagln_Value3"
"Tagln_Value1" "TagOut_Value"
"TagOut" "Tagln_1" "Tagln_2"
The following table shows how the instruction works using specific operand values:
Parameter Operand Value
IN1 TagIn_Value1 12222
IN2 TagIn_Value2 14444
IN3 TagIn_Value3 13333
OUT TagOut_Value 14444
If the "TagIn_1" and "TagIn_2" operands have signal state "1", the "Get maximum" instruction
is executed. The instruction compares the values of the specified operands and copies the
highest value ("TagIn_Value2") to output "TagOut_Value". If the instruction is executed without
errors, the "TagOut" output is set.
See also
Overview of the valid data types (Page 899)
Inserting additional inputs and outputs in LAD elements (Page 1104)
Removing inputs and outputs (Page 1105)
Basics of the EN/ENO mechanism (Page 987)
LIMIT: Set limit value
Description
You use the "Set limit value" instruction to limit the value at input IN to the values at the inputs
MN and MX. If the value at the IN input meets the condition MN <= IN <= MX, it is copied to
the OUT output. If the condition is not fulfilled and the input value IN is below the low limit MN,
the output OUT is set to the value of the MN input. If the MX high limit is exceeded, the OUT
output is set to the value of the MX input.
If the value at the MN input is greater than at the MX input, the result is undefined and the
enable output ENO is "0".
The ENO enable output has the signal state "0" if one of the following conditions is fulfilled:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1536 System Manual, 01/2013,
Enable input EN has the signal state "0".
The specified tags are not of the same data type.
An operand has an invalid value.
The value at the MN input is greater than the value at the MX input.
Parameters
The following table shows the parameters of the "Set limit value" instruction:
Parameter Declaration Data type Memory area Description
S7-1200 S7-1500
EN Input BOOL BOOL I, Q, M, D, L Enable input
ENO Output BOOL BOOL I, Q, M, D, L Enable output
MN Input Integers,
floating-
point
numbers,
TIME, TOD,
DATE, DT
Integers,
floating-point
numbers,
timers, TOD,
LTOD, DATE,
DT, LDT
I, Q, M, D, L, P
or constant
Low limit
IN Input Integers,
floating-
point
numbers,
TIME, TOD,
DATE, DT
Integers,
floating-point
numbers,
timers, TOD,
LTOD, DATE,
DT, LDT
I, Q, M, D, L, P
or constant
Input value
MX Input Integers,
floating-
point
numbers,
TIME, TOD,
DATE, DT
Integers,
floating-point
numbers,
timers, TOD,
LTOD, DATE,
DT, LDT
I, Q, M, D, L, P
or constant
High limit
OUT Output Integers,
floating-
point
numbers,
TIME, TOD,
DATE, DT
Integers,
floating-point
numbers,
timers, TOD,
LTOD, DATE,
DT, LDT
I, Q, M, D, L, P Result
You can select the data type for the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1537
Example
The following example shows how the instruction works:
LlMlT
OUT MN
EN ENO
lNT
lN
MX
"Tag_Value"
"Tag_MX"
"Tag_MN" "Tag_Result"
"TagOut" "Tagln_1" "Tagln_2"
The following table shows how the instruction works using specific operand values:
Parameter Operand Value
MN Tag_MN 12000
IN Tag_Value 8000
MX Tag_MX 16000
OUT Tag_Result 12000
If operands "TagIn_1" and "TagIn_2" have the signal state "1", the "Set limit value" instruction
is executed. The value of operand "Tag_Value" is compared with the values of operands
"Tag_MN" and "Tag_MX". Since the value of operand "Tag_Value" is less than the low limit,
the value of operand "Tag_MN" is copied to the "Tag_Result" output. If the instruction is
executed without errors, the "TagOut" output is set.
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
SQR: Form square
Description
You can use the "Form square" instruction to square the value at the IN input and query the
result at the OUT output.
The ENO enable output has the signal state "0" if one of the following conditions is fulfilled:
The EN enable input has the signal state "0".
The value at the IN input is not a valid floating-point number.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1538 System Manual, 01/2013,
Parameters
The following table shows the parameters of the "Form square" instruction:
Parameter Declaration Data type Memory area Description
EN Input BOOL I, Q, M, D, L Enable input
ENO Output BOOL I, Q, M, D, L Enable output
IN Input Floating-point
numbers
I, Q, M, D, L, P or
constant
Input value
OUT Output Floating-point
numbers
I, Q, M, D, L, P Square of the
input value
You can select the data type for the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
SQR
ENO EN
lN OUT
REAL
"Tag_Result" "Tag_Value"
"TagOut" "Tagln"
The following table shows how the instruction works using specific operand values:
Parameter Operand Value
IN Tag_Value 5.0
OUT Tag_Result 25.0
If operand "TagIn" has the signal state "1", the "Form square" instruction is executed. The
instruction squares the value of operand "Tag_Value" and sends the result to the "Tag_Result"
output. If the instruction is executed without errors, the "TagOut" output is set.
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
SQRT: Form square root
Description
You can use the "Form square root" instruction to find the square root of the value at the IN
input and query the result at the OUT output. The instruction outputs a positive result if the
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1539
input value is greater than zero. If input values are less than zero, the OUT output returns an
invalid floating-point number. If the value at input IN is "0", then the result is also "0".
The ENO enable output has the signal state "0" if one of the following conditions is fulfilled:
The EN enable input has the signal state "0".
The value at the IN input is not a valid floating-point number.
The value at the IN input is negative.
Parameters
The following table shows the parameters of the "Form square root" instruction:
Parameter Declaration Data type Memory area Description
EN Input BOOL I, Q, M, D, L Enable input
ENO Output BOOL I, Q, M, D, L Enable output
IN Input Floating-point
numbers
I, Q, M, D, L, P or
constant
Input value
OUT Output Floating-point
numbers
I, Q, M, D, L, P Square root of the
input value
You can select the data type for the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
SQRT
ENO EN
lN OUT
REAL
"Tag_Result" "Tag_Value"
"TagOut" "Tagln"
The following table shows how the instruction works using specific operand values:
Parameter Operand Value
IN Tag_Value 25.0
OUT Tag_Result 5.0
If operand "TagIn" has the signal state "1", the "Form square root" instruction is executed. The
instruction finds the square root of the value of operand "Tag_Value" and stores the result in
the "Tag_Result" output. If the instruction is executed without errors, the "TagOut" output is
set.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1540 System Manual, 01/2013,
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
LN: Form natural logarithm
Description
You can use the "Form natural logarithm" instruction to calculate the natural logarithm to base
e (e = 2.718282) of the value at input IN. The result is sent to the OUT output and can be
queried there. The instruction outputs a positive result if the input value is greater than zero.
If input values are less than zero, the OUT output returns an invalid floating-point number.
The ENO enable output has the signal state "0" if one of the following conditions is fulfilled:
The enable input EN has the signal state "0".
The value at the IN input is not a valid floating-point number.
The value at the IN input is negative.
Parameters
The following table shows the parameters of the "Form natural logarithm" instruction:
Parameters Declaration Data type Memory area Description
EN Input BOOL I, Q, M, D, L Enable input
ENO Output BOOL I, Q, M, D, L Enable output
IN Input Floating-point
numbers
I, Q, M, D, L, P or
constant
Input value
OUT Output Floating-point
numbers
I, Q, M, D, L, P Natural logarithm
of the input value
You can select the data type for the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
LN
ENO EN
lN OUT
REAL
"Tag_Result" "Tag_Value"
"TagOut" "Tagln"
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1541
If operand "TagIn" has the signal state "1", the "Form natural logarithm" instruction is executed.
The instruction forms the natural logarithm of the value at the "Tag_Value" input and stores
the result in the "Tag_Result" output. If the instruction is executed without errors, the "TagOut"
output is set.
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
EXP: Form exponential value
Description
You can use the "Form exponential value" instruction to calculate the exponent from the base
e (e = 2.718282) and the value specified at input IN. The result is provided at output OUT and
can be queried there (OUT = e
IN
).
The ENO enable output has the signal state "0" if one of the following conditions is fulfilled:
The enable input EN has the signal state "0".
The value at the IN input is not a valid floating-point number.
Parameters
The following table shows the parameters of the "Form exponential value" instruction:
Parameters Declaration Data type Memory area Description
EN Input BOOL I, Q, M, D, L Enable input
ENO Output BOOL I, Q, M, D, L Enable output
IN Input Floating-point
numbers
I, Q, M, D, L, P or
constant
Input value
OUT Output Floating-point
numbers
I, Q, M, D, L, P Exponential value
of input value IN
You can select the data type for the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1542 System Manual, 01/2013,
Example
The following example shows how the instruction works:
EXP
ENO EN
lN OUT
REAL
"Tag_Result" "Tag_Value"
"TagOut" "Tagln"
If operand "TagIn" has the signal state "1", the "Form exponential value" instruction is executed.
The instruction calculates the exponent from base e and the value of operand "Tag_Value"
and sends the result to the "Tag_Result" output. If the instruction is executed without errors,
the "TagOut" output is set.
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
SIN: Form sine value
Description
Use the "Form sine value" instruction to calculate the sine of the angle. The size of the angle
is specified in radians at the IN input. The result of the instruction is sent to the OUT output
and can be queried there.
The ENO enable output has the signal state "0" if one of the following conditions is fulfilled:
The EN enable input has the signal state "0".
The value at the IN input is not a valid floating-point number.
Parameters
The following table shows the parameters of the "Form sine value" instruction:
Parameter Declaration Data type Memory area Description
EN Input BOOL I, Q, M, D, L Enable input
ENO Output BOOL I, Q, M, D, L Enable output
IN Input Floating-point
numbers
I, Q, M, D, L, P or
constant
Size of angle in
radians
OUT Output Floating-point
numbers
I, Q, M, D, L, P Sine of the
specified angle
You can select the data type for the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1543
Example
The following example shows how the instruction works:
SlN
ENO EN
lN OUT
REAL
"Tag_Result" "Tag_Value"
"TagOut" "Tagln"
The following table shows how the instruction works using specific operand values:
Parameter Operand Value
IN Tag_Value +1.570796 (/2)
OUT Tag_Result 1.0
If operand "TagIn" has the signal state "1", the "Form sine value" instruction is executed. The
instruction calculates the sine of the angle specified at the "Tag_Value" input and stores the
result in the "Tag_Result" output. If the instruction is executed without errors, the "TagOut"
output is set.
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
COS: Form cosine value
Description
Use the "Form cosine value" instruction to calculate the cosine of the angle. The size of the
angle is specified in radians at the IN input. The result of the instruction is sent to the OUT
output and can be queried there.
The ENO enable output has the signal state "0" if one of the following conditions is fulfilled:
The EN enable input has the signal state "0".
The value at the IN input is not a valid floating-point number.
Parameters
The following table shows the parameters of the "Form cosine value" instruction:
Parameter Declaration Data type Memory area Description
EN Input BOOL I, Q, M, D, L Enable input
ENO Output BOOL I, Q, M, D, L Enable output
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1544 System Manual, 01/2013,
Parameter Declaration Data type Memory area Description
IN Input Floating-point
numbers
I, Q, M, D, L, P or
constant
Size of angle in
radians
OUT Output Floating-point
numbers
I, Q, M, D, L, P Cosine of the
specified angle
You can select the data type for the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
COS
ENO EN
lN OUT
REAL
"Tag_Result" "Tag_Value"
"TagOut" "Tagln"
The following table shows how the instruction works using specific operand values:
Parameter Operand Value
IN Tag_Value +1.570796 (/2)
OUT Tag_Result 0
If operand "TagIn" has the signal state "1", the "Form cosine value" instruction is executed.
The instruction calculates the cosine of the angle specified at the "Tag_Value" input and stores
the result in the "Tag_Result" output. If the instruction is executed without errors, the "TagOut"
output is set.
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
TAN: Form tangent value
Description
Use the "Form tangent value" instruction to calculate the tangent of the angle. The size of the
angle is specified in radians at the IN input. The result of the instruction is sent to the OUT
output and can be queried there.
The ENO enable output has the signal state "0" if one of the following conditions is fulfilled:
The EN enable input has the signal state "0".
The value at the IN input is not a valid floating-point number.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1545
Parameters
The following table shows the parameters of the "Form tangent value" instruction:
Parameters Declaration Data type Memory area Description
EN Input BOOL I, Q, M, D, L Enable input
ENO Output BOOL I, Q, M, D, L Enable output
IN Input Floating-point
numbers
I, Q, M, D, L, P or
constant
Size of angle in
radians
OUT Output Floating-point
numbers
I, Q, M, D, L, P Tangent of the
specified angle
You can select the data type for the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
TAN
ENO EN
lN OUT
REAL
"Tag_Result" "Tag_Value"
"TagOut" "Tagln"
The following table shows how the instruction works using specific operand values:
Parameter Operand Value
IN Tag_Value +3.141593 ()
OUT Tag_Result 0
If operand "TagIn" has the signal state "1", the "Form tangent value" instruction is executed.
The instruction calculates the tangent of the angle specified at the "Tag_Value" input and stores
the result in the "Tag_Result" output. If the instruction is executed without errors, the "TagOut"
output is set.
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1546 System Manual, 01/2013,
ASIN: Form arcsine value
Description
You can use the "Form arcsine value" instruction to calculate the size of the angle from the
arcsine value specified at input IN, which corresponds to this value. Only valid floating-point
numbers within the range -1 to +1 can be specified at the IN input. The calculated angle size
is output in radians at the OUT output and can range in value from -/2 to +/2.
The ENO enable output has the signal state "0" if one of the following conditions is fulfilled:
The EN enable input has the signal state "0".
The value at the IN input is not a valid floating-point number.
The value at the IN input is outside the permitted value range (-1 to +1).
Parameters
The following table shows the parameters of the "Form arcsine value" instruction:
Parameters Declaration Data type Memory area Description
EN Input BOOL I, Q, M, D, L Enable input
ENO Output BOOL I, Q, M, D, L Enable output
IN Input Floating-point
numbers
I, Q, M, D, L, P or
constant
Sine value
OUT Output Floating-point
numbers
I, Q, M, D, L, P Size of angle in
radians
You can select the data type for the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
ASlN
ENO EN
lN OUT
REAL
"Tag_Result" "Tag_Value"
"TagOut" "Tagln"
The following table shows how the instruction works using specific operand values:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1547
Parameters Operand Value
IN Tag_Value 1.0
OUT Tag_Result +1.570796 (/2)
If operand "TagIn" has the signal state "1", the "Form arcsine value" instruction is executed.
The instruction calculates the size of the angle corresponding to the sine value at the
"Tag_Value" input. The result of the instruction is stored in the "Tag_Result" output. If the
instruction is executed without errors, the "TagOut" output is set.
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
ACOS: Form arccosine value
Description
You can use the "Form arccosine value" instruction to calculate the size of the angle from the
cosine value specified at input IN, which corresponds to this value. Only valid floating-point
numbers within the range -1 to +1 can be specified at the IN input. The calculated angle size
is output in radians at the OUT output and can range in value from 0 to +.
The ENO enable output has the signal state "0" if one of the following conditions is fulfilled:
The EN enable input has the signal state "0".
The value at the IN input is not a valid floating-point number.
The value at the IN input is outside the permitted value range (-1 to +1).
Parameters
The following table shows the parameters of the "Form arccosine value" instruction:
Parameters Declaration Data type Memory area Description
EN Input BOOL I, Q, M, D, L Enable input
ENO Output BOOL I, Q, M, D, L Enable output
IN Input Floating-point
numbers
I, Q, M, D, L, P or
constant
Cosine value
OUT Output Floating-point
numbers
I, Q, M, D, L, P Size of angle in
radians
You can select the data type for the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1548 System Manual, 01/2013,
Example
The following example shows how the instruction works:
ACOS
ENO EN
lN OUT
REAL
"Tag_Result" "Tag_Value"
"TagOut" "Tagln"
The following table shows how the instruction works using specific operand values:
Parameters Operand Value
IN Tag_Value 0
OUT Tag_Result +1.570796 (/2)
If operand "TagIn" has the signal state "1", the "Form arccosine value" instruction is executed.
The instruction calculates the size of the angle corresponding to the cosine value at the
"Tag_Value" input. The result of the instruction is stored in the "Tag_Result" output. If the
instruction is executed without errors, the "TagOut" output is set.
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
ATAN: Form arctangent value
Description
You can use the "Form arctangent value" instruction to calculate the size of the angle from the
tangent value specified at input IN, which corresponds to this value. Only valid floating-point
numbers may be specified at the IN input. The calculated angle size is output in radians at the
OUT output and can range in value from -/2 to +/2.
The ENO enable output has the signal state "0" if one of the following conditions is fulfilled:
The EN enable input has the signal state "0".
The value at the IN input is not a valid floating-point number.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1549
Parameters
The following table shows the parameters of the "Form arctangent value" instruction:
Parameters Declaration Data type Memory area Description
EN Input BOOL I, Q, M, D, L Enable input
ENO Output BOOL I, Q, M, D, L Enable output
IN Input Floating-point
numbers
I, Q, M, D, L, P or
constant
Tangent value
OUT Output Floating-point
numbers
I, Q, M, D, L, P Size of angle in
radians
You can select the data type for the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
ATAN
ENO EN
lN OUT
REAL
"Tag_Result" "Tag_Value"
"TagOut" "Tagln"
The following table shows how the instruction works using specific operand values:
Parameters Operand Value
IN Tag_Value 1.0
OUT Tag_Result +0.785398 (/4)
If operand "TagIn" has the signal state"1", the "Form arctangent value" instruction is executed.
The instruction calculates the size of the angle corresponding to the tangent value at the
"Tag_Value" input. The result of the instruction is stored in the "Tag_Result" output. If the
instruction is executed without errors, the "TagOut" output is set.
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1550 System Manual, 01/2013,
FRAC: Return fraction
Description
You can use the "Return fraction" instruction to determine the decimal places of the value at
the IN input. The result of the query is stored at the OUT output and can be queried there. If,
for example, the IN input has the value 123.4567, the OUT output returns the value 0.4567.
The ENO enable output has the signal state "0" if one of the following conditions is fulfilled:
The EN enable input has the signal state "0".
Errors occur during execution of the instruction, for example, there is no valid floating-point
number at the IN input.
Parameters
The following table shows the parameters of the "Return fraction" instruction:
Parameters Declaration Data type Memory area Description
EN Input BOOL I, Q, M, D, L Enable input
ENO Output BOOL I, Q, M, D, L Enable output
IN Input Floating-point
numbers
I, Q, M, D, L, P or
constant
Value, whose
decimal places
are to be
determined.
OUT Output Floating-point
numbers
I, Q, M, D, L, P Decimal places of
the value at the IN
input
You can select the data type for the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
FRAC
OUT lN
EN ENO
REAL
"Tag_Result" "Tag_Value"
"TagOut" "Tagln_1" "Tagln_2"
The following table shows how the instruction works using specific operand values:
Parameter Operand Value
IN Tag_Value 2.555
OUT Tag_Result 0.555
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1551
If operands "TagIn_1" and "TagIn_2" have the signal state "1", the "Return fraction" instruction
is started. The decimal places from the value of operand "Tag_Value" are copied to operand
"Tag_Result". If the instruction is executed without errors, the ENO output has the signal state
"1" and the "TagOut" output is set.
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
EXPT: Exponentiate
Description
You can use the "Exponentiate" instruction to raise the value at the IN1 input to a power
specified with the value at the IN2 input. The result of the instruction is provided at the OUT
output and can be queried there (OUT =IN1
IN2
).
The IN1 input can only be assigned valid floating-point numbers. Integers can also be assigned
to the IN2 input.
The ENO enable output has the signal state "0" if one of the following conditions is fulfilled:
The EN enable input has the signal state "0".
Errors occur during execution of the instruction, for example, an overflow occurs.
Parameters
The following table shows the parameters of the "Exponentiate" instruction:
Parameter Declaration Data type Memory area Description
EN Input BOOL I, Q, M, D, L Enable input
ENO Output BOOL I, Q, M, D, L Enable output
IN1 Input Floating-point
numbers
I, Q, M, D, L, P or
constant
Base value
IN2 Input Integers, floating-
point numbers
I, Q, M, D, L, P or
constant
Value with which
the base value is
exponentiated
OUT Output Floating-point
numbers
I, Q, M, D, L, P Result
You can select the data type for the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1552 System Manual, 01/2013,
Example
The following example shows how the instruction works:
EXPT
OUT lN1
EN ENO
REAL
lN2
REAL **
"Tag_Result" "Tag_Value1"
"Tag_Value2"
"TagOut" "Tagln_1" "Tagln_2"
If operands "TagIn_1" and "TagIn_2" have the signal state "1", the "Exponentiate" instruction
is started. The value of operand "Tag_Value1" is raised to a power specified with the value of
operand "Tag_Value2". The result is stored in the "Tag_Result" output. If the instruction is
executed without errors, the ENO enable output has the signal state "1" and the "TagOut"
output is set.
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
Move operations
MOVE: Move value
Description
You use the "Move value" instruction to transfer the contents of the operand at the IN input to
the operand at the OUT1 output. The transfer is always made in the direction of the ascending
address.
The following table shows the available transfers for the S7-1200 CPU family:
Source (IN) Destination (OUT1)
With IEC check Without IEC check
BYTE BYTE, WORD, DWORD BYTE, WORD, DWORD, SINT, USINT, INT, UINT,
DINT, UDINT, TIME, DATE ,TOD, CHAR
WORD WORD, DWORD BYTE, WORD, DWORD, SINT, USINT, INT, UINT,
DINT, UDINT, TIME, DATE, TOD, CHAR
DWORD DWORD BYTE, WORD, DWORD, SINT, USINT, INT, UINT,
DINT, UDINT, REAL, TIME, DATE, TOD, CHAR
SINT SINT BYTE, WORD, DWORD, SINT, USINT, INT, UINT,
DINT, UDINT, TIME, DATE, TOD
USINT USINT, UINT, UDINT BYTE, WORD, DWORD, SINT, USINT, INT, UINT,
DINT, UDINT, TIME, DATE, TOD
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1553
Source (IN) Destination (OUT1)
With IEC check Without IEC check
INT INT BYTE, WORD, DWORD, SINT, USINT, INT, UINT,
DINT, UDINT, TIME, DATE, TOD
UINT UINT, UDINT BYTE, WORD, DWORD, SINT, USINT, INT, UINT,
DINT, UDINT, TIME, DATE, TOD
DINT DINT BYTE, WORD, DWORD, SINT, USINT, INT, UINT,
DINT, UDINT, TIME, DATE, TOD
UDINT UDINT BYTE, WORD, DWORD, SINT, USINT, INT, UINT,
DINT, UDINT, TIME, DATE, TOD
REAL REAL DWORD, REAL
LREAL LREAL LREAL
TIME TIME BYTE, WORD, DWORD, SINT, USINT, INT, UINT,
DINT, UDINT, TIME
DATE DATE BYTE, WORD, DWORD, SINT, USINT, INT, UINT,
DINT, UDINT, DATE
TOD TOD BYTE, WORD, DWORD, SINT, USINT, INT, UINT,
DINT, UDINT, TOD
DTL DTL DTL
CHAR CHAR BYTE, WORD, DWORD, CHAR, Character of a
string
1)
Character of a
string
1)
Character of a string Character of a string CHAR
ARRAY
2)
ARRAY ARRAY
STRUCT STRUCT STRUCT
PLC data type
(UDT)
PLC data type (UDT) PLC data type (UDT)
IEC_TIMER IEC_TIMER IEC_TIMER
IEC_SCOUNTE
R
IEC_SCOUNTER IEC_SCOUNTER
IEC_USCOUNT
ER
IEC_USCOUNTER IEC_USCOUNTER
IEC_COUNTER IEC_COUNTER IEC_COUNTER
IEC_UCOUNTE
R
IEC_UCOUNTER IEC_UCOUNTER
IEC_DCOUNTE
R
IEC_DCOUNTER IEC_DCOUNTER
IEC_UDCOUN
TER
IEC_UDCOUNTER IEC_UDCOUNTER
The following table shows the available transfers for the S7-1500 CPU family:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1554 System Manual, 01/2013,
Source (IN) Destination (OUT1)
With IEC check Without IEC check
BYTE BYTE, WORD, DWORD,
LWORD
BYTE, WORD, DWORD, LWORD, SINT, USINT,
INT, UINT, DINT, UDINT, LINT, ULINT, TIME, LTIME,
LDT, DATE ,TOD, LTOD, CHAR
WORD WORD, DWORD, LWORD BYTE, WORD, DWORD, LWORD, SINT, USINT,
INT, UINT, DINT, UDINT, LINT, ULINT, S5TIME,
TIME, LTIME, LDT, DATE, TOD, LTOD, CHAR
DWORD DWORD, LWORD BYTE, WORD, DWORD, LWORD, SINT, USINT,
INT, UINT, DINT, UDINT, LINT, ULINT, REAL, TIME,
LTIME, LDT, DATE, TOD, LTOD, CHAR
LWORD LWORD BYTE, WORD, DWORD, LWORD, SINT, USINT,
INT, UINT, DINT, UDINT, LINT, ULINT, LREAL,
TIME, LTIME, LDT, DATE, TOD, LTOD, CHAR
SINT SINT BYTE, WORD, DWORD, LWORD, SINT, USINT,
INT, UINT, DINT, UDINT, LINT, ULINT, TIME, LTIME,
LDT, DATE, TOD, LTOD
USINT USINT, UINT, UDINT,
ULINT
BYTE, WORD, DWORD, LWORD, SINT, USINT,
INT, UINT, DINT, UDINT, LINT, ULINT, TIME, LTIME,
LDT, DATE, TOD, LTOD
INT INT BYTE, WORD, DWORD, LWORD, SINT, USINT,
INT, UINT, DINT, UDINT, LINT, ULINT, TIME, LTIME,
LDT, DATE, TOD, LTOD
UINT UINT, UDINT, ULINT BYTE, WORD, DWORD, LWORD, SINT, USINT,
INT, UINT, DINT, UDINT, LINT, ULINT, TIME, LTIME,
LDT, DATE, TOD. LTOD
DINT DINT BYTE, WORD, DWORD, LWORD, SINT, USINT,
INT, UINT, DINT, UDINT, LINT, ULINT, TIME, LTIME,
LDT, DATE, TOD, LTOD
UDINT UDINT, ULINT BYTE, WORD, DWORD, LWORD, SINT, USINT,
INT, UINT, DINT, UDINT, LINT, ULINT, TIME, LTIME,
LDT, DATE, TOD, LTOD
LINT LINT BYTE, WORD, DWORD, LWORD, SINT, USINT,
INT, UINT, DINT, UDINT, LINT, ULINT, TIME, LTIME,
LDT, DATE, TOD, LTOD
ULINT ULINT BYTE, WORD, DWORD, LWORD, SINT, USINT,
INT, UINT, DINT, UDINT, LINT, ULINT, TIME, LTIME,
LDT, DATE, TOD, LTOD
REAL REAL DWORD, REAL
LREAL LREAL LWORD, LREAL
S5TIME S5TIME WORD, S5TIME
TIME TIME BYTE, WORD, DWORD, LWORD, SINT, USINT,
INT, UINT, DINT, UDINT, LINT, ULINT, TIME
LTIME LTIME BYTE, WORD, DWORD, LWORD, SINT, USINT,
INT, UINT, DINT, UDINT, LINT, ULINT, LTIME
DATE DATE BYTE, WORD, DWORD, LWORD, SINT, USINT,
INT, UINT, DINT, UDINT, LINT, ULINT, DATE
DT DT DT
LDT LDT BYTE, WORD, DWORD, LWORD, SINT, USINT,
INT, UINT, DINT, UDINT, LINT, ULINT, LDT
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1555
Source (IN) Destination (OUT1)
With IEC check Without IEC check
TOD TOD BYTE, WORD, DWORD, LWORD, SINT, USINT,
INT, UINT, DINT, UDINT, LINT, ULINT, TOD
LTOD LTOD BYTE, WORD, DWORD, LWORD, SINT, USINT,
INT, UINT, DINT, UDINT, LINT, ULINT, LTOD
DTL DTL DTL
CHAR CHAR BYTE, WORD, DWORD, LWORD, CHAR, Character
of a string
1)
Character of a
string
1)
Character of a string Character of a string CHAR
ARRAY
2)
ARRAY ARRAY
STRUCT STRUCT STRUCT
COUNTER COUNTER, WORD, INT WORD, DWORD, INT, UINT, DINT, UDINT
TIMER TIMER, WORD, INT WORD, DWORD, INT, UINT, DINT, UDINT
PLC data type
(UDT)
PLC data type (UDT) PLC data type (UDT)
IEC_TIMER IEC_TIMER IEC_TIMER
IEC_LTIMER IEC_LTIMER IEC_LTIMER
IEC_SCOUNTE
R
IEC_SCOUNTER IEC_SCOUNTER
IEC_USCOUNT
ER
IEC_USCOUNTER IEC_USCOUNTER
IEC_COUNTER IEC_COUNTER IEC_COUNTER
IEC_UCOUNTE
R
IEC_UCOUNTER IEC_UCOUNTER
IEC_DCOUNTE
R
IEC_DCOUNTER IEC_DCOUNTER
IEC_UDCOUN
TER
IEC_UDCOUNTER IEC_UDCOUNTER
IEC_LCOUNTE
R
IEC_LCOUNTER IEC_LCOUNTER
IEC_ULCOUNT
ER
IEC_ULCOUNTER IEC_ULCOUNTER
1)
You can also use the "Move value" instruction to transfer individual characters of a string
(STRING) to operands of CHAR data type. The number of the character to be transferred is
given in brackets next to the operand name. "MyString[2]", for example, transfers the second
character of the "MyString" string. It is also possible to transfer from operands of the data type
CHAR to the individual characters of a string. You can also replace a specific character of a
string with the character of another string.
2)
Transferring entire arrays (ARRAY) is possible only when the array components of the
operands at input IN and at output OUT1 are of the same data type.
If the bit length of the data type at IN input exceeds the bit length of the data type at OUT1
output, the higher order bits of the source value are lost. If the bit length of the data type at
the IN input is less than the bit length of the data type at the OUT1 output, then the more
significant bits of the destination value will be overwritten with zeros.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1556 System Manual, 01/2013,
In its initial state, the instruction box contains 1 output (OUT1). The number of outputs can be
extended. The added outputs are numbered in ascending order on the box. When the
instruction is executed, the content of the operand at the IN input is sent to all available outputs.
The instruction box cannot be extended if structured data types (DTL, STRUCT, ARRAY) or
characters of a string (STRING) are transferred.
The "Move block" (MOVE_BLK) and "Move block uninterruptible" (UMOVE_BLK) instructions
can also be used to copy operands of the ARRAY data type. You can move operands of the
STRING data type with the instruction "Move character string" (S_MOVE).
Parameters
The following table shows the parameters of the "Move value" instruction:
Parameter Declaration Data type Memory area Description
S7-1200 S7-1500
EN Input BOOL BOOL I, Q, M, D, L Enable input
ENO Output BOOL BOOL I, Q, M, D, L Enable output
IN Input Bit strings,
integers,
floating-point
numbers,
DATE, TIME,
TOD, DTL,
CHAR,
STRUCT,
ARRAY, IEC
data types,
PLC data type
(UDT)
Bit strings,
integers,
floating-point
numbers,
DATE, DT,
LDT, S5TIME,
TIME, LTIME,
TOD, LTOD,
DTL, CHAR,
STRUCT,
ARRAY,
TIMER,
COUNTER,
IEC data
types, PLC
data type
(UDT)
I, Q, M, D, L or
constant
Source value
OUT1 Output Bit strings,
integers,
floating-point
numbers,
DATE, TIME,
TOD, DTL,
CHAR,
STRUCT,
ARRAY, IEC
data types,
PLC data type
(UDT)
Bit strings,
integers,
floating-point
numbers,
DATE, DT,
LDT, S5TIME,
TIME, LTIME,
TOD, LTOD,
DTL, CHAR,
STRUCT,
ARRAY,
TIMER,
COUNTER,
IEC data
types, PLC
data type
(UDT)
I, Q, M, D, L Operands to
which in the
source value is
transferred.
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1557
Example
The following example shows how the instruction works:
EN
MOVE
ENO
lN OUT1
"TagOut" "Tagln"
"Tagln_Value" "TagOut_Value"
The following table shows how the instruction works using specific operand values:
Parameter Operand Value
IN TagIn_Value 0011 1111 1010 1111
OUT1 TagOut_Value 0011 1111 1010 1111
If operand "TagIn" has the signal state "1", the "Move value" instruction is executed. The
instruction copies the contents of operand "TagIn_Value" to operand "TagOut_Value" and sets
output "TagOut" to signal state "1".
See also
Overview of the valid data types (Page 899)
Removing inputs and outputs (Page 1105)
Basics of the EN/ENO mechanism (Page 987)
MOVE_BLK: Move block (Page 1562)
UMOVE_BLK: Move block uninterruptible (Page 1564)
S_MOVE: Move character string (Page 2088)
Inserting additional inputs and outputs in LAD elements (Page 1104)
FieldRead: Read field
Description
You can use the "Read field" instruction to read out a specific component from the field
specified at input MEMBER and transfer its content to the tag at output VALUE. You specify
the index of the field component to be read at input INDEX. Specify the first component of the
field from which reading is to occur at input MEMBER.
The data types of the field component at input MEMBER and the tags at output VALUE must
correspond to the data type of the instruction "Read field".
The ENO enable output has the signal state "0" if one of the following conditions is fulfilled:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1558 System Manual, 01/2013,
The EN enable input has the signal state "0".
The field component specified at input INDEX is not defined in the field specified at output
MEMBER.
Errors such as an overflow occur during execution.
Parameters
The following table shows the parameters of the "Read field" instruction:
Parameter Declaration Data type Memory area Description
S7-1200 S7-1500
EN Input BOOL BOOL I, Q, M, D, L Enable input
ENO Output BOOL BOOL I, Q, M, D, L Enable output
INDEX Input DINT DINT I, Q, M, D, L, P
or constant
Index of field
component
whose content
is read out
MEMBER Input Binary
numbers,
integers,
floating-point
numbers,
TIME, DATE,
TOD and
CHAR as
components of
an ARRAY tag
Binary
numbers,
integers,
floating-point
numbers,
timers, DATE,
TOD, LTOD
and CHAR as
components of
an ARRAY tag
D, L First
component of
the field from
which reading
occurs.
VALUE Output Bit strings,
integers,
floating-point
numbers,
TIME, DATE,
TOD and
CHAR
Bit strings,
integers,
floating-point
numbers,
timers, DATE,
TOD, LTOD
and CHAR
I, Q, M, D, L, P Operand to
which the
content of the
field
component is
transferred
You can select the data type for the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1559
Example
The following example shows how the instruction works:
#a_index
Q 4.0
"DB_1".
Main_Field[-10]
#a_real
EN
FieldRead
ENO
lNDEX VALUE
REAL
MEMBER
The following table shows how the instruction works using specific operand values:
Parameters Tag Value
INDEX a_index 4
MEMBER "DB_1".Main_Field[-10] First component of the "Main_Field[-10..10] of
REAL" field in the "DB_1" data block
VALUE a_real Component with index 4 of the
"Main_Field[-10..10] of REAL" field
The field component with index 4 is read from the "Main_Field[-10...10] of REAL" field and
written to the "a_real" tag. The field component to be read is specified by the value at input
INDEX.
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
FieldWrite: Write field
Description
The "Write field" instruction is used to transfer the content of the tag at the VALUE input to a
specific component of the field at the MEMBER output. You use the value at the INDEX input
to specify the index of the field component that is described. At the MEMBER output, enter the
first component of the field which is to be written to.
The data types of the field component specified at the MEMBER output and the tags at the
VALUE input have to match the data type of the "Write field" instruction.
The ENO enable output has the signal state "0" if one of the following conditions is fulfilled:
The EN enable input has the signal state "0".
The field component specified at the input INDEX is not defined in the field specified at the
output MEMBER.
Errors such as an overflow occur during execution.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1560 System Manual, 01/2013,
Parameters
The following table shows the parameters of the "Write field" instruction:
Parameter Declaration Data type Memory area Description
S7-1200 S7-1500
EN Input BOOL BOOL I, Q, M, D, L Enable input
ENO Output BOOL BOOL I, Q, M, D, L Enable output
INDEX Input DINT DINT I, Q, M, D, L, P
or constant
Index of the
field
component
that is being
written with the
content of
VALUE.
VALUE Input Bit strings,
integers,
floating-point
numbers,
TIME, DATE,
TOD and
CHAR
Bit strings,
integers,
floating-point
numbers,
timers, DATE,
TOD, LTOD
and CHAR
I, Q, M, D, L, P
or constant
Operand
whose content
is copied.
MEMBER Output Binary
numbers,
integers,
floating-point
numbers,
TIME, DATE,
TOD and
CHAR as
components of
an ARRAY tag
Binary
numbers,
integers,
floating-point
numbers,
timers, DATE,
TOD, LTOD
and CHAR as
components of
an ARRAY tag
D, L First
component of
the field to
which the
content of
VALUE is
written.
You can select the data type for the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
#a_index
Q 4.0
#a_real
"DB_1".
Main_Field[-10]
EN
FieldWrite
ENO
lNDEX
VALUE
REAL
MEMBER
The following table shows how the instruction works using specific operand values:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1561
Parameters Operand Value
INDEX a_index 4
VALUE a_real 10.54
MEMBER "DB_1".Main_Field[-10] First component of the "Main_Field[-10..10] of
REAL" field in the "DB_1" data block
The value "10.54" of the "a_real" tag is written to the field component with index 4 of the
"Main_Field[-10..10] of REAL" field. The index of the field component to which the content of
the tag "a_real" is transferred is specified by the value at the input INDEX.
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
MOVE_BLK: Move block
Description
You can use the "Move block" instruction to move the content of a memory area (source area)
to another memory area (destination area). The number of elements to be moved to the
destination area is specified at input COUNT. The width of the elements to be moved is defined
by the width of the element at the IN input.
The ENO enable output has the signal state "0" if one of the following conditions is fulfilled:
The EN enable input has the signal state "0".
More data is copied than is made available at the IN input or OUT output.
If the last BOOL element of an ARRAY structure is not at a byte limit (for example, bit 16 of 2
bytes) and an overflow occurs, the ENO enable output remains at "1" until the byte limit of the
ARRAY structure is exceeded. If the byte limit of the ARRAY structure is exceeded by the
value at the COUNT input, the ENO enable output is reset to "0".
Parameters
The following table lists the parameters of the "Move block" instruction:
Parameter Declaration Data type Memory area Description
S7-1200 S7-1500
EN Input BOOL BOOL I, Q, M, D, L Enable input
ENO Output BOOL BOOL I, Q, M, D, L Enable output
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1562 System Manual, 01/2013,
Parameter Declaration Data type Memory area Description
S7-1200 S7-1500
IN Input Binary
numbers,
integers,
floating-point
numbers,
TIME, DATE,
CHAR, TOD,
DATE and
CHAR as
components of
an ARRAY
structure
Binary
numbers,
integers,
floating-point
numbers,
S5TIME,
TIME, LTIME,
DATE, CHAR,
TOD, LTOD,
DATE and
CHAR as a
component of
an ARRAY
structure
D, L The first
element of the
source area
that is being
copied.
COUNT Input USINT, UINT,
UDINT
USINT, UINT,
UDINT, ULINT
I, Q, M, D, L, P
or constant
Number of
elements to be
copied from
the source
area to the
destination
area.
OUT Output Binary
numbers,
integers,
floating-point
numbers,
TIME, DATE,
CHAR, TOD,
DATE and
CHAR as
components of
an ARRAY
structure
Binary
numbers,
integers,
floating-point
numbers,
S5TIME,
TIME, LTIME,
DATE, CHAR,
TOD, LTOD,
DATE and
CHAR as a
component of
an ARRAY
structure
D, L The first
element of the
destination
area to which
the contents of
the source
area are being
moved.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
MOVE_BLK
OUT
EN ENO
COUNT
lN
"TagOut" "Tagln_1" "Tagln_2"
#b_array[1] #a_array[2]
"Tag_Count"
The following table shows how the instruction works using specific operand values:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1563
Parameter Operand Value
IN a_array[2] Operand "a_array" is of the
ARRAY data type and consists
of 5 elements of the INT data
type.
COUNT Tag_Count 3
OUT b_array[1] Operand "b_array" is of the
ARRAY data type and consists
of 6 elements of the INT data
type.
If operands "TagIn_1" and "TagIn_2" have the signal state "1", the "Move block" instruction is
executed. The instruction selects three INT elements from the "a_array" (a_array[2..4]) tag and
moves their contents into the "b_array" (b_array[1..3]) output tag. If the instruction is executed
without errors, the ENO enable output has the signal state "1" and the "TagOut" output is set.
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
Inserting additional inputs and outputs in LAD elements (Page 1104)
UMOVE_BLK: Move block uninterruptible
Description
You can use the "Move block uninterruptible" instruction to move the content of a memory area
(source area) to another memory area (destination area). The number of elements to be moved
to the destination area is specified with the COUNT parameter. The width of the elements to
be moved is defined by the width of the element at the IN input.
Note
The copy operation cannot be interrupted by other operating system activities. This is why
the interrupt reaction times of the CPU increase during the execution of the "Move block
uninterruptible" instruction.
The ENO enable output has the signal state "0" if one of the following conditions is fulfilled:
The EN enable input has the signal state "0".
More data is copied than is made available at the IN input or OUT output.
If the last BOOL element of an ARRAY structure is not at a byte limit (for example, bit 16 of 2
bytes) and an overflow occurs, the ENO enable output remains at "1" until the byte limit of the
ARRAY structure is exceeded. If the byte limit of the ARRAY structure is exceeded by the
value at the COUNT input, the ENO enable output is reset to "0".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1564 System Manual, 01/2013,
Parameters
The following table shows the parameters of the "Move block uninterruptible" instruction:
Parameter Declaration Data type Memory area Description
S7-1200 S7-1500
EN Input BOOL BOOL I, Q, M, D, L Enable input
ENO Output BOOL BOOL I, Q, M, D, L Enable output
IN Input Binary
numbers,
integers,
floating-point
numbers,
TIME, DATE,
CHAR, TOD,
DATE and
CHAR as
components of
an ARRAY
structure
Binary
numbers,
integers,
floating-point
numbers,
S5TIME,
TIME, LTIME,
DATE, CHAR,
TOD, LTOD,
DATE and
CHAR as a
component of
an ARRAY
structure
D, L The first
element of the
source area
that is being
copied.
COUNT Input USINT, UINT,
UDINT
USINT, UINT,
UDINT, ULINT
I, Q, M, D, L, P
or constant
Number of
elements to be
copied from
the source
area to the
destination
area.
OUT Output Binary
numbers,
integers,
floating-point
numbers,
TIME, DATE,
CHAR, TOD,
DATE and
CHAR as
components of
an ARRAY
structure
Binary
numbers,
integers,
floating-point
numbers,
S5TIME,
TIME, LTIME,
DATE, CHAR,
TOD, LTOD,
DATE and
CHAR as a
component of
an ARRAY
structure
D, L The first
element of the
destination
area to which
the contents of
the source
area are being
moved.
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1565
Example
The following example shows how the instruction works:
UMOVE_BLK
OUT
EN ENO
COUNT
lN
"TagOut" "Tagln_1" "Tagln_2"
#b_array[1] #a_array[2]
"Tag_Count"
The following table shows how the instruction works using specific operand values:
Parameter Operand Value
IN a_array[2] Operand "a_array" is of the
ARRAY data type and consists
of 5 elements of the INT data
type.
COUNT Tag_Count 3
OUT b_array[1] Tag "b_array" is of the ARRAY
data type and consists of 6
elements of the INT data type.
If operands "TagIn_1" and "TagIn_2" have the signal state "1", the "Move block uninterruptible"
instruction is executed. The instruction selects three INT elements from the "a_array"
(a_array[2..4]) tag and moves their contents into the "b_array" (b_array[1..3]) output tag. The
copy operation cannot be interrupted by other operating system activities. If the instruction is
executed without errors, the ENO output has the signal state "1" and the "TagOut" output is
set.
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
Inserting additional inputs and outputs in LAD elements (Page 1104)
FILL_BLK: Fill block
Description
You can use the "Fill block" instruction to fill a memory area (destination area) with the value
of the IN input. The destination area is filled starting from the address specified at the OUT
output. The number of repeated copy operations is specified with the COUNT parameter. When
the instruction is executed, the value at the IN input is selected and copied to the destination
area as often as specified by the value in the COUNT parameter.
The ENO enable output has the signal state "0" if one of the following conditions is fulfilled:
The EN enable input has the signal state "0".
More data is copied than is made available at the IN input or OUT output.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1566 System Manual, 01/2013,
If the last BOOL element of an ARRAY structure is not at a byte limit (for example, bit 16 of 2
bytes) and an overflow occurs, the ENO enable output remains at "1" until the byte limit of the
ARRAY structure is exceeded. If the byte limit of the ARRAY structure is exceeded by the
value at the COUNT input, the ENO enable output is reset to "0".
Parameter
The following table shows the parameters of the "Fill block" instruction:
Parameter Declaration Data type Memory area
Description
S7-1200 S7-1500
EN Input BOOL BOOL I, Q, M, D, L Enable input
ENO Output BOOL BOOL I, Q, M, D, L Enable output
IN Input Binary
numbers,
integers,
floating-point
numbers,
TIME, DATE,
TOD, CHAR,
DATE and
CHAR as
components of
an ARRAY
structure
Binary
numbers,
integers,
floating-point
numbers,
S5TIME,
TIME, LTIME,
DATE, CHAR,
TOD, LTOD,
DATE and
CHAR as a
component of
an ARRAY
structure
I, Q, M, D, L, P
or constant
Element used
to fill the
destination
area.
COUNT Input USINT, UINT,
UDINT
USINT, UINT,
UDINT, ULINT
I, Q, M, D, L, P
or constant
Number of
repeated copy
operations
OUT Output Binary
numbers,
integers,
floating-point
numbers,
TIME, DATE,
TOD, CHAR,
DATE and
CHAR as
components of
an ARRAY
structure
Binary
numbers,
integers,
floating-point
numbers,
S5TIME,
TIME, LTIME,
DATE, CHAR,
TOD, LTOD,
DATE and
CHAR as a
component of
an ARRAY
structure
D, L Address in
destination
area from
which filling
starts.
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1567
Example
The following example shows how the instruction works:
#b_array[1] #a_array[2]
"Tag_Count"
FlLL_BLK
OUT
EN ENO
COUNT
lN
"TagOut" "Tagln_1" "Tagln_2"
The following table shows how the instruction works using specific operand values:
Parameter Operand Value
IN A_array[2] Operand "a_array" is of the
ARRAY data type and consists
of 4 elements of the WORD
(ARRAY[1..4] of WORD) data
type.
COUNT Tag_Count 3
OUT b_array[1] Operand "b_array" is of the
ARRAY data type and consists
of 5 elements of the WORD
(ARRAY[1..5] of WORD) data
type.
If operands "TagIn_1" and "TagIn_2" have the signal state "1", the "Fill block" instruction is
executed. The instruction copies the second element (a_array[2]) of the "a_array" tag three
times to the "b_array" output tag (b_array[1..3]). If the instruction is executed without errors,
the ENO and "TagOut" enable outputs are set to signal state "1".
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
Inserting additional inputs and outputs in LAD elements (Page 1104)
UFILL_BLK: Fill block uninterruptible
Description
You can use the "Fill block uninterruptible" instruction to fill a memory area (destination area)
with the value of the IN input without interruption. The destination area is filled starting from
the address specified at the OUT output. The number of repeated copy operations is specified
with the COUNT parameter. When the instruction is executed, the value at the IN input is
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1568 System Manual, 01/2013,
selected and copied to the destination area as often as specified by the value in the COUNT
parameter.
Note
The copy operation cannot be interrupted by other operating system activities. This is why
the alarm reaction times of the CPU increase during the execution of the "Fill block
uninterruptible" instruction.
The ENO enable output has the signal state "0" if one of the following conditions is fulfilled:
The EN enable input has the signal state "0".
More data is copied than is made available at the IN input or OUT output.
If the last BOOL element of an ARRAY structure is not at a byte limit (for example, bit 16 of 2
bytes) and an overflow occurs, the ENO enable output remains at "1" until the byte limit of the
ARRAY structure is exceeded. If the byte limit of the ARRAY structure is exceeded by the
value at the COUNT input, the ENO enable output is reset to "0".
Parameter
The following table shows the parameters of the "Fill block uninterruptible" instruction:
Parameter Declaration Data type Memory area
Description
S7-1200 S7-1500
EN Input BOOL BOOL I, Q, M, D, L Enable input
ENO Output BOOL BOOL I, Q, M, D, L Enable output
IN Input Binary
numbers,
integers,
floating-point
numbers,
TIME, DATE,
CHAR, TOD,
DATE and
CHAR as
components of
an ARRAY
structure
Binary
numbers,
integers,
floating-point
numbers,
S5TIME,
TIME, LTIME,
DATE, CHAR,
TOD, LTOD,
DATE and
CHAR as a
component of
an ARRAY
structure
I, Q, M, D, L, P
or constant
Element used
to fill the
destination
area.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1569
Parameter Declaration Data type Memory area
Description
S7-1200 S7-1500
COUNT Input USINT, UINT,
UDINT
USINT, UINT,
UDINT, ULINT
I, Q, M, D, L, P
or constant
Number of
repeated copy
operations
OUT Output Binary
numbers,
integers,
floating-point
numbers,
TIME, DATE,
CHAR, TOD,
DATE and
CHAR as
components of
an ARRAY
structure
Binary
numbers,
integers,
floating-point
numbers,
S5TIME,
TIME, LTIME,
DATE, CHAR,
TOD, LTOD,
DATE and
CHAR as a
component of
an ARRAY
structure
D, L Address in
destination
area from
which filling
starts.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
#b_array[1] #a_array[2]
"Tag_Count"
UFlLL_BLK
OUT
EN ENO
COUNT
lN
"TagOut" "Tagln_1" "Tagln_2"
The following table shows how the instruction works using specific operand values:
Parameter Operand Value
IN a_array[2] Operand "a_array" is of the
ARRAY data type and consists
of 4 elements of the WORD
(ARRAY[1..4] of WORD) data
type.
COUNT Tag_Count 3
OUT b_array[1] Operand "b_array" is of the
ARRAY data type and consists
of 5 elements of the WORD
(ARRAY[1..5] of WORD) data
type.
If operands "TagIn_1" and "TagIn_2" have the signal state "1", the "Fill block uninterruptible"
instruction is executed. The instruction copies the second element (a_array[2]) of the "a_array"
tag three times to the "b_array" output tag (b_array[1..3]). The copy operation cannot be
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1570 System Manual, 01/2013,
interrupted by other operating system activities. If the instruction is executed without errors,
the ENO and "TagOut" enable outputs are set to signal state "1".
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
Inserting additional inputs and outputs in LAD elements (Page 1104)
SWAP: Swap
Description
You can use the "Swap" instruction to change the order of the bytes at input IN and query the
result at output OUT.
The following figure shows how the bytes of an operand of the DWORD data type are swapped
using the "Swap" instruction:
15... ...8 7... ...0
0 1 1 0 1 0 1 0 0 1 0 1 1 1 0 0 0 0 0 1 1 1 1 0 1 1 0 0 0 1 0 1
16 23... ...24 31...
15... ...8 7... ...0
1 1 0 0 0 1 0 1 0 0 0 1 1 1 1 0 0 1 0 1 1 1 0 0 0 1 1 0 1 0 1 0
16 23... ...24 31...
OUT
lN
1 2 3 4
1
2
3 4
Parameter
The following table shows the parameters of the "Swap" instruction:
Parameter Declaration Data type Memory area Description
S7-1200 S7-1500
EN Input BOOL BOOL I, Q, M, D, L Enable input
ENO Output BOOL BOOL I, Q, M, D, L Enable output
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1571
Parameter Declaration Data type Memory area Description
S7-1200 S7-1500
IN Input WORD,
DWORD
WORD,
DWORD,
LWORD
I, Q, M, D, L or,
P constant
Operand
whose bytes
are swapped.
OUT Output WORD,
DWORD
WORD,
DWORD,
LWORD
I, Q, M, D, L, P Result
You can select the data type for the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
SWAP
OUT lN
EN ENO
WORD
S
"Tagln"
"Tagln_Value" "TagOut_Value"
"TagOut"
The following table shows how the instruction works using specific operand values:
Parameter Operand Value
IN TagIn_Value 0000 1111 0101 0101
OUT TagOut_Value 0101 0101 0000 1111
If operand "TagIn" has the signal state "1", the "Swap" instruction is executed. The order of
the bytes is changed and stored in operand "TagOut_Value".
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
Inserting additional inputs and outputs in LAD elements (Page 1104)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1572 System Manual, 01/2013,
BLKMOV: Move block
Description
You can use the "Move block" instruction to move the content of a memory area (source area)
to another memory area (destination area). The move operation takes place in the direction
of ascending addresses. You use VARIANT to define the source and destination area.
Note
The tags of the instruction can only be used in data blocks with the block property "Standard
access" or, if the tag was declared with the retentive setting "Set in IDB", also "with optimized
access".
The following figure shows the principle of the move operation:
The move takes place in
the direction of ascending
addresses
Memory area
Move
A DB10.DBW4
DB10.DBW6
DB10.DBW8
DB10.DBW10
MW10
MW12
MW14
MW16
B
C D
E F
G H
A B
C D
E F
G H
Consistency of the source data and the target data
Make sure that the source data remain unchanged during execution of the instruction Move
block instruction. Otherwise the consistency of the target data cannot be ensured.
Interrupt ability
As long as the source area is not part of a data block that only exists in the load memory, there
is no limit to the nesting depth.
If, however, BLKMOV is interrupted while copying from a DB that is not relevant to program
execution, the execution of BLKMOV can no longer be nested.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1573
Memory areas
You can use the "Move block" instruction to move the following memory areas:
Areas of a data block
Bit memory
Process image input table
Process image output table
Data blocks not relevant for program execution
General rules for moving
The source and destination area must not overlap. If the source and destination area have
different lengths, only the length of the smaller area will be moved.
If the source area is less than the destination area, the entire source area will be written to the
destination area. The remaining bytes of the destination area remain unchanged.
If the destination area is less than the source area, the entire destination area will be written.
The remaining bytes of the source area are ignored.
If a block of data type BOOL is moved, the specified length of the area must be dividable by
8, otherwise it will not be possible to execute the instruction.
Rules for moving character strings
You can use the "Move block" instruction to also move source and destination areas of the
STRING data type. If only the source area is STRING data type, the characters will be moved
that are actually contained in the character string. Information on the actual and maximum
length is also written to the destination area. If the source and destination area are each
STRING data type, the current length of the character string in the destination area is set to
the number of actually moved characters.
If you want to move the information on the maximum and actual length of a character string,
specify the areas in bytes to the SRCBLK and DSTBLK parameters.
Rules for moving data blocks that are not relevant to the program execution
The source area is in a data block in load memory that is not relevant for program execution.
Data blocks that are not relevant for program execution are marked with the keyword
UNLINKED.
If an not runtime-relevant data block is copied to the work memory with the "Move block"
instruction and loaded at the same time, for example, by the programming device, the
execution of the instruction can be delayed for several milliseconds. This results in a longer
OB cycle and may trip the cycle monitoring.
If an unlinked data block is moved with the "Move block" instruction and the move operation
is interrupted, the execution of the instruction can no longer be continued.
If the Read from data block in the load memory instruction is available on your CPU, you must
use this instruction to read data blocks that are not runtime-relevant from load memory. If you
use the Move block instruction, error W#16#8092 is output.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1574 System Manual, 01/2013,
Parameter
The following table lists the parameters of the "Move block" instruction:
Parameter Declaration Data type Memory area Description
EN Input BOOL I, Q, M, D, L Enable input
ENO Output BOOL I, Q, M, D, L Enable output
SRCBLK Input ANY I, Q, M, D, L, P Specifies the memory area to be
moved (source area).
RET_VAL Output INT I, Q, M, D, L, P Error information:
If an error occurs during
execution of the instruction, an
error code is output on the
RET_VAL parameter.
DSTBLK Output ANY I, Q, M, D, L, P Specifies the memory area to
which the block is to be moved
(destination area).
Parameter RET_VAL
The following table shows the meaning of the values of the RET_VAL parameter:
Error code*
(W#16#...)
Explanation
0000 No error
8091 The permitted nesting depth was exceeded
8092 The instruction cannot be executed because a specified data block is write protection, non-executable or
unloaded.
8xyy For more information on errors, refer to "See also".
*The error codes can be displayed as integer or hexadecimal value in the program editor. For additional information on
toggling display formats, refer to "See also".
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
Inserting additional inputs and outputs in LAD elements (Page 1104)
UBLKMOV: Move block uninterruptible
Description
You can use the "Move block uninterruptible" instruction to move the content of a memory area
(source area) to another memory area (destination area). The move operation takes place in
the direction of ascending addresses. You use ANY pointer to define the source and destination
area.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1575
The copy operation cannot be interrupted by other operating system activities. As a result the
alarm reaction time of the CPU can increase during the execution of the "Move block
uninterruptible" instruction.
Note
The tags of the instruction can only be used in data blocks with the block property "Standard
access" or, if the tag was declared with the retentive setting "Set in IDB", also "with optimized
access".
Memory areas
You can use the "Move block uninterruptible" instruction to move the following memory areas:
Areas of a data block
Bit memory
Process image input table
Process image output table
General rules for moving
The source and destination area must not overlap during the execution of the "Move block
uninterruptible" instruction. If the source area is less than the destination area, the entire source
area will be written to the destination area. The remaining bytes of the destination area remain
unchanged.
If the destination area is less than the source area, the entire destination area will be written.
The remaining bytes of the source area are ignored.
If a source or destination area defined as a formal parameter is less than a destination or
source area specified on the SRCBLK or DSTBLK parameter, no data will be transferred.
If a block of data type BOOL is moved, the specified length of the area must be dividable by
8, otherwise it will not be possible to execute the instruction.
You can use the "Move block uninterruptible" instruction to move a maximum of 512 bytes.
Note the CPU specific restrictions for this.
Rules for moving character strings
You can use the "Move block uninterruptible" instruction to also move source and destination
areas of the STRING data type. If only the source area is STRING data type, the characters
will be moved that are actually contained in the character string. Information on the actual and
maximum length are not written in the destination area. If the source and destination area are
each STRING data type, the current length of the character string in the destination area is
set to the number of actually moved characters. If areas of the data type STRING are moved,
you have to specify "1" as area length.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1576 System Manual, 01/2013,
Parameters
The following table shows the parameters of the "Move block uninterruptible" instruction:
Paramet
er
Declaratio
n
Data type Memory area Description
EN Input BOOL I, Q, M, D, L Enable input
ENO Output BOOL I, Q, M, D, L Enable output
SRCBLK Input ANY I, Q, M, D, L, P Specifies the memory area to
be moved (source area).
RET_VA
L
Output INT I, Q, M, D, L, P Error information:
If an error occurs during
execution of the instruction, an
error code is output on the
RET_VAL parameter.
DSTBLK Output ANY I, Q, M, D, L, P Specifies the memory area to
which the block is to be moved
(destination area).
Parameter RET_VAL
The following table shows the meaning of the values of the RET_VAL parameter:
Error code*
(W#16#...)
Explanation
0000 No error
8091 The source area is in a data block that is not relevant for program execution.
8xyy For more information on errors, refer to "See also".
*The error codes can be displayed as integer or hexadecimal value in the program editor. For additional information on
toggling display formats, refer to "See also".
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
Inserting additional inputs and outputs in LAD elements (Page 1104)
FILL: Fill block
Description
You can use the "Fill block" instruction to fill a memory area (destination area) with the content
of another memory area (source area). The "Fill block" instruction moves the content of the
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1577
source area to the destination area until the destination area is completely written. The move
operation takes place in the direction of ascending addresses.
Note
The tags of the instruction can only be used in data blocks with the block property "Standard
access" or, if the tag was declared with the retentive setting "Set in IDB", also "with optimized
access".
The following figure shows the principle of the move operation:
BVAL
BLK
FlLL
MW14
MW16
MW18
MW20
MW100
MW102
MW104
MW106
A B
C D
E F
G H
A B
C D
E F
G H
A B
C D
MW108
MW110
MW112
MW114
MW116
MW118
A B
C D
E F
G H
Example: The contents of the range MW100 to MW118 are to be preassigned with the contents
of the memory words MW14 to MW20.
Consistency of the source data and the target data
Please note that during execution of the instruction "Fill block" that the source data remain
unchanged, otherwise the consistency of the target data is not ensured.
Memory areas
You can use the "Fill block" instruction to move the following memory areas:
Areas of a data block
Bit memory
Process image input table
Process image output table
Data blocks not relevant for program execution
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1578 System Manual, 01/2013,
General rules for moving
The source and destination area must not overlap. If the destination block to be preset is not
an integer multiple of the length of the input parameter BVAL, the destination block is
nevertheless written up to the last byte.
If the destination area to be preset is smaller than the source area, the function only copies as
much data as can be written to the destination area.
If the destination or source block actually present is smaller than the assigned memory area
for the source or destination block (BVAL BLK parameters), no data will be transferred.
If the ANY pointer (source or destination) is of the data type BOOL, the length specified must
be divisible by 8; otherwise the instruction will not be executed.
If the destination block is of data type STRING, the instruction describes the entire string
including the administration information.
Parameters
The following table shows the parameters of the "Fill block" instruction:
Paramet
ers
Declarati
on
Data
type
Memory area Description
EN Input BOOL I, Q, M, D, L Enable input
ENO Output BOOL I, Q, M, D, L Enable output
BVAL Input ANY I, Q, M, D, P Specification of the memory area
(source area) with whose content
the destination area on the BLK
parameter will be filled.
RET_VA
L
Output INT I, Q, M, D, L, P Error information:
If an error occurs during
execution of the instruction, an
error code is output on the
RET_VAL parameter.
BLK Output ANY I, Q, M, D, P Specification of the memory area
that will be filled with the content
of the source area.
Parameter RET_VAL
The following table shows the meaning of the values of the RET_VAL parameter:
Error code*
(W#16#...)
Explanation
0000 No error
8xyy For more information on errors, refer to "See also".
*The error codes can be displayed as integer or hexadecimal value in the program editor. For additional information on
toggling display formats, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1579
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
Inserting additional inputs and outputs in LAD elements (Page 1104)
Conversion operations
CONVERT: Convert value
Description
The "Convert value" instruction reads the content of the IN parameter and converts it according
to the data types selected in the instruction box. The converted value is sent to the output OUT.
For information on possible conversions, refer to the "Explicit conversion" section at "See also".
The ENO enable output has the signal state "0" if one of the following conditions is fulfilled:
The EN enable input has the signal state "0".
Errors such as an overflow occur during execution.
An operand of data type BYTE, WORD, DWORD or LWORD is specified at the IN input.
This operand's most significant bit is set. A signed integer (SINT, INT, DINT, LINT) is
specified at the OUT output. It has the same bit length as the operand at the IN input.
Parameters
The following table shows the parameters of the "Convert value" instruction:
Parameter Declaration Data type Memory area Description
EN Input BOOL I, Q, M, D, L Enable input
ENO Output BOOL I, Q, M, D, L Enable output
IN Input Bit strings,
integers, floating-
point numbers,
CHAR, BCD16,
BCD32
I, Q, M, D, L, P or
constant
Value to be
converted.
OUT Output Bit strings,
integers, floating-
point numbers,
CHAR, BCD16,
BCD32
I, Q, M, D, L, P Result of the
conversion
You can select the data type for the instruction from the "<???>" drop-down list of the instruction
box.
Bit strings (BYTE, WORD, DWORD, LWORD) cannot be selected in the instruction box. If you
have specified an operand of data type BYTE, WORD, DWORD or LWORD at a parameter of
the instruction, the value of the operand is interpreted as an unsigned integer with the same
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1580 System Manual, 01/2013,
bit length. In this case the data type BYTE is interpreted as USINT, WORD as UINT, DWORD
as UDINT, and LWORD as LINT.
Note
For S7-1500 CPU: The data types DWORD and LWORD can be selected, if REAL or LREAL
is selected as IN data type.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
EN
CONV
ENO
lN OUT
lNT DlNT
to
"TagOut" "Tagln"
"Tagln_Value" "TagOut_Value"
If operand "TagIn" has the signal state "1", the content of operand "TagIn_Value" is read and
converted to an integer (32-bit). The result is stored in operand "TagOut_Value". The output
"TagOut" is set to "1" if the instruction was executed without errors.
See also
Overview of the valid data types (Page 899)
Explicit conversion of CHAR (Page 985)
ROUND: Round numerical value
Description
You can use the "Round numerical value" instruction to round the value at input IN to the
nearest integer. The instruction interprets the value at input IN as a floating-point number and
converts this to an integer of data type DINT. If the input value is exactly between an even and
odd number, the even number is selected. The result of the instruction is sent to the OUT
output and can be queried there.
The ENO enable output has the signal state "0" if one of the following conditions is fulfilled:
The enable input EN has the signal state "0".
Errors such as an overflow occur during execution.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1581
Parameters
The following table shows the parameters of the "Round numerical value" instruction:
Parameters Declaration Data type Memory area Description
EN Input BOOL I, Q, M, D, L Enable input
ENO Output BOOL I, Q, M, D, L Enable output
IN Input Floating-point
numbers
I, Q, M, D, L, P or
constant
Input value to be
rounded.
OUT Output Integers, floating-
point numbers
I, Q, M, D, L, P Result of rounding
You can select the data type for the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
EN
ROUND
ENO
lN OUT
to
REAL DlNT
"TagOut" "Tagln"
"Tagln_Value" "TagOut_Value"
The following table shows how the instruction works using specific operand values:
Parameter Operand Value
IN TagIn_Value 1.50000000 -1.50000000
OUT TagOut_Value 2 -2
If operand "TagIn" has the signal state "1", the "Round numerical value" instruction is executed.
The floating-point number at input "TagIn_Value" is rounded to the nearest even integer and
sent to output "TagOut_Value". If the instruction is executed without errors, the "TagOut" output
is set.
See also
Overview of the valid data types (Page 899)
CEIL: Generate next higher integer from floating-point number
Description
You can use the "Generate next higher integer from floating-point number" instruction to round
the value at input IN to the next higher integer. The instruction interprets the value at the IN
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1582 System Manual, 01/2013,
input as a floating-point number and converts this number to the next higher integer. The result
of the instruction is sent to the OUT output and can be queried there. The output value can be
greater than or equal to the input value.
The ENO enable output has the signal state "0" if one of the following conditions is fulfilled:
The enable input EN has the signal state "0".
Errors such as an overflow occur during execution.
Parameters
The following table shows the parameters of the "Generate next higher integer from floating-
point number" instruction:
Parameters Declaration Data type Memory area Description
EN Input BOOL I, Q, M, D, L Enable input
ENO Output BOOL I, Q, M, D, L Enable output
IN Input Floating-point
numbers
I, Q, M, D, L, P or
constant
Input value
OUT Output Integers, floating-
point numbers
I, Q, M, D, L, P Result with next
higher integer
You can select the data type for the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
EN
CElL
ENO
lN OUT
to
REAL DlNT
"TagOut" "Tagln"
"Tagln_Value" "TagOut_Value"
The following table shows how the instruction works using specific operand values:
Parameter Operand Value
IN TagIn_Value 0.50000000 -0.50000000
OUT TagOut_Value 1 0
If operand "TagIn" has the signal state "1", the "Generate next higher integer from floating-
point number" instruction is executed. The floating-point number at the "TagIn_Value" input is
rounded to the next higher integer and sent to the "TagOut_Value" output. If the instruction is
executed without errors, the "TagOut" output is set.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1583
See also
Overview of the valid data types (Page 899)
FLOOR: Generate next lower integer from floating-point number
Description
You can use the "Generate next lower integer from floating-point number" instruction to round
the value at input IN to the next lower integer. The instruction interprets the value at input IN
as a floating-point number and converts this to the next lower integer. The result of the
instruction is sent to the OUT output and can be queried there. The output value can be less
than or equal to the input value.
The ENO enable output has the signal state "0" if one of the following conditions is fulfilled:
The enable input EN has the signal state "0".
Errors such as an overflow occur during execution.
Parameters
The following table shows the parameters of the "Generate next lower integer from floating-
point number" instruction:
Parameters Declaration Data type Memory area Description
EN Input BOOL I, Q, M, D, L Enable input
ENO Output BOOL I, Q, M, D, L Enable output
IN Input Floating-point
numbers
I, Q, M, D, L, P or
constant
Input value
OUT Output Integers, floating-
point numbers
I, Q, M, D, L, P Result with next
lower integer
You can select the data type for the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1584 System Manual, 01/2013,
Example
The following example shows how the instruction works:
EN
FLOOR
ENO
lN OUT
to
REAL DlNT
"TagOut" "Tagln"
"Tagln_Value" "TagOut_Value"
The following table shows how the instruction works using specific operand values:
Parameter Operand Value
IN TagIn_Value 0.50000000 -0.50000000
OUT TagOut_Value 0 -1
If operand "TagIn" has the signal state "1", the "Generate next lower integer from floating-point
number" instruction is executed. The floating-point number at input "TagIn_Value" is rounded
to the next lower integer and sent to output "TagOut_Value". If the instruction is executed
without errors, the "TagOut" output is set.
See also
Overview of the valid data types (Page 899)
TRUNC: Truncate numerical value
Description
You can use the "Truncate numerical value" instruction to form an integer from the value at
the IN input. The value at the IN input is interpreted as a floating-point number. The instruction
selects only the integer part of the floating-point number and sends this to the OUT output
without decimal places.
The ENO enable output has the signal state "0" if one of the following conditions is fulfilled:
The EN input has the signal state "0".
Errors such as an overflow occur during execution.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1585
Parameters
The following table shows the parameters of the "Truncate numerical value" instruction:
Parameter Declaration Data type Memory area Description
EN Input BOOL I, Q, M, D, L Enable input
ENO Output BOOL I, Q, M, D, L Enable output
IN Input Floating-point
numbers
I, Q, M, D, L or
constant
Input value
OUT Output Integers, floating-
point numbers
I, Q, M, D, L Integer part of the
input value
You can select the data type for the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
EN
TRUNC
ENO
lN OUT
to
REAL DlNT
"TagOut" "Tagln"
"Tagln_Value" "TagOut_Value"
The following table shows how the instruction works using specific operand values:
Parameter Operand Value
IN TagIn_Value 1.50000000 -1.50000000
OUT TagOut_Value 1 -1
If operand "TagIn" has the signal state "1", the "Truncate numerical value" instruction is
executed. The integer part of the floating-point number at the "TagIn_Value" input is converted
to an integer and sent to the "TagOut_Value" output. If the instruction is executed without
errors, the "TagOut" output is set.
See also
Overview of the valid data types (Page 899)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1586 System Manual, 01/2013,
SCALE_X: Scale
Description
You can use the "Scale" instruction to scale the value at the VALUE input by mapping it to a
specified value range. When the "Scale" instruction is executed, the floating-point value at the
VALUE input is scaled to the value range that was defined by the MIN and MAX parameters.
The result of the scaling is an integer, which is stored in the OUT output.
The following figure shows an example of how values can be scaled:
MlN
MAX
1.0 0.0
OUT
VALUE
The "Scale" instruction works with the following equation:
OUT = [VALUE (MAX MIN)] + MIN
The ENO enable output has the signal state "0" if one of the following conditions is fulfilled:
The EN enable input has the signal state "0".
The value at the MIN input is greater than or equal to the value at the MAX input.
The value of a specified floating-point number is outside the range of the normalized
numbers according to IEEE-754.
An overflow occurs.
The value at the VALUE input is NaN (Not a Number = result of an invalid arithmetic
operation).
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1587
Parameters
The following table shows the parameters of the "Scale" instruction:
Parameter Declaration Data type Memory area Description
EN Input BOOL I, Q, M, D, L Enable input
ENO Output BOOL I, Q, M, D, L Enable output
MIN Input Integers, floating-
point numbers
I, Q, M, D, L or
constant
Low limit of the
value range
VALUE Input Floating-point
numbers
I, Q, M, D, L or
constant
Value to be scaled.
MAX Input Integers, floating-
point numbers
I, Q, M, D, L or
constant
High limit of the
value range
OUT Output Integers, floating-
point numbers
I, Q, M, D, L Result of scaling
You can select the data type for the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
S
SCALE_X
EN ENO
MlN OUT
VALUE
MAX
to REAL DlNT
"TagOut" "Tagln"
"Tag_MlN"
"Tag_Value"
"Tag_Result"
"Tag_MAX"
The following table shows how the instruction works using specific operand values:
Parameter Operand Value
MIN Tag_MIN 10
VALUE Tag_Value 0.5
MAX Tag_MAX 30
OUT Tag_Result 20
If operand "TagIn" has the signal state "1", the "Scale" instruction is executed. The value at
the "Tag_Value" input is scaled to the range of values defined by the values at the "Tag_MIN"
and "Tag_MAX" inputs. The result is stored in the "Tag_Result" output. If the instruction is
executed without errors, the ENO enable output has the signal state "1" and the "TagOut"
output is set.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1588 System Manual, 01/2013,
See also
Overview of the valid data types (Page 899)
NORM_X: Normalize (Page 1589)
NORM_X: Normalize
Description
You can use the instruction "Normalize" to normalize the value of the tag at the VALUE input
by mapping it to a linear scale. You can use the MIN and MAX parameters to define the limits
of a value range that is applied to the scale. The result at the OUT output is calculated and
stored as a floating-point number depending on the location of the value to be normalized
within this value range. If the value to be normalized is equal to the value at the MIN input, the
OUT output has the value "0.0". If the value to be normalized is equal to the value at input
MAX, output OUT returns the value "1.0".
The following figure shows an example of how values can be normalized:
MlN MAX
1.0
0.0
OUT
VALUE
The "Normalize" instruction works with the following equation:
OUT = (VALUE MIN) / (MAX MIN)
The ENO enable output has the signal state "0" if one of the following conditions is fulfilled:
The EN enable input has the signal state "0".
The value at the MIN input is greater than or equal to the value at the MAX input.
The value of a specified floating-point number is outside the range of the normalized
numbers according to IEEE-754.
The value at the VALUE input is NaN (result of an invalid arithmetic operation).
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1589
Parameter
The following table shows the parameters of the "Normalize" instruction:
Parameter Declaration Data type Memory area Description
EN Input BOOL I, Q, M, D, L Enable input
ENO Output BOOL I, Q, M, D, L Enable output
MIN Input Integers, floating-
point numbers
I, Q, M, D, L or
constant
Low limit of the
value range
VALUE Input Integers, floating-
point numbers
I, Q, M, D, L or
constant
Value to be
normalized.
MAX Input Integers, floating-
point numbers
I, Q, M, D, L or
constant
High limit of the
value range
OUT Output Floating-point
numbers
I, Q, M, D, L Result of the
normalization
You can select the data type for the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
S EN ENO
MlN OUT
VALUE
MAX
to REAL
NORM_X
DlNT
"TagOut" "Tagln"
"Tag_MlN"
"Tag_Value"
"Tag_Result"
"Tag_MAX"
The following table shows how the instruction works using specific operand values:
Parameter Operand Value
MIN Tag_MIN 10
VALUE Tag_Value 20
MAX Tag_MAX 30
OUT Tag_Result 0.5
If operand "TagIn" has the signal state "1", the "Normalize" instruction is executed. The value
at the "Tag_Value" input is mapped to the range of values that were defined by the values at
the "Tag_MIN" and "Tag_MAX" inputs. The tag value at the "Tag_Value" input is normalized
to the defined value range. The result is stored as a floating-point number in the "Tag_Result"
output. If the instruction is executed without errors, the ENO enable output has the signal state
"1" and the "TagOut" output is set.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1590 System Manual, 01/2013,
See also
Overview of the valid data types (Page 899)
SCALE_X: Scale (Page 1587)
SCALE: Scale
Description
Use the "Scale" instruction to convert the integer at the IN parameter into a floating-point
number, which can be scaled in physical units between a low limit value and a high limit value.
You use the LO_LIM and HI_LIM parameters to specify the low limit and high limit of the value
range to which the input value is scaled. The result of the instruction is output on the OUT
parameter.
The "Scale" instruction works with the following equation:
OUT = [((FLOAT (IN) K1)/(K2K1)) (HI_LIMLO_LIM)] + LO_LIM
The values of the constants "K1" and "K2" are determined by the signal state on the BIPOLAR
parameter. The following signal states are possible on the BIPOLAR parameter:
Signal state "1": It is assumed that the value at the IN parameter is bipolar and in a value
range between -27648 and 27648. In this case the "K1" constant has the value "-27648.0"
and the "K2" constant the value "+27648.0".
Signal state "0": It is assumed that the value at the IN parameter is unipolar and in a value
range between 0 and 27648. In this case the "K1" constant has the value "0,0" and the "K2"
constant the value "+27648.0".
When the value at the IN parameter is greater than the value of the constant "K2", the result
of the instruction is set to the value of the high limit (HI_LIM) and an error is output.
When the value at the IN parameter is less than the value of the constant "K1", the result of
the instruction is set to the value of the low limit value (LO_LIM) and an error is output.
When the indicated low limit value is greater than the high limit value (LO_LIM > HI_LIM), the
result is scaled in reverse proportion to the input value.
Parameter
The following table shows the parameters of the "Scale" instruction:
Parameter Declaration Data type Memory area Description
EN Input BOOL I, Q, M, D, L Enable input
ENO Output BOOL I, Q, M, D, L Enable output
IN Input INT I, Q, M, D, L, P or
constant
Input value to be
scaled.
HI_LIM Input REAL I, Q, M, D, L, P or
constant
High limit
LO_LIM Input REAL I, Q, M, D, L, P or
constant
Low limit
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1591
Parameter Declaration Data type Memory area Description
BIPOLAR Input BOOL I, Q, M, D, L or
constant
Indicates if the
value at IN
parameter is to be
interpreted as
bipolar or unipolar.
The parameter
can assume the
following values:
1: Bipolar
0: Unipolar
OUT Output REAL I, Q, M, D, L, P Result of the
instruction
RET_VAL Output WORD I, Q, M, D, L, P Error information
Parameter RET_VAL
The following table shows the meaning of the values of the RET_VAL parameter:
Error code*
(W#16#...)
Explanation
0000 No error
0008 The value of the IN parameter is greater than the value of the constant "K2" or less than the value of the
constant "K1"
8xyy For more information on errors, refer to "See also".
*The error codes can be displayed as integer or hexadecimal value in the program editor. For additional information on
toggling display formats, refer to "See also".
Example
The following example shows how the instruction works:
SCALE
EN ENO
lN RET_VAL
OUT Hl_LlM
LO_LlM
BlPOLAR
"Tag_lnputValue" "Tag_OutputValue"
"Tag_ErrorCode" "Tag_HighLimit"
"Tag_LowLimit"
"Tagln" "TagOut"
"Tag_Bipolar"
The following table shows how the instruction works using specific operand values:
Parameter Operand Value
IN Tag_InputValue 22
HI_LIM Tag_HighLimit 100.0
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1592 System Manual, 01/2013,
Parameter Operand Value
LO_LIM Tag_LowLimit 0.0
BIPOLAR Tag_Bipolar 1
OUT Tag_OutputValue 50.03978588
RET_VAL Tag_ErrorCode W#16#0000
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
UNSCALE: Unscale
Description
The "Unscale" instruction is used to unscale the floating-point number on the IN parameter
into physical units between a low limit and a high limit and convert it into an integer. You use
the LO_LIM and HI_LIM parameters to specify the low limit and high limit of the value range
to which the input value is unscaled. The result of the instruction is output on the OUT
parameter.
The "Unscale" instruction works with the following equation:
OUT = [ ((INLO_LIM)/(HI_LIMLO_LIM)) (K2K1) ] + K1
The values of the constants "K1" and "K2" are determined by the signal state on the BIPOLAR
parameter. The following signal states are possible on the BIPOLAR parameter:
Signal state "1": It is assumed that the value at the IN parameter is bipolar and in a value
range between -27648 and 27648. In this case the "K1" constant has the value "-27648.0"
and the "K2" constant the value "+27648.0".
Signal state "0": It is assumed that the value at the IN parameter is unipolar and in a value
range between 0 and 27648. In this case the "K1" constant has the value "0.0" and the "K2"
constant the value "+27648.0".
When the value at the IN parameter is greater than the value of the constant "HI_LIM", the
result of the instruction is set to the value of the constant (K2) and an error is output.
When the value at the IN parameter is less than the value of the constant of the low limit
(LO_LIM), the result of the instruction is set to the value of the constant (K1) and an error is
output.
Parameter
The following table shows the parameters of the "Unscale" instruction:
Parameter Declaration Data type Memory area Description
EN Input BOOL I, Q, M, D, L Enable input
ENO Input BOOL I, Q, M, D, L Enable output
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1593
Parameter Declaration Data type Memory area Description
IN Input REAL I, Q, M, D, L, P or
constant
Input value to be
unscaled to an
integer value.
HI_LIM Input REAL I, Q, M, D, L, P or
constant
High limit
LO_LIM Input REAL I, Q, M, D, L, P or
constant
Low limit
BIPOLAR Input BOOL I, Q, M, D, L or
constant
Indicates if the
value at IN
parameter is to be
interpreted as
bipolar or unipolar.
The parameter
can assume the
following values:
1: Bipolar
0: Unipolar
OUT Output INT I, Q, M, D, L, P Result of the
instruction
RET_VAL Output WORD I, Q, M, D, L, P Error information
Parameter RET_VAL
The following table shows the meaning of the values of the RET_VAL parameter:
Error code*
(W#16#...)
Explanation
0000 No error
0008 The value of the IN parameter is greater than the value of the high limit (HI_LIM) or less than the value
of the low limit (LO_LIM).
8xyy For more information on errors, refer to "See also".
*The error codes can be displayed as integer or hexadecimal value in the program editor. For additional information on
toggling display formats, refer to "See also".
Example
The following example shows how the instruction works:
UNSCALE
EN ENO
lN RET_VAL
OUT Hl_LlM
LO_LlM
BlPOLAR
"Tag_lnputValue" "Tag_OutputValue"
"Tag_ErrorCode" "Tag_HighLimit"
"Tag_LowLimit"
"Tagln" "TagOut"
"Tag_Bipolar"
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1594 System Manual, 01/2013,
The following table shows how the instruction works using specific operand values:
Parameter Operand Value
IN Tag_InputValue 50.03978588
HI_LIM Tag_HighLimit 100.0
LO_LIM Tag_LowLimit 0.0
BIPOLAR Tag_Bipolar 1
OUT Tag_OutputValue 22
RET_VAL Tag_ErrorCode W#16#0000
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
Program control operations
---( JMP ): Jump if RLO = 1
Description
You can use the "Jump if RLO = 1" instruction to interrupt the linear execution of the program
and resume it in another network. The destination network must be identified by a jump label
(LABEL). The name of this jump label is specified in the placeholder above the instruction.
The specified jump label must be in the same block in which the instruction is executed. The
name you specify can only occur once in the block. Only one jumping coil is permitted within
a network.
If the result of logic operation (RLO) at the input of the instruction is "1", the jump to the network
identified by the specified jump label is executed. The jump direction can be towards higher
or lower network numbers.
If the condition at the input of the instruction is not fulfilled (RLO = 0), execution of the program
continues in the next network.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1595
Example
The following example shows how the instruction works:
Network 1
Network 2
Network 3
R
JMP
R
CAS1
CAS1
"TagOut_2"
"TagOut_3"
"Tagln_1"
"Tagln_2"
"Tagln_3"
If operand "TagIn_1" has the signal state "1", the "Jump if RLO = 1" instruction is executed.
The linear execution of the program is interrupted and continues in Network 3, which is
identified by the jump label CAS1. If the "TagIn_3" input has the signal state "1", the "TagOut_3"
output is set.
---( JMPN ): Jump if RLO = 0
Description
You can use the instruction "Jump if RLO = 0" to interrupt the linear execution of the program
and resume it in another network, when the result of logic operation at the input of the
instruction is "0". The destination network must be identified by a jump label (LABEL). The
name of this jump label is specified in the placeholder above the instruction.
The specified jump label must be in the same block in which the instruction is executed. The
name you specify can only occur once in the block. Only one jumping coil is permitted within
a network.
If the result of logic operation (RLO) at the input of the instruction is "0", the jump to the network
identified by the specified jump label is executed. The jump direction can be towards higher
or lower network numbers.
If the result of logic operation at the input of the instruction is "1", execution of the program
continues in the next network.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1596 System Manual, 01/2013,
Example
The following example shows how the instruction works:
Network 1
Network 2
Network 3
R
JMPN
R
CAS1
CAS1
"TagOut_2"
"TagOut_3"
"Tagln_1"
"Tagln_2"
"Tagln_3"
If operand "TagIn_1" has the signal state "0", the "Jump if RLO = 0" instruction is executed.
The linear execution of the program is interrupted and continues in Network 3, which is
identified by the jump label CAS1. If the "TagIn_3" input has the signal state "1", the "TagOut_3"
output is set.
See also
Overview of the valid data types (Page 899)
LABEL: Jump label
Description
You can use a jump label to identify a destination network, in which the program execution
should resume when a jump is executed.
The jump label and the instruction in which the jump label is specified must be located in the
same block. The name of a jump label can only be assigned once in a block. You can declare
up to 32 jump labels when you use a CPU S7-1200 and a maximum of 256 jump labels when
you use a CPU S7-1500.
Only one jump label can be placed in a network. Each jump label can jump to several locations.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1597
Example
The following example shows how the instruction works:
Network 1
Network 2
Network 3
R
JMP
R
CAS1
CAS1
"TagOut_2"
"TagOut_3"
"Tagln_1"
"Tagln_2"
"Tagln_3"
If operand "TagIn_1" has the signal state "1", the "Jump if RLO = 1" instruction is executed.
The linear execution of the program is interrupted and continues in Network 3, which is
identified by the jump label CAS1. If the "TagIn_3" input has the signal state "1", the "TagOut_3"
output is set.
See also
Overview of the valid data types (Page 899)
Inserting additional inputs and outputs in LAD elements (Page 1104)
Removing inputs and outputs (Page 1105)
JMP_LIST: Define jump list
Description
You can use the "Define jump list" instruction to define several conditional jumps and continue
the program execution in a specific network depending on the value of the K parameter.
You define the jumps with jump labels (LABEL), which you specify at the outputs of the
instruction box. The number of outputs can be expanded in the instruction box. You can declare
up to 32 outputs when you use a CPU S7-1200 and a maximum of 256 outputs when you use
a CPU S7-1500.
The numbering of the outputs begins with the value "0" and continues in ascending order with
each new output. Only jump labels can be specified at the outputs of the instruction. Instructions
or operands cannot be specified.
The value of the K parameter specifies the number of the output and thus the jump label where
the program execution is to be resumed. If the value in the K parameter is greater than the
number of available outputs, the program execution is resumed in the next network of the block.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1598 System Manual, 01/2013,
The "Define jump list" instruction is only executed if the signal state is "1" at the EN enable
input.
Parameter
The following table shows the parameters of the "Define jump list" instruction:
Parameters Declaration Data type Memory area Description
EN Input BOOL I, Q, M, D, L Enable input
K Input UINT I, Q, M, D, L or
constant
Specifies the
number of the
output and thus
the jump that is to
be made.
DEST0 - - - First jump label
DEST1 - - - Second jump label
DESTn - - - Optional jump
labels
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
"Tag_lnput"
DEST0
EN
K
JMP_LlST
DEST1
DEST2
LABEL0
LABEL1
LABEL2
"Tag_Value"
The following table shows how the instruction works using specific operand values:
Parameters Operand/Jump label Value
K Tag_Value 1
Dest0 LABEL0 Jump to the network that is
identified with the jump label
"LABEL0".
Dest1 LABEL1 Jump to the network that is
identified with the jump label
"LABEL1".
Dest2 LABEL2 Jump to the network that is
identified with the jump label
"LABEL2".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1599
If operand "Tag_Input" has the signal state "1", the "Define jump list" instruction is executed.
The program execution is resumed according to the value of operand "Tag_Value" in the
network that is identified with the jump label "LABEL1".
See also
Overview of the valid data types (Page 899)
Inserting additional inputs and outputs in LAD elements (Page 1104)
Removing inputs and outputs (Page 1105)
SWITCH: Jump distributor
Description
You can use the "Jump distributor" instruction to define multiple program jumps to be executed
depending on the result of one or more comparison instructions.
You specify the value to be compared in the K parameter. This value is compared with the
values that are provided by the various inputs. You can select the comparison method for each
individual input. The availability of the various comparison instructions depends on the data
type of the instruction.
The following table shows the comparison instructions that are available depending on the
selected data type:
Data type Instruction Syntax
S7-1200 S7-1500
Bit strings Bit strings Equal ==
Not equal <>
Integers, floating-point
numbers, TIME,
DATE, TOD
Integers, floating-point
numbers, TIME,
LTIME, DATE, TOD,
LTOD, LDT
Equal ==
Not equal <>
Greater or equal >=
Less or equal <=
Greater than >
Less than <
You can select the data type of the instruction from the "<???>" drop-down list of the instruction
box. If you select a comparison instruction and the data type of the instruction is not yet defined,
the "<???>" drop-down list only offers the data types that are permitted for the selected
comparison instruction.
Execution of the instruction begins with the first comparison and runs until a comparison
condition is met. If a comparison condition is met, the subsequent comparison conditions are
not considered. If none of the specified comparison conditions are met, the jump at the ELSE
output is executed. If no program jump is defined at the ELSE output, execution of the program
continues in the next network.
The number of outputs can be expanded in the instruction box. The numbering of the outputs
begins with the value "0" and continues in ascending order with each new output. Specify jump
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1600 System Manual, 01/2013,
labels (LABEL) at the outputs of the instruction. Instructions or operands cannot be specified
at the outputs of the instruction.
An input is automatically inserted for each additional output. The jump programmed at an
output is executed if the comparison condition of the corresponding input is fulfilled.
Parameters
The following table shows the parameters of the "Jump distributor" instruction:
Parameter Declarati
on
Data type Memory area Description
S7-1200 S7-1500
EN Input BOOL BOOL I, Q, M, D, L Enable input
K Input UINT UINT I, Q, M, D, L or
constant
Specifies the value to
be compared.
<Comparison
values>
Input Bit strings,
integers,
floating-point
numbers,
TIME, DATE,
TOD
Bit strings,
integers,
floating-point
numbers,
TIME,
LTIME,
DATE, TOD,
LTOD, LDT
I, Q, M, D, L or
constant
Input value with
which the value of the
K parameter is
compared.
DEST0 - - - - First jump label
DEST1 - - - - Second jump label
DEST(n) - - - - Optional jump
labels(n = 2 to 99)
ELSE - - - - Program jump that is
executed when none
of the comparison
conditions are
fulfilled.
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1601
Example
The following example shows how the instruction works:
DEST0
UlNT
K
EN
==
>
<
SWlTCH
DEST1
DEST2
LABEL0
LABEL1
LABEL2
LABEL3
"Tag_Value"
"Tag_Value_1"
"Tag_Value_2"
"Tag_Value_3"
ELSE
"Tag_lnput"
The following table shows how the instruction works using specific operand values:
Parameters Operand/Jump label Value
K Tag_Value 23
== Tag_Value_1 20
> Tag_Value_2 21
< Tag_Value_3 19
Dest 0 LABEL0 Jump to jump label "LABEL0", if
the value of the K parameter
equals 20.
Dest 1 LABEL1 Jump to jump label "LABEL1" if
the value of the K parameter is
greater than 21.
Dest 2 LABEL2 Jump to jump label "LABEL2", if
the value of the K parameter is
less than 19.
ELSE LABEL 3 Jump to jump label "LABEL3", if
the none of the comparison
conditions are fulfilled.
If the operand "Tag_Input" changes to signal state "1", the instruction "Jump distributor" is
executed. The execution of the program is continued in the network that is identified with the
jump label "LABEL1".
See also
Overview of the valid data types (Page 899)
Inserting additional inputs and outputs in LAD elements (Page 1104)
Removing inputs and outputs (Page 1105)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1602 System Manual, 01/2013,
--(RET): Return
Description
You can use the "Return" instruction to stop the execution of a block. The results is three types
through which the block processing can be completed.
Without call of the "Return" instruction
The block is exited after execution of the last network. The ENO of the function call is set
to the signal state "1".
Call of the "Return" instruction with preceding logic operation (see example)
If the left connector has the signal state "1", the block will be exited. The ENO of the function
call corresponds to the operand.
Call of the "Return" instruction without previous logic operation
The block is exited. The ENO of the function call corresponds to the operand.
Note
Only one jumping coil may be used in a network ("Return", "Jump if RLO=1", "Jump if
RLO=0").
If the result of logic operation (RLO) at the input of the "Return" instruction is "1", program
execution is terminated in the currently called block and resumed after the call function in the
calling block (for example, in the calling OB). The status (ENO) of the call function is determined
by the parameter of the instruction. This can assume the following values:
RLO
TRUE/FALSE
<Operand>
To set the parameter values, double-click the instruction and select the corresponding value
in the drop-down list.
The following table shows the status of the call function if the "Return" instruction is
programmed in a network within the called block:
RLO Parameter value ENO of the call function
1 RLO 1
TRUE 1
FALSE 0
<Operand> <Operand>
0 RLO The program execution continues in the
next network of the called block.
TRUE
FALSE
<Operand>
If an OB is completed, another block will be selected and started or executed by the priority
class system:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1603
If the program cycle OB was completed, it will be restarted.
If an OB is completed that has interrupted another block (for example, an alarm OB), then
the interrupted block (for example, program cycle OB) will be executed.
Parameters
The following table shows the parameters of the "Return" instruction:
Parameter Declaration Data type Memory area Description
Status of the
calling function
with RLO = 1:
RLO - - Is set to the signal
status of the RLO.
TRUE - - 1
FALSE - - 0
<Operand> Input BOOL I, Q, M, D, L Signal state of the
specified operand
Example
The following example shows how the instruction works:
RET
FALSE "Tagln"
If operand "TagIn" has the signal state "1", the "Return" instruction is executed. Program
execution is terminated in the called block and continues in the calling block. The ENO enable
output of the call function is reset to signal state "0".
See also
Overview of the valid data types (Page 899)
Runtime control
RE_TRIGR: Restart cycle monitoring time
Description
You can use the "Restart cycle monitoring time" instruction to restart the cycle time monitoring
of the CPU. The maximum cycle time then starts over again for the duration you have set in
the CPU configuration.
The instruction "Restart cycle monitoring time" can be called regardless of the priority in all
blocks.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1604 System Manual, 01/2013,
If the instruction is called in a block with a higher priority, such as a hardware interrupt,
diagnostic error interrupt, or cyclic interrupt, the instruction is not executed and the ENO enable
output is set to signal state "0".
The instruction "Restart cycle monitoring time" can be called a maximum of 10 times in a
program cycle.
Note
Make sure that you do not create an infinite loop in the cyclical program processing, i.e. in
OB1, when you use the instruction "Restart cycle monitoring time". Otherwise the CPU will
not reach the cycle control point. As a result, it may not be possible to execute certain CPU
functions (e. g. process image update).
Parameters
The "Restart cycle monitoring time" instruction has no parameters.
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
STP: Exit program
Description
You use the "Exit program" instruction to set the CPU to STOP mode and therefore to terminate
the execution of the program. The effects of changing from RUN to STOP depend on the CPU
configuration.
When the result of logic operation (RLO) at the input of the instruction is "1", the CPU changes
to STOP mode and program execution is terminated. The signal state at the output of the
instruction is not evaluated.
When the RLO is "0" at the input of the instruction, then the instruction will not be executed.
Parameters
The "Exit program" instruction has no parameters.
See also
Overview of the valid data types (Page 899)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1605
GetError: Get error locally
Description
The "Get error locally" instruction is used to query the occurrence of errors within a block. If
the system signals errors during block execution, detailed information about the first error that
occurred is saved in the operand at the ERROR output.
Only operands of the "ErrorStruct" system data type can be specified at the ERROR output.
The "ErrorStruct" system data type specifies the exact structure in which the information about
the error is stored. Using additional instructions, you can evaluate this structure and program
an appropriate response. When the first error has been eliminated, the instruction outputs
information about the next error that occurred.
Parameters
The following table shows the parameters of the "Get error locally" instruction:
Parameters Declaration Data type Memory area Description
ERROR Output ErrorStruct D, L Error information
Data type "ErrorStuct"
The following table shows the structure of the "ErrorStruct" data type:
Structure component Data type Description
ERROR_ID WORD Error ID
FLAGS BYTE Shows if an error occurred during a block call.
16#01: Error during a block call.
16#00: No error during a block call.
REACTION BYTE Default reaction:
0: Ignore (write error),
1: Continue with substitute value "0" (read error),
2: Skip instruction (system error)
CODE_ADDRESS CREF Information about the address and type of block
BLOCK_TYPE BYTE Type of block where the error occurred:
1: OB
2: FC
3: FB
CB_NUMBER UINT Number of the code block
OFFSET UDINT Reference to the internal memory
MODE BYTE Access mode: Depending on the type of access, the
following information can be output:
Mode (A) (B) (C) (D) (E)
0
1 Offset
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1606 System Manual, 01/2013,
Structure component Data type Description
2 Area
3 Location Scope Numb
er
4 Area Offset
5 Area DB no. Offset
6 PtrNo./
Acc
Area DB no. Offset
7 PtrNo./
Acc
Slot
No. /
Scope
Area DB no. Offset
OPERAND_NUMBER UINT Operand number of the machine command
POINTER_NUMBER_LOCATION UINT (A) Internal pointer
SLOT_NUMBER_SCOPE UINT (B) Storage area in internal memory
DATA_ADDRESS NREF Information about the address of an operand
AREA BYTE (C) Memory area:
L: 16#40 4E, 86, 87, 8E, 8F, C0 CE
E: 16#81
A: 16#82
M: 16#83
DB: 16#84, 85, 8A, 8B
DB_NUMBER UINT (D) Number of the data block
OFFSET UDINT (E) Relative address of the operand
Structure component "ERROR_ID"
The following table shows the values that can be output on the structure component
"ERROR_ID":
ID*
(hexadecimal)
ID*
(decimal)
Description
0 0 No error
2503 9475 Invalid pointer
2505 9477 Calling the instruction "Stop" (SFC46) in the user program
2520 9504 Invalid STRING
2522 9506 Read error: Operand outside the valid range
2523 9507 Write error: Operand outside the valid range
2524 9508 Read error: Invalid operand
2525 9509 Write error: Invalid operand
2528 9512 Read error: Data alignment
2529 9513 Write error: Data alignment
252C 9516 Invalid pointer
2530 9520 Write error: Data block
2533 9523 Invalid pointer used
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1607
ID*
(hexadecimal)
ID*
(decimal)
Description
2534 9524 Block number error FC
2535 9525 Block number error FB
2538 9528 Access error: DB does not exist
2539 9529 Access error: Wrong DB used
253A 9530 Global data block does not exist
253C 9532 Faulty information or the function does not exist
253D 9533 System function does not exist
253E 9534 Faulty information or the function block does not exist
253F 9535 System block does not exist
2550 9552 Access error: DB does not exist
2551 9553 Access error: Wrong DB used
2575 9589 Error in the program nesting depth
2576 9590 Error in the local data distribution
2942 10562 Read error: Input
2943 10563 Write error: Output
*The error codes can be displayed as integer or hexadecimal value in the program editor. For additional
information on toggling display formats, refer to "See also".
The ENO enable output of the "Get error locally" instruction is only set if the EN enable input
has the signal state "1" and error information is present. If one of these conditions is not fulfilled,
the remaining program execution is not affected by the "Get error locally" instruction.
The "Get error locally" instruction can also be used to forward an alarm about the error status
to the calling block. To do this, the instruction must be positioned in the last network of the
called block.
Note
The "Get error locally" instruction enables local error handling within a block. If "Get error
locally" is inserted in the program code of a block, any predefined system responses are
ignored when an error occurs.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1608 System Manual, 01/2013,
Example
The following example shows how the instruction works:
"Tag_lnput"
==
CONV
ENO EN
lN OUT
BYTE UlNT
#error
GET_ERROR
ERROR #err_reaction
"substitute"
#err_reaction
#out #index
#out
"OK"
#conv
UlNT
R
R
#error.
reaction
#conv
ENO EN
to
When an error occurs, the "Get error locally" instruction returns the error information to the
locally created "#error" structure at the ERROR output. The error information is converted and
evaluated using the "Equal" comparison instruction. Information about the type of error is the
first comparison value assigned to the instruction. The value "1" is specified in operand
"substitute" as the second comparison value. If the error is a read error, the condition of the
comparison instruction is fulfilled. The "#out" and "OK" outputs are reset in this case.
See also
Overview of the valid data types (Page 899)
Basics of error handling (Page 1193)
Principles of local error handling (Page 1195)
Error output priorities (Page 1196)
Enabling local error handling for a block (Page 1197)
GetErrorID: Get error ID locally
Description
The "Get error ID locally" instruction is used to query the occurrence of errors within a block.
If the system signals errors during block execution, the error ID of the first error that occurred
is saved in the tag at output ID. Only operands of the WORD data type can be specified at the
ID output. When the first error has been eliminated, the instruction outputs the error ID of the
next error that occurred.
The output of the "Get error ID locally" instruction is only set if the input of the instruction has
the signal state "1" and error information is present. If one of these conditions is not fulfilled,
the remaining program execution is not affected by the "Get error ID locally" instruction.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1609
The "Get error ID locally" instruction can also be used to forward an alarm about the error
status to the calling block. To do this, the instruction must be positioned in the last network of
the called block.
Note
The "Get error ID locally" instruction enables local error handling within a block. If the "Get
error ID locally" instruction is inserted in the program code of a block, any predefined system
responses are ignored when an error occurs.
Parameters
The following table shows the parameters of the "Get error ID locally" instruction:
Parameters Declaration Data type Memory area Description
ID Output WORD I, Q, M, D, L Error ID
Parameters ID
The following table shows the values that can be output in the ID parameter:
ID*
(hexadecimal)
ID*
(decimal)
Description
0 0 No error
2503 9475 Invalid pointer
2505 9477 Calling the instruction "Stop" (SFC46) in the user program
2520 9504 Invalid STRING
2522 9506 Read error: Operand outside the valid range
2523 9507 Write error: Operand outside the valid range
2524 9508 Read error: Invalid operand
2525 9509 Write error: Invalid operand
2528 9512 Read error: Data alignment
2529 9513 Write error: Data alignment
252C 9516 Invalid pointer
2530 9520 Write error: Data block
2533 9523 Invalid pointer used
2534 9524 Block number error FC
2535 9525 Block number error FB
2538 9528 Access error: DB does not exist
2539 9529 Access error: Wrong DB used
253A 9530 Global data block does not exist
253C 9532 Faulty information or the function does not exist
253D 9533 System function does not exist
253E 9534 Faulty information or the function block does not exist
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1610 System Manual, 01/2013,
ID*
(hexadecimal)
ID*
(decimal)
Description
253F 9535 System block does not exist
2550 9552 Access error: DB does not exist
2551 9553 Access error: Wrong DB used
2575 9589 Error in the program nesting depth
2576 9590 Error in the local data distribution
2942 10562 Read error: Input
2943 10563 Write error: Output
*The error codes can be displayed as integer or hexadecimal value in the program editor. For additional
information on toggling display formats, refer to "See also".
See also
Overview of the valid data types (Page 899)
Basics of error handling (Page 1193)
Principles of local error handling (Page 1195)
Error output priorities (Page 1196)
Enabling local error handling for a block (Page 1197)
INIT_RD: Initialize all retain data
Description
You use the "Initialize all retain data" instruction to reset the retain data of all data blocks, bit
memories and SIMATIC timers and counters at the same time. The instruction can only be
executed within a startup OB because the execution would exceed the program cycle duration.
Parameter
The following table shows the parameters of the "Initialize all retain data" instruction:
Parameter Declaration Data type Memory area Description
EN Input BOOL I, Q, M, D, L Enable input
ENO Output BOOL I, Q, M, D, L Enable output
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1611
Parameter Declaration Data type Memory area Description
REQ Input BOOL I, Q, M, D, L, T, C
or constant
If the "REQ" input
has the signal
state "1", all retain
data are reset.
RET_VAL Output INT I, Q, M, D, L Error information:
If an error occurs
during execution
of the instruction,
an error code is
output on the
RET_VAL
parameter.
For additional information on valid data types, refer to "See also".
Parameters RET_VAL
The following table shows the meaning of the values of the RET_VAL parameter:
Error code*
(W#16#...)
Explanation
0000 No error
80B5 The instruction cannot be executed because it was not programmed within a startup OB.
8xyy For more information on errors, refer to "See also".
*The error codes can be displayed as integer or hexadecimal value in the program editor. For additional information on
toggling display formats, refer to "See also".
Example
The following example shows how the instruction works:
lNlT_RD
RET_VAL REQ
EN ENO
"Tag_REQ" "Tag_Result"
"TagOut" "Tagln_1"
If the operands "TagIn_1" and "Tag_REQ" have signal state "1", the instruction is executed.
The retain data of all data blocks, bit memories and SIMATIC timers and counters are reset If
the instruction is executed without errors, the ENO enable output has the signal state "1".
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1612 System Manual, 01/2013,
WAIT: Configure time delay
Description
The "Configure time delay" instruction is used to halt the execution of the program for a set
period of time. You indicate the period of time in microseconds on the WT parameter of the
instruction.
You can configure time delays of up to 32767 microseconds (s). The smallest possible delay
time depends on the respective CPU and corresponds to the execution time of the "Configure
time delay" instruction.
The execution of the instruction can be interrupted by higher priority events.
The "Configure time delay" instruction supplies no error information.
Parameters
The following table shows the parameters of the "Configure time delay" instruction:
Parameter Declaration Data type Memory area Description
EN Input BOOL I, Q, M, D, L Enable input
ENO Output BOOL I, Q, M, D, L Enable output
WT Input INT I, Q, M, D, L, P or
constant
Time delay in
microseconds (s)
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
Word logic operations
AND: AND logic operation
Description
You can use the "AND logic operation" instruction to combine the value at the IN1 input and
the value at the IN2 input bit-by-bit by AND logic and query the result at the OUT output.
When the instruction is executed, bit 0 of the value at the IN1 input and bit 0 of the value at
the IN2 input are logically ANDed. The result is stored in bit 0 of output OUT. The same logic
operation is executed for all other bits of the specified values.
The number of inputs can be expanded in the instruction box. The added inputs are numbered
in ascending order in the box. When the instruction is executed, the values of all available input
parameters are combined with AND logic (ANDed). The result is stored in the OUT output.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1613
The result bit has signal state "1" only when both of the bits in the logic operation also have
signal state "1". If one of the two bits of the logic operation has signal state "0", the
corresponding result bit is reset.
Parameters
The following table shows the parameters of the "AND logic operation" instruction:
Parameter Declaration Data type Memory area Description
EN Input BOOL I, Q, M, D, L Enable input
ENO Output BOOL I, Q, M, D, L Enable output
IN1 Input Bit strings I, Q, M, D, L, P or
constant
First value for logic
operation
IN2 Input Bit strings I, Q, M, D, L, P or
constant
Second value for
logic operation
INn Input Bit strings I, Q, M, D, L, P or
constant
Other inputs
whose values are
logically
combined.
OUT Output Bit strings I, Q, M, D, L, P Result of the
instruction
You can select the data type for the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
AND
ENO EN
lN2
lN1
OUT
WORD
"TagOut" "Tagln"
"Tag_Value2"
"Tag_Value1"
"Tag_Result"
The following table shows how the instruction works using specific operand values:
Parameter Operand Value
IN1 Tag_Value1 0101 0101 0101 0101
IN2 Tag_Value2 0000 0000 0000 1111
OUT Tag_Result 0000 0000 0000 0101
If operand "TagIn" has the signal state "1", the "AND logic operation" instruction is executed.
The value of operand "Tag_Value1" and the value of operand "Tag_Value2" are ANDed. The
result is mapped bit-for-bit and output in operand "Tag_Result". The ENO enable output and
the "TagOut" output are set to signal state "1".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1614 System Manual, 01/2013,
See also
Overview of the valid data types (Page 899)
Inserting additional inputs and outputs in LAD elements (Page 1104)
Removing inputs and outputs (Page 1105)
Basics of the EN/ENO mechanism (Page 987)
OR: OR logic operation
Description
You can use the "OR logic operation" instruction to combine the value at the IN1 input and the
value at the IN2 input bit-by-bit by OR logic and query the result at the OUT output.
When the instruction is executed, bit 0 of the value at the IN1 input and bit 0 of the value at
the IN2 input are combined by OR logic operation. The result is stored in bit 0 of output OUT.
The same logic operation is executed for all bits of the specified tags.
The number of inputs can be expanded in the instruction box. The added inputs are numbered
in ascending order in the box. When the instruction is executed, the values of all available input
parameters are combined with OR logic (ORed). The result is stored in the OUT output.
The result bit has signal state "1" when at least one of the two bits in the logic operation has
the signal state "1". If both of the bits of the logic operation have signal state "0", the
corresponding result bit is reset.
Parameters
The following table shows the parameters of the "OR logic operation" instruction:
Parameter Declaration Data type Memory area Description
EN Input BOOL I, Q, M, D, L Enable input
ENO Output BOOL I, Q, M, D, L Enable output
IN1 Input Bit strings I, Q, M, D, L, P or
constant
First value for logic
operation
IN2 Input Bit strings I, Q, M, D, L, P or
constant
Second value for
logic operation
INn Input Bit strings I, Q, M, D, L, P or
constant
Other inputs
whose values are
logically
combined.
OUT Output Bit strings I, Q, M, D, L, P Result of the
instruction
You can select the data type for the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1615
Example
The following example shows how the instruction works:
OR
ENO EN
lN2
lN1
OUT
WORD
"TagOut" "Tagln"
"Tag_Value2"
"Tag_Value1"
"Tag_Result"
The following table shows how the instruction works using specific operand values:
Parameter Operand Value
IN1 Tag_Value1 0101 0101 0101 0101
IN2 Tag_Value2 0000 0000 0000 1111
OUT Tag_Result 0101 0101 0101 1111
If operand "TagIn" has the signal state "1", the "OR logic operation" instruction is executed.
The value of operand "Tag_Value1" and the value of operand "Tag_Value2" are ORed. The
result is mapped bit-for-bit and output in operand "Tag_Result". The ENO enable output and
the "TagOut" output are set to signal state "1".
See also
Overview of the valid data types (Page 899)
Inserting additional inputs and outputs in LAD elements (Page 1104)
Removing inputs and outputs (Page 1105)
Basics of the EN/ENO mechanism (Page 987)
XOR: EXCLUSIVE OR logic operation
Description
You can use the "EXCLUSIVE OR logic operation" instruction to combine the value at the IN1
input and the value at the IN2 input bit-by-bit by EXCLUSIVE OR logic and query the result at
the OUT output.
When the instruction is executed, bit 0 of the value at the IN1 input and bit 0 of the value at
the IN2 input are combined by EXCLUSIVE OR logic operation. The result is stored in bit 0 of
output OUT. The same logic operation is executed for all other bits of the specified value.
The number of inputs can be expanded in the instruction box. The added inputs are numbered
in ascending order in the box. When the instruction is executed, the values of all available input
parameters are combined with EXCLUSIVE OR logic. The result is stored in the OUT output.
The result bit has signal state "1" when one of the two bits in the logic operation has the signal
state "1". If both of the bits of the logic operation have signal state "1" or "0", the corresponding
result bit is reset.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1616 System Manual, 01/2013,
Parameters
The following table shows the parameters of the "EXCLUSIVE OR logic operation" instruction:
Parameter Declaration Data type Memory area Description
EN Input BOOL I, Q, M, D, L Enable input
ENO Output BOOL I, Q, M, D, L Enable output
IN1 Input Bit strings I, Q, M, D, L, P or
constant
First value for logic
operation
IN2 Input Bit strings I, Q, M, D, L, P or
constant
Second value for
logic operation
INn Input Bit strings I, Q, M, D, L, P or
constant
Other inputs
whose values are
logically
combined.
OUT Output Bit strings I, Q, M, D, L, P Result of the
instruction
You can select the data type for the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
XOR
ENO EN
lN2
lN1
OUT
WORD
"TagOut" "Tagln"
"Tag_Value2"
"Tag_Value1"
"Tag_Result"
The following table shows how the instruction works using specific operand values:
Parameter Operand Value
IN1 Tag_Value1 0101 0101 0101 0101
IN2 Tag_Value2 0000 0000 0000 1111
OUT Tag_Result 0101 0101 0101 1010
If operand "TagIn" has the signal state "1", the "EXCLUSIVE OR logic operation" instruction
is executed. The value of operand "Tag_Value1" and the value of operand "Tag_Value2" are
combined by EXCLUSIVE OR logic. The result is mapped bit-for-bit and output in operand
"Tag_Result". The ENO enable output and the "TagOut" output are set to signal state "1".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1617
See also
Overview of the valid data types (Page 899)
Inserting additional inputs and outputs in LAD elements (Page 1104)
Removing inputs and outputs (Page 1105)
Basics of the EN/ENO mechanism (Page 987)
INV: Create ones complement
Description
You can use the "Create ones complement" instruction to invert the signal state of the bits at
the IN input. When the instruction is processed, the value at the IN input and a hexadecimal
template (W#16#FFFF for 16-bit numbers or DW#16#FFFF FFFF for 32-bit numbers) are
combined by EXCLUSIVE OR logic. This inverts the signal state of the individual bits that are
then stored at output OUT.
Parameters
The following table shows the parameters of the "Create ones complement" instruction:
Parameter Declaration Data type Memory area Description
EN Input BOOL I, Q, M, D, L Enable input
ENO Output BOOL I, Q, M, D, L Enable output
IN Input Bit strings,
integers
I, Q, M, D, L, P or
constant
Input value
OUT Output Bit strings,
integers
I, Q, M, D, L, P Ones complement
of the value at
input IN
You can select the data type for the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
EN
lNV
ENO
lN OUT
WORD
"TagOut" "Tagln"
"Tagln_Value" "TagOut_Value"
The following table shows how the instruction works using specific operand values:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1618 System Manual, 01/2013,
Parameter Operand Value
IN TagIn_Value W#16#000F W#16#7E
OUT TagOut_Value W#16#FFF0 W#16#81
If operand "TagIn" has the signal state "1", the "Create ones complement" instruction is
executed. The instruction inverts the signal state of the individual bits at input TagIn_Value"
and writes the result to output "TagOut_Value". The ENO enable output and the "TagOut"
output are set to signal state "1".
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
DECO: Decode
Description
You can use the "Decode" instruction to set a bit in the output value specified by the input
value.
The "Decode" instruction reads the value at the IN input and sets the bit in the output value
whose bit position corresponds to the read value. The other bits in the output value are filled
with zeroes. When the value at the IN input is greater than 31, a modulo 32 instruction is
executed.
Parameters
The following table shows the parameters of the "Decode" instruction:
Parameter Declaration Data type Memory area Description
EN Input BOOL I, Q, M, D, L Enable input
ENO Output BOOL I, Q, M, D, L Enable output
IN Input UINT I, Q, M, D, L, P or
constant
Position of the bit
in the output value
which is set.
OUT Output Bit strings I, Q, M, D, L, P Output value
You can select the data type for the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1619
Example
The following example shows how the instruction works:
EN
DECO
ENO
lN OUT
UlNT DWORD
to
"TagOut" "Tagln"
"Tagln_Value" "TagOut_Value"
The following figure shows how the instruction works using specific operand values:
0000 0000 0000 0000 0000 0000 0000 1000
3 ... 0 15 ... ... 16 31 ...
3 "Tagln_Value"
"TagOut_Value"
If operand "TagIn" has the signal state "1", the "Decode" instruction is executed. The instruction
reads bit number "3" from the value of the operand "TagIn_Value" at the input and sets the
third bit to the value of the operand "TagOut_Value" at the output.
If the instruction is executed without errors, the ENO enable output has the signal state "1"
and the "TagOut" output is set.
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
ENCO: Encode
Description
You can use the "Encode" instruction to read the bit number of the least significant bit in the
input value and to send it to the OUT output.
The "Encode" instruction selects the least significant bit of the value at the IN input and writes
its bit number to the tag in the OUT output.
Parameters
The following table shows the parameters of the "Encode" instruction:
Parameter Declaration Data type Memory area Description
EN Input BOOL I, Q, M, D, L Enable input
ENO Output BOOL I, Q, M, D, L Enable output
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1620 System Manual, 01/2013,
Parameter Declaration Data type Memory area Description
IN Input Bit strings I, Q, M, D, L, P or
constant
Input value
OUT Output INT I, Q, M, D, L, P Output value
You can select the data type for the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
ENCO
OUT lN
EN ENO
"TagOut"
"Tagln_Value" "TagOut_Value"
"Tagln"
DWORD
The following figure shows how the instruction works using specific operand values:
0000 1111 0000 0101 0000 1001 0000 1000
3 ... 0 15 ... ... 16 31 ...
3
"Tagln_Value"
"TagOut_Value"
If operand "TagIn" has the signal state "1", the "Encode" instruction is executed. The instruction
selects the least significant bit at the "TagIn_Value" input and writes bit position "3" to the tag
in the "TagOut_Value" output.
If the instruction is executed without errors, the ENO enable output has the signal state "1"
and the "TagOut" output is set.
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
SEL: Select
Description
Depending on a switch (G input), the "Select" instruction selects one of the inputs, IN0 or IN1
and copies its content to the OUT output. When the G input has the signal state "0", the value
at the IN0 input is moved. When the G input has the signal state "1", the value at the IN1 input
is moved to the OUT output.
All tags at all parameters must have the same data type.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1621
Parameters
The following table shows the parameters of the "Select" instruction:
Parameter Declaration Data type Memory area Description
S7-1200 S7-1500 S7-1200 S7-1500
EN Input BOOL BOOL I, Q, M,
D, L
I, Q, M, D, L Enable input
ENO Output BOOL BOOL I, Q, M,
D, L
I, Q, M, D, L Enable output
G Input BOOL BOOL I, Q, M,
D, L
I, Q, M, D,
L, T, C
Switch
IN0 Input Bit strings,
integers,
floating-point
numbers,
TIME, TOD,
DATE, CHAR
Bit strings,
integers,
floating-point
numbers,
timers, TOD,
LTOD,
DATE, CHAR
I, Q, M,
D, L, P
or
constant
I, Q, M, D,
L, P or
constant
First input value
IN1 Input Bit strings,
integers,
floating-point
numbers,
TIME, TOD,
DATE, CHAR
Bit strings,
integers,
floating-point
numbers,
timers, TOD,
LTOD,
DATE, CHAR
I, Q, M,
D, L, P
or
constant
I, Q, M, D,
L, P or
constant
Second input
value
OUT Output Bit strings,
integers,
floating-point
numbers,
TIME, TOD,
DATE, CHAR
Bit strings,
integers,
floating-point
numbers,
timers, TOD,
LTOD,
DATE, CHAR
I, Q, M,
D, L, P
I, Q, M, D,
L, P
Result
You can select the data type for the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
SEL
OUT G
EN ENO
WORD
lN0
lN1
"TagOut"
"Tagln_G"
"TagOut_Value"
"Tagln_Value0"
"Tagln_Value1"
"Tagln"
The following table shows how the instruction works using specific operand values:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1622 System Manual, 01/2013,
Parameter Operand Value
G TagIn_G 0 1
IN0 TagIn_Value0 W#16#0000 W#16#4C
IN1 TagIn_Value1 W#16#FFFF W#16#5E
OUT TagOut_Value W#16#0000 W#16#5E
If operand "TagIn" has the signal state "1", the "Select" instruction is executed. Based on the
signal state at the "TagIn_G" input, the value at the "TagIn_Value0" or "TagIn_Value1" input
is selected and copied to the "TagOut_Value" output. If the instruction is executed without
errors, enable output ENO has the signal state "1" and the "TagOut" output is set.
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
MUX: Multiplex
Description
You can use the "Multiplex" instruction to copy the content of a selected input to the OUT
output. The number of selectable inputs of the instruction box can be expanded. You can
declare up to 32 input parameters when you use a CPU S7-1200 and a maximum of 256 input
parameters when you use a CPU S7-1500.
The inputs are automatically numbered in the box. Numbering starts at IN0 and continues
consecutively with each new input. You use the K parameter to define the input whose content
is to be copied to the OUT output. If the value of the K parameter is greater than the number
of available inputs, the content of the ELSE parameter is copied to the OUT output and the
ENO enable output is assigned the signal state "0".
The "Multiplex" instruction can only be executed, when the tags in all inputs and in the OUT
output have the same data type. The K parameter is an exception, since only integers can be
specified for it.
The ENO enable output is reset if one of the following conditions is fulfilled:
The EN enable input has the signal state "0".
The value of the K parameter is greater than the number of available inputs.
Errors occurred during execution of the instruction.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1623
Parameters
The following table shows the parameters of the "Multiplex" instruction:
Parameter Declaration Data type Memory area Description
S7-1200 S7-1500
EN Input BOOL BOOL I, Q, M, D, L Enable input
ENO Output BOOL BOOL I, Q, M, D, L Enable output
K Input Integers Integers I, Q, M, D, L, P
or constant
Specifies the
input whose
content is to be
copied.
If K = 0 =>
Parameter
IN0
If K = 1 =>
Parameter
IN1, etc.
IN0 Input Binary
numbers,
integers,
floating-point
numbers,
strings, TIME,
TOD, DATE
Binary
numbers,
integers,
floating-point
numbers,
strings, timers,
TOD, LTOD,
DATE, LDT
I, Q, M, D, L, P
or constant
First input
value
IN1 Input Binary
numbers,
integers,
floating-point
numbers,
strings, TIME,
TOD, DATE
Binary
numbers,
integers,
floating-point
numbers,
strings, timers,
TOD, LTOD,
DATE, LDT
I, Q, M, D, L, P
or constant
Second input
value
INn Input Binary
numbers,
integers,
floating-point
numbers,
strings, TIME,
TOD, DATE
Binary
numbers,
integers,
floating-point
numbers,
strings, timers,
TOD, LTOD,
DATE, LDT
I, Q, M, D, L, P
or constant
Optional input
values
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1624 System Manual, 01/2013,
Parameter Declaration Data type Memory area Description
S7-1200 S7-1500
ELSE Input Binary
numbers,
integers,
floating-point
numbers,
strings, TIME,
TOD, DATE
Binary
numbers,
integers,
floating-point
numbers,
strings, timers,
TOD, LTOD,
DATE, LDT
I, Q, M, D, L, P
or constant
Specifies the
value to be
copied with K >
n.
OUT Output Binary
numbers,
integers,
floating-point
numbers,
strings, TIME,
TOD, DATE
Binary
numbers,
integers,
floating-point
numbers,
strings, timers,
TOD, LTOD,
DATE, LDT
I, Q, M, D, L, P Output to
which the
value is to be
copied.
You can select the data type for the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
MUX
EN ENO
K OUT
lN0
lN1
ELSE
DWORD
S
"Tag_Output" "Tag_lnput"
"Tag_Number"
"Tag_Value_0"
"Tag_Value_1"
"Tag_Value_2"
"Tag_Result"
The following table shows how the instruction works using specific operand values:
Parameter Operand Value
K Tag_Number 1
IN0 Tag_Value_0 DW#16#00000000
IN1 Tag_Value_1 DW#16#003E4A7D
ELSE Tag_Value_2 DW#16#FFFF0000
OUT Tag_Result DW#16#003E4A7D
If operand "Tag_Input" has the signal state "1", the "Multiplex" instruction is executed.
Depending on the value of the operand "Tag_Number", the value at input "Tag_Value_1" is
copied and assigned to the operand at output "Tag_Result". If the instruction is executed
without errors, the "ENO" and "Tag_Output" enable outputs are set.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1625
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
DEMUX: Demultiplex
Description
You can use the "Demultiplex" instruction to copy the content of the IN input to the selected
output. The number of selectable outputs can be expanded in the instruction box. The outputs
are automatically numbered in the box. Numbering starts at OUT0 and continues consecutively
with each new input. You use the K parameter to define the output to which the content of the
IN input is to be copied. The other outputs are not changed. If the value of the parameter K is
greater than the number of available outputs, then the content of input IN in the parameter
ELSE and the enable output ENO will be assigned to the signal state "0".
The "Demultiplex" instruction can only be executed if the tags in the IN input and in all outputs
have the same data type. The K parameter is an exception, since only integers can be specified
for it.
The ENO enable output is reset if one of the following conditions is fulfilled:
The EN enable input has the signal state "0".
The value of the K parameter is greater than the number of available outputs.
Errors occurred during execution of the instruction.
Parameters
The following table shows the parameters of the "Demultiplex" instruction:
Parameter Declaration Data type Memory area Description
S7-1200 S7-1500
EN Input BOOL BOOL I, Q, M, D, L Enable input
ENO Output BOOL BOOL I, Q, M, D, L Enable output
K Input Integers Integers I, Q, M, D, L, P
or constant
Specifies the
output to which
the input value
(IN) is copied.
If K = 0 =>
Parameter
OUT0
If K = 1 =>
Parameter
OUT1, etc.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1626 System Manual, 01/2013,
Parameter Declaration Data type Memory area Description
S7-1200 S7-1500
IN Input Binary
numbers,
integers,
floating-point
numbers,
strings, TIME,
TOD, DATE,
DT
Binary
numbers,
integers,
floating-point
numbers,
strings, timers,
TOD, LTOD,
DATE, DT,
LDT
I, Q, M, D, L, P
or constant
Input value
OUT0 Output Binary
numbers,
integers,
floating-point
numbers,
strings, TIME,
TOD, DATE,
DT
Binary
numbers,
integers,
floating-point
numbers,
strings, timers,
TOD, LTOD,
DATE, DT,
LDT
I, Q, M, D, L, P First output
OUT1 Output Binary
numbers,
integers,
floating-point
numbers,
strings, TIME,
TOD, DATE,
DT
Binary
numbers,
integers,
floating-point
numbers,
strings, timers,
TOD, LTOD,
DATE, DT,
LDT
I, Q, M, D, L, P Second output
OUTn Output Binary
numbers,
integers,
floating-point
numbers,
strings, TIME,
TOD, DATE,
DT
Binary
numbers,
integers,
floating-point
numbers,
strings, timers,
TOD, LTOD,
DATE, DT,
LDT
I, Q, M, D, L, P Optional
outputs
ELSE Output Binary
numbers,
integers,
floating-point
numbers,
strings, TIME,
TOD, DATE,
DT
Binary
numbers,
integers,
floating-point
numbers,
strings, timers,
TOD, LTOD,
DATE, DT,
LDT
I, Q, M, D, L, P Output to
which the input
value (IN) at K
> n is copied.
You can select the data type for the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on available data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1627
Example
The following example shows how the instruction works:
K OUT0
S
OUT1
ELSE
lN
EN ENO
DWORD
DEMUX
"Tag_Output" "Tag_lnput"
"Tag_Value"
"Tag_Output_0"
"Tag_Output_1"
"Tag_Output_2"
"Tag_Number"
The following tables show how the instruction works using specific operand values:
Table 9-24 Input values of the "Demultiplex" instruction before network execution
Parameters Operand Values
K Tag_Number 1 4
IN Tag_Value DW#16#FFFFFFFF DW#16#003E4A7D
Table 9-25 Output values of the "Demultiplex" instruction after network execution
Parameters Operand Values
OUT0 Tag_Output_0 Unchanged Unchanged
OUT1 Tag_Output_1 DW#16#FFFFFFFF Unchanged
ELSE Tag_Output_2 Unchanged DW#16#003E4A7D
If the "Tag_Input" input has the signal state"1", the "Demultiplex" instruction is executed.
Depending on the value of operand "Tag_Number", the value at the IN input is copied to the
corresponding output.
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
Shift and rotate
SHR: Shift right
Description
You can use the "Shift right" instruction to rotate the content of the operand at the input INbit-
by-bit to the right and query the result at the OUT output. You use the N parameter to specify
the number of bit positions by which the specified value is to be shifted.
When the value at the N parameter is "0", the value at the IN input is copied to the operand at
the OUT output.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1628 System Manual, 01/2013,
When the value at the N parameter is greater than the number of available bit positions, the
operand value at the IN input is shifted by the available number of bit positions to the right.
In the case of unsigned values, the freed bit positions in the left area of the operand are filled
with zeroes when shifting occurs. If the specified value has a sign, the free bit positions are
filled with the signal state of the sign bit.
The following figure show how the content of an operand of integer data type is shifted four bit
positions to the right:
OUT
4 places Sign
bit
These four bits
are lost.
The freed bit positions
are filled by the signal status
of the sign bit.
lN
N
1 1 1 1 1 0 1 0 1 1 1 1 0 0 0 0 1 0 1 0
15... ...8 7... ...0
1 0 1 0 1 1 1 1 0 0 0 0 1 0 1 0
Parameters
The following table shows the parameters of the "Shift right" instruction:
Parameter Declaration Data type Memory area Description
EN Input BOOL I, Q, M, D, L Enable input
ENO Output BOOL I, Q, M, D, L Enable output
IN Input Bit strings,
integers
I, Q, M, D, L or
constant
Value to be shifted.
N Input UINT I, Q, M, D, L or
constant
Number of bit
positions by which
the value is shifted.
OUT Output Bit strings,
integers
I, Q, M, D, L Result of the
instruction
You can select the data type for the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1629
Example
The following example shows how the instruction works:
EN
lN
N
SHR
ENO
OUT
S
WORD
"TagOut" "Tagln"
"TagOut_Value"
"Tag_Number"
"Tagln_Value"
The following table shows how the instruction works using specific operand values:
Parameter Operand Value
IN TagIn_Value 0011 1111 1010 1111
N Tag_Number 3
OUT TagOut_Value 0000 0111 1111 0101
If operand "TagIn" has the signal state "1", the "Shift right" instruction is executed. The content
of operand "TagIn_Value" is shifted three bit positions to the right. The result is sent to the
"TagOut_Value" output. If the instruction is executed without errors, the ENO enable output
has the signal state "1" and the "TagOut" output is set.
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
SHL: Shift left
Description
You can use the "Shift left" instruction to rotate the content of the operand at the IN input bit-
by-bit to the left and query the result at the OUT output. You use the N parameter to specify
the number of bit positions by which the specified value is to be shifted.
When the value at the N parameter is "0", the value at the IN input is copied to the operand at
the OUT output.
When the value at the N parameter is greater than the number of available bit positions, the
operand value at the IN input is shifted by the available number of bit positions to the left.
The bit positions in the right part of the operand freed by shifting are filled with zeros.
The following figure shows how the content of an operand of WORD data type is shifted six
bit positions to the left:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1630 System Manual, 01/2013,
OUT
6 places
The freed bit
positions are filled by
zeros.
These six bits
are lost.
lN
N
0 1 1 0 1 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 1 1
15... ...8 7... ...0
0 0 0 0 1 1 1 1 0 1 0 1 0 1 0 1
Parameter
The following table shows the parameters of the "Shift left" instruction:
Parameter Declaration Data type Memory area Description
EN Input BOOL I, Q, M, D, L Enable input
ENO Output BOOL I, Q, M, D, L Enable output
IN Input Bit strings,
integers
I, Q, M, D, L or
constant
Value to be shifted.
N Input UINT I, Q, M, D, L or
constant
Number of bit
positions by which
the value is shifted.
OUT Output Bit strings,
integers
I, Q, M, D, L Result of the
instruction
You can select the data type for the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1631
Example
The following example shows how the instruction works:
EN
lN
N
SHL
ENO
OUT
S
WORD
"TagOut" "Tagln"
"TagOut_Value"
"Tag_Number"
"Tagln_Value"
The following table shows how the instruction works using specific operand values:
Parameter Operand Value
IN TagIn_Value 0011 1111 1010 1111
N Tag_Number 4
OUT TagOut_Value 1111 1010 1111 0000
If operand "TagIn" has the signal state "1", the "Shift left" instruction is executed. The content
of operand "TagIn_Value" is shifted four bit positions to the left. The result is sent to the
"TagOut_Value" output. If the instruction is executed without errors, the ENO enable output
has the signal state "1" and the "TagOut" output is set.
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
ROR: Rotate right
Description
You can use the "Rotate right" instruction to rotate the content of the operand at the IN input
bit-by-bit to the right and query the result at the OUT output You use the N parameter to specify
the number of bit positions by which the specified value is to be rotated. The bit positions freed
by rotating are filled with the bit positions that are pushed out.
When the value at the N parameter is "0", the value at the IN input is copied to the operand at
the OUT output.
When the value at the N parameter is greater than the number of available bit positions, the
operand value at the IN input is nevertheless rotated by the specified number of bit positions.
The following figure shows how the content of an operand of DWORD data type is rotated
three positions to the right:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1632 System Manual, 01/2013,
OUT
3 places
The signal status of the three
shifted bits are inserted into
the freed places.
lN
N
1 0 1 1 0 1 0 1 0 1 0 0 1 1 1 0 0 0 0 1 0 0 0 1 1 1 1 0 1 0 1 0 1 0 1
31... ...16 15... ...0
1 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 0 1 0 1 0 1 0 1
Parameter
The following table shows the parameters of the "Rotate right" instruction:
Parameter Declaration Data type Memory area Description
EN Input BOOL I, Q, M, D, L Enable input
ENO Output BOOL I, Q, M, D, L Enable output
IN Input Bit strings I, Q, M, D, L or
constant
Value to be
rotated.
N Input UINT I, Q, M, D, L or
constant
Number of bit
positions by which
the value is
rotated.
OUT Output Bit strings I, Q, M, D, L Result of the
instruction
You can select the data type for the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1633
Example
The following example shows how the instruction works:
EN
lN
N
ROR
ENO
OUT
S
WORD
"TagOut" "Tagln"
"TagOut_Value"
"Tag_Number"
"Tagln_Value"
The following table shows how the instruction works using specific operand values:
Parameter Operand Value
IN TagIn_Value 0000 1111 1001 0101
N Tag_Number 5
OUT TagOut_Value 1010 1000 0111 1100
If operand "TagIn" has the signal state "1", the "Rotate right" instruction is executed. The
content of operand "TagIn_Value" is rotated five bit positions to the right. The result is sent to
the "TagOut_Value" output. If the instruction is executed without errors, the ENO enable output
has the signal state "1" and the "TagOut" output is set.
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
ROL: Rotate left
Description
You can use the "Rotate left" instruction to rotate the content of the operand at the IN input bit-
by-bit to the left and query the result at the OUT output You use the N parameter to specify
the number of bit positions by which the specified value is to be rotated. The bit positions freed
by rotating are filled with the bit positions that are pushed out.
When the value at the N parameter is "0", the value at the IN input is copied to the operand at
the OUT output.
When the value at the N parameter is greater than the number of available bit positions, the
operand value at the IN input is nevertheless rotated by the specified number of bit positions.
The following figure shows how the content of an operand of DWORD data type is rotated
three positions to the left:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1634 System Manual, 01/2013,
OUT
3 places
The signal status of the three
shifted bits are inserted into
the freed places.
lN
N
1 0 0 0 0 1 0 1 0 1 0 1 0 1 1 1 0 0 0 0 1 0 0 0 0 1 1 1 1 1 1 1 1 1 1
31... ...16 15... ...0
1 1 1 1 0 0 0 0 1 0 1 0 0 0 0 0 1 0 1 0 1 1 1 1 0 0 0 0 1 1 1 1
Parameter
The following table shows the parameters of the "Rotate left" instruction:
Parameter Declaration Data type Memory area Description
EN Input BOOL I, Q, M, D, L Enable input
ENO Output BOOL I, Q, M, D, L Enable output
IN Input Bit strings I, Q, M, D, L or
constant
Value to be
rotated.
N Input UINT I, Q, M, D, L or
constant
Number of bit
positions by which
the value is
rotated.
OUT Output Bit strings I, Q, M, D, L Result of the
instruction
You can select the data type for the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1635
Example
The following example shows how the instruction works:
EN
lN
N
ROL
ENO
OUT
S
WORD
"TagOut" "Tagln"
"TagOut_Value"
"Tag_Number"
"Tagln_Value"
The following table shows how the instruction works using specific operand values:
Parameter Operand Value
IN TagIn_Value 1010 1000 1111 0110
N Tag_Number 5
OUT TagOut_Value 0001 1110 1101 0101
If the "TagIn" input has the signal state "1", the "Rotate left" instruction is executed. The content
of operand "TagIn_Value" is rotated five bit positions to the left. The result is sent to the
"TagOut_Value" output. If the instruction is executed without errors, the ENO enable output
has the signal state "1" and the "TagOut" output is set.
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
Additional instructions
DRUM: Implement sequencer
Description
The "Implement sequencer" instruction is used to assign the programmed values of the
OUT_VAL parameter of the corresponding step to the programmed output bits (OUT1 to
OUT16) and the output word OUT_WORD. The specific step must thereby satisfy the
conditions of the programmed enable mask on the S_MASK parameter while the instruction
remains at this step. The instruction advances to the next step if the event for the step is true
and the programmed time for the current step elapses, or if the value at the JOG parameter
changes from "0" to "1". The instruction is reset if the signal state on the RESET parameter
changes to "1". The current step is hereby equated to the preset step (DSP).
The amount of time spent on a step is determined by the product of the preset timebase (DTBP)
and the preset counter value (S_PRESET) for each step. At the start of a new step, this
calculated value is loaded into the DCC parameter, which contains the time remaining for the
current step. If, for example the value at the DTBP parameter is "2" and the preset value for
the first step is "100" (100 ms), the DCC parameter has the value "200" (200 ms).
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1636 System Manual, 01/2013,
A step can be programmed with a timer value, an event, or both. Steps that have an event bit
and the timer value "0" advance to the next step as soon as the signal state of the event bit is
"1". Steps that are programmed only with a timer value start the time immediately. Steps that
are programmed with an event bit and a timer value greater than "0" start the time when the
signal state of the event bit is "1". The event bits are initialized with a signal state of "1".
When the sequencer is on the last programmed step (LST_STEP) and the time for this step
has expired, the signal state on the Q parameter is set to "1"; otherwise it is set to "0". When
the parameter Q is set, the instruction remains on the step until it is reset.
In the configurable mask (S_MASK) you can selected the separate bits in the output word
(OUT_WORD) and set or reset the output bits (OUT1 to OUT16) by means of the output values
(OUT_VAL). If a bit of the configurable mask is in the signal state "1", the value OUT_VAL sets
or resets the corresponding bit. If the signal state of a bit of the configurable mask is "0", the
corresponding bit is left unchanged. All the bits of the configurable mask for all 16 steps are
initialized with a signal state of "1".
The output bit on the OUT1 parameter corresponds to the least significant bit of the output
word (OUT_WORD). The output bit on the OUT16 parameter corresponds to the most
significant bit of the output word (OUT_WORD).
When you insert the instruction in the program, the "Call options" dialog opens in which you
can specify whether the IEC counter is stored in its own data block (single instance) or as a
local tag (multiple instance) in the block interface. If you create a separate data block, you will
find it in the project tree in the "Program resources" folder under "Program blocks > System
blocks". For additional information on this topic, refer to "See also".
Parameters
The following table shows the parameters of the "Implement sequencer" instruction:
Parameter Declaration Data type Memory area Description
EN Input BOOL I, Q, M, D, L Enable input
ENO Output BOOL I, Q, M, D, L Enable output
RESET Input BOOL I, Q, M, D, L or
constant
A signal state of
"1" indicates a
reset condition.
JOG Input BOOL I, Q, M, D, L or
constant
When the signal
state changes
from "0" to "1", the
instruction
advances to the
next step.
DRUM_EN Input BOOL I, Q, M, D, L or
constant
A signal state of
"1" allows the
sequencer to
advance based on
the event and time
criteria.
LST_STEP Input BYTE I, Q, M, D, L or
constant
Step number of
the last step
programmed.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1637
Parameter Declaration Data type Memory area Description
EVENT1 Input BOOL I, Q, M, D, L or
constant
Event bit 1; initial
signal state is "1".
EVENT2 Input BOOL I, Q, M, D, L or
constant
Event bit 2; initial
signal state is "1".
EVENT3 Input BOOL I, Q, M, D, L or
constant
Event bit 3; initial
signal state is "1".
EVENT4 Input BOOL I, Q, M, D, L or
constant
Event bit 4; initial
signal state is "1".
EVENT5 Input BOOL I, Q, M, D, L or
constant
Event bit 5; initial
signal state is "1".
EVENT6 Input BOOL I, Q, M, D, L or
constant
Event bit 6; initial
signal state is "1".
EVENT7 Input BOOL I, Q, M, D, L or
constant
Event bit 7; initial
signal state is "1".
EVENT8 Input BOOL I, Q, M, D, L or
constant
Event bit 8; initial
signal state is "1".
EVENT9 Input BOOL I, Q, M, D, L or
constant
Event bit 9; initial
signal state is "1".
EVENT10 Input BOOL I, Q, M, D, L or
constant
Event bit 10; initial
signal state is "1".
EVENT11 Input BOOL I, Q, M, D, L or
constant
Event bit 11; initial
signal state is "1".
EVENT12 Input BOOL I, Q, M, D, L or
constant
Event bit 12; initial
signal state is "1".
EVENT13 Input BOOL I, Q, M, D, L or
constant
Event bit 13; initial
signal state is "1".
EVENT14 Input BOOL I, Q, M, D, L or
constant
Event bit 14; initial
signal state is "1".
EVENT15 Input BOOL I, Q, M, D, L or
constant
Event bit 15; initial
signal state is "1".
EVENT16 Input BOOL I, Q, M, D, L or
constant
Event bit 16; initial
signal state is "1".
OUT1 Output BOOL I, Q, M, D, L Output bit 1
OUT2 Output BOOL I, Q, M, D, L Output bit 2
OUT3 Output BOOL I, Q, M, D, L Output bit 3
OUT4 Output BOOL I, Q, M, D, L Output bit 4
OUT5 Output BOOL I, Q, M, D, L Output bit 5
OUT6 Output BOOL I, Q, M, D, L Output bit 6
OUT7 Output BOOL I, Q, M, D, L Output bit 7
OUT8 Output BOOL I, Q, M, D, L Output bit 8
OUT9 Output BOOL I, Q, M, D, L Output bit 9
OUT10 Output BOOL I, Q, M, D, L Output bit 10
OUT11 Output BOOL I, Q, M, D, L Output bit 11
OUT12 Output BOOL I, Q, M, D, L Output bit 12
OUT13 Output BOOL I, Q, M, D, L Output bit 13
OUT14 Output BOOL I, Q, M, D, L Output bit 14
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1638 System Manual, 01/2013,
Parameter Declaration Data type Memory area Description
OUT15 Output BOOL I, Q, M, D, L Output bit 15
OUT16 Output BOOL I, Q, M, D, L Output bit 16
Q Output BOOL I, Q, M, D, L A signal state of
"1" indicates that
the time for the
last step has
elapsed.
OUT_WORD Output WORD I, Q, M, D, L, P Word address to
which the
sequencer writes
the output values.
ERR_CODE Output WORD I, Q, M, D, L, P Error information
JOG_HIS Static BOOL I, Q, M, D, L JOG parameter
history bit
EOD Static BOOL I, Q, M, D, L A signal state of
"1" indicates that
the time for the
last step has
elapsed.
DSP Static BYTE I, Q, M, D, L, P Preset step of the
sequencer
DSC Static BYTE I, Q, M, D, L, P Current step of the
sequencer
DCC Static DWORD I, Q, M, D, L, P Current numerical
value of the
sequencer
DTBP Static WORD I, Q, M, D, L, P Preset timebase
of the sequencer
PREV_TIME Static DWORD I, Q, M, D, L or
constant
Previous system
time
S_PRESET Static ARRAY of WORD I, Q, M, D, L Count preset for
each step [1 to 16]
where 1 count = 1
ms.
OUT_VAL Static ARRAY of BOOL I, Q, M, D, L Output values for
each step [1 to 16,
0 to 15].
S_MASK Static ARRAY of BOOL I, Q, M, D, L Configurable
mask for each
step [1 to 16,
0 to 15]. Initial
signal states are
"1".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1639
Parameter ERR_CODE
The following table shows the meaning of the values of the ERR_CODE parameter:
ERR_CODE* Explanation
W#16#0000 No error
W#16#000B The value at the LST_STEP parameter is less than 1 or greater than 16.
W#16#000C The value at the DSC parameter is less than 1 or greater than the value at
the LST_STEP parameter.
W#16#000D The value at the DSP parameter is less than 1 or greater than the value at
the LST_STEP parameter.
*The error codes can be displayed as integer or hexadecimal value in the program editor. For additional information on
toggling display formats, refer to "See also".
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
DCAT: Discrete control-timer alarm
Description
The instruction "Discrete control-timer alarm" is used to accumulate the time from the point at
which the CMD parameter issued the command to open or close. The time is accumulated
until the preset time (PT) is exceeded or the information is received that the device was opened
or closed (O_FB or C_FB) within the specified time. If the preset time is exceeded before the
information on the opening or closing of the device is received, the corresponding alarm is
activated. If the signal state on the command input changes state before the preset time, the
time is restarted.
When you insert the instruction in the program, the "Call options" dialog opens in which you
can specify whether the IEC timer is stored in its own data block (single instance) or as a local
tag (multiple instance) in the block interface. If you create a separate data block, you will find
it in the project tree in the "Program resources" folder under "Program blocks > System blocks".
For additional information on this topic, refer to "See also".
The "Discrete control-timer alarm" instruction has the following reactions to the input conditions:
When the signal state of the CMD parameter changes from "0" to "1", the signal states of
the parameters Q, CMD_HIS, ET (only if ET < PT), OA and CA are influenced as follows:
The parameters Q and CMD_HIS are set to "1".
The parameters ET, OA and CA are reset to "0".
When the signal state on the parameter CMD changes from "1" to "0", the parameters Q,
ET (only if ET < PT), OA, CA and CMD_HIS are reset to "0".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1640 System Manual, 01/2013,
When the signal state of the parameters CMD and CMD_HIS is "1" and the parameter O_FB
is set to "0", the time difference (ms) since the last execution of the instruction is added to
the value at the parameter ET. If the value of the parameter ET exceeds the value of the
parameter PT, the signal state on the parameter OA is set to "1". If the value of the
parameter ET does not exceed the value of the parameter PT, the signal state on the
parameter OA is reset to "0". The value at the parameter CMD_HIS is reset to the value of
the parameter CMD.
If the signal state of the parameters CMD, CMD_HIS and O_FB are set to "1" and the
parameter C_FB has the value "0", the signal state of the parameter OA is set to "0". The
value of the parameter ET is set to the value of the parameter PT. If the signal state of the
parameter O_FB changes to "0", the alarm is set the next time the instruction is executed.
The value of the parameter CMD_HIS is set to the value of the parameter CMD.
If the parameters CMD, CMD_HIS and C_FB have the value "0", the time difference (ms)
since the last execution of the instruction is added to the value of the parameter ET. If the
value of the parameter ET exceeds the value of the parameter PT, the signal state of the
parameter CA is reset to "1". If the value at the parameter PT is not exceeded, the parameter
CA has the signal state "0". The value of the parameter CMD_HIS is set to the value of the
parameter CMD.
If the parameters CMD, CMD_HIS and O_FB have the signal state "0" and the parameter
C_FB is set to "1", the parameter CA is set to "0". The value of the parameter ET is set to
the value of the parameter PT. If the signal state of the parameter C_FB changes to "0",
the alarm is set the next time the instruction is executed. The value of the parameter
CMD_HIS is set to the value of the parameter CMD.
If the parameters O_FB and C_FB simultaneously have the signal state "1", the signal states
of both alarm outputs are set to "1".
The "Discrete control-timer alarm" instruction has no error information.
Parameters
The following table shows the parameters of the "Discrete control-timer alarm" instruction:
Parameter Declaration Data type Memory area Description
EN Input BOOL I, Q, M, D, L Enable input
ENO Output BOOL I, Q, M, D, L Enable output
CMD Input BOOL I, Q, M, D, L or constant A signal state of "0"
indicates a "close"
command.
A signal state of "1"
indicates an "open"
command.
O_FB Input BOOL I, Q, M, D, L or constant Feedback input when
opening
C_FB Input BOOL I, Q, M, D, L or constant Feedback input when
closing
Q Output BOOL I, Q, M, D, L Shows the status of the
parameter CMD
OA Output BOOL I, Q, M, D, L Alarm output when opening
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1641
Parameter Declaration Data type Memory area Description
CA Output BOOL I, Q, M, D, L Alarm output when closing
ET Static DINT D, L Currently elapsed time,
where 1 count = 1 ms
PT Static DINT D, L Preset timer value, where 1
count = 1 ms
PREV_TIME Static DWORD D, L Previous system time
CMD_HIS Static BOOL D, L CMD history bit
For additional information on valid data types, refer to "See also".
Example
In the following example the parameter CMD changes from "0" to "1". After the execution of
the instruction the parameter Q is set to "1" and the two alarm outputs OA and CA have the
signal state "0". The parameter CMD_HIS of the instance data block is set to the signal state
"1" and the parameter ET is reset to "0".
Note
You can initialize static parameters in the data block.
"Tag_lnput_CMD"
"Tag_Output_Q"
"Tag_Output_OA"
"Tag_Output_CA"
"Tag_lnput_O_FB"
"Tag_lnput_C_FB"
"Tagln" "TagOut"
"DCAT_DB"
EN
CMD
O_FB
C_FB
ENO
Q
OA
CA
DCAT
The following tables show how the instruction works using specific values.
Before processing
In this example, the following values are used for the input and output parameters:
Parameter Operand Value
CMD Tag_Input_CMD TRUE
O_FB Tag_Input_O_FB FALSE
C_FB Tag_Input_C_FB FALSE
Q Tag_Output_Q FALSE
OA Tag_Output_OA FALSE
CA Tag_Output_CA FALSE
The following values are saved in the instance data block "DCAT_DB" of the instruction:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1642 System Manual, 01/2013,
Parameter Address Value
ET DBD4 L#12
PT DBD8 L#222
CMD_HIS DBX16.0 FALSE
After processing
The following values are written to the output parameters after the instruction has been
executed:
Parameter Operand Value
Q Tag_Output_Q TRUE
OA Tag_Output_OA FALSE
CA Tag_Output_CA FALSE
The following values are saved in the instance data block "DCAT_DB" of the instruction:
Parameter Address Value
ET DBD4 L#0
CMD_HIS DBX16.0 TRUE
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
MCAT: Motor control-timer alarm
Description
The instruction "Motor control-timer alarm" is used to accumulate the time from the point of
time from which the one of the command inputs (opening or closing) is switched on. The time
is accumulated until the preset time is exceeded or the relevant feedback input indicates that
the device has executed the requested operation within the specified time. If the preset time
is exceeded before the feedback is received, the corresponding alarm is triggered.
When you insert the instruction in the program, the "Call options" dialog opens in which you
can specify whether the IEC timer is stored in its own data block (single instance) or as a local
tag (multiple instance) in the block interface. If you create a separate data block, you will find
it in the project tree in the "Program resources" folder under "Program blocks > System blocks".
For additional information on this topic, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1643
Execution of the "Motor control-timer alarm" instruction
The following table shows the reactions of the instruction "Motor control-timer alarm" to the
various input conditions:
Input parameters Output parameters
ET O_H
IS
C_H
IS
O_C
MD
C_C
MD
S_C
MD
O_F
B
C_F
B
OO CO OA CA ET O_H
IS
C_H
IS
Q Status
X 1 1 X X X X X 0 0 1 1 PT 0 0 0 Alarm
X X X X X X 1 1 0 0 1 1 PT 0 0 0 Alarm
X X X X X 1 X X 0 0 0 0 X 0 0 1 Stop
X X X 1 1 X X X 0 0 0 0 X 0 0 1 Stop
X 0 X 1 0 0 X X 1 0 0 0 0 1 0 1 Start
opening
<PT 1 0 X 0 0 0 X 1 0 0 0 INC 1 0 1 Open
X 1 0 X 0 0 1 0 0 0 0 0 PT 1 0 1 Opened
>=P
T
1 0 X 0 0 0 X 0 0 1 0 PT 1 0 0 Opening
alarm
X X 0 0 1 0 X X 0 1 0 0 0 0 1 1 Start closing
<PT 0 1 0 X 0 X 0 0 1 0 0 INC 0 1 1 Close
X 0 1 0 X 0 0 1 0 0 0 0 PT 0 1 1 Closed
>=P
T
0 1 0 X 0 X 0 0 0 0 1 PT 0 1 0 Closing
alarm
X 0 0 0 0 0 X X 0 0 0 0 X 0 0 1 Stopped
Legend:
INC Add the time difference (ms) since the last processing of the FB to ET
PT PT is set to the same value as ET
X Cannot be used
<PT ET < PT
>=PT ET >= PT
If the input parameters O_HIS and C_HIS both have the signal state "1", they are immediately set to the signal state "0". In
this case, the last line in the table (X) mentioned above is valid. Because it is therefore not possible to check whether the
input parameters O_HIS and C_HIS have the signal state "1", the output parameters are set as follows in this case:
OO = FALSE
CO = FALSE
OA = FALSE
CA = FALSE
ET = PT
Q = TRUE
The "Motor control-timer alarm" instruction has no error information.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1644 System Manual, 01/2013,
Parameters
The following table shows the reactions of the instruction "Motor control-timer alarm":
Parameter Declaration Data type Memory area Description
EN Input BOOL I, Q, M, D, L Enable input
ENO Output BOOL I, Q, M, D, L Enable output
O_CMD Input BOOL I, Q, M, D, L or
constant
"Open" command
input
C_CMD Input BOOL I, Q, M, D, L or
constant
"Close" command
input
S_CMD Input BOOL I, Q, M, D, L or
constant
"Stop" command
input
O_FB Input BOOL I, Q, M, D, L or
constant
Feedback input
when opening
C_FB Input BOOL I, Q, M, D, L or
constant
Feedback input
when closing
OO Output BOOL I, Q, M, D, L "Open" output
CO Output BOOL I, Q, M, D, L "Close" output
OA Output BOOL I, Q, M, D, L Alarm output
when opening
CA Output BOOL I, Q, M, D, L Alarm output
when closing
Q Output BOOL I, Q, M, D, L A signal state of
"0" indicates an
error condition.
ET Static DINT D, L Currently elapsed
time, where 1
count = 1 ms
PT Static DINT D, L Preset timer
value, where 1
count = 1 ms
PREV_TIME Static DWORD D, L Previous system
time
O_HIS Static BOOL D, L "Open" history bit
C_HIS Static BOOL D, L "Close" history bit
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
Note
You can initialize static parameters in the data block.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1645
"MCAT_DB"
EN
O_CMD
C_CMD
S_CMD
O_FB
C_FB
ENO
OO
CO
OA
CA
Q
MCAT
"Tagln" "TagOut"
"Tag_lnput_O_CMD"
"Tag_lnput_C_CMD"
"Tag_lnput_S_CMD"
"Tag_lnput_O_FB"
"Tag_lnput_C_FB"
"Tag_OutputOpen"
"Tag_OutputClosed"
"Tag_Output_OA"
"Tag_Output_CA"
"Tag_Output_Q"
The following table shows how the instruction works using specific operand values:
Before processing
In this example, the following values are used for the input and output parameters:
Parameter Operand Value
O_CMD Tag_Input_O_CMD TRUE
C_CMD Tag_Input_C_CMD FALSE
S_CMD Tag_Input_S_CMD FALSE
O_FB Tag_Input_O_FB FALSE
C_FB Tag_Input_C_FB FALSE
OO Tag_OutputOpen FALSE
CO Tag_OutputClosed FALSE
OA Tag_Output_OA FALSE
CA Tag_Output_CA FALSE
Q Tag_Output_Q FALSE
The following values are saved in the instance data block "MCAT_DB" of the instruction:
Parameter Address Value
ET DBD4 L#2
PT DBD8 L#22
O_HIS DBX16.0 TRUE
C_HIS DBX16.1 FALSE
After processing
The following values are written to the output parameters after the instruction has been
executed:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1646 System Manual, 01/2013,
Parameter Operand Value
OO Tag_OutputOpen TRUE
CO Tag_OutputClosed FALSE
OA Tag_Output_OA FALSE
CA Tag_Output_CA FALSE
Q Tag_Output_Q TRUE
The following values are saved in the instance data block "MCAT_DB" of the instruction:
Parameter Address Value
ET DBD4 L#0
O_HIS DBX16.0 TRUE
CMD_HIS DBX16.1 FALSE
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
IMC: Compare input bits with the bits of a mask
Description
The instruction "Compare input bits with the bits of a mask" is used to compare the signal state
of up to 16 programmed input bits (IN_BIT0 to IN_BIT15) with the corresponding bits of a mask.
Up to 16 steps with masks can be programmed. The value of the IN_BIT0 parameter is
compared with the value of the mask CMP_VAL[x,0], with "x" indicating the step number. On
the CMP_STEP parameter, you specify the step number of the mask that is used for the
comparison. All programmed values are compared in the same manner. Unprogrammed input
bits or unprogrammed bits of the mask have a default signal state FALSE.
If a match is found in the comparison, the signal state of the OUT parameter is set to "1".
Otherwise, the OUT parameter is set to "0".
If the value of CMP_STEP parameter is greater than 15, the instruction is not executed. An
error message is output at the ERR_CODE parameter.
When you insert the instruction in the program, the "Call options" dialog opens in which you
can specify whether the instruction data will be stored in its own data block (single instance)
or as a local tag (multi-instance) in the block interface. If you create a separate data block, you
will find it in the project tree in the "Program resources" folder under "Program blocks > System
blocks". For additional information on this topic, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1647
Parameter
The following table shows the parameters of the "Compare input bits with the bits of a mask"
instruction:
Paramete
r
Declarati
on
Data type Memory area Description
EN Input BOOL I, Q, M, D, L Enable input
ENO Output BOOL I, Q, M, D, L Enable output
IN_BIT0 Input BOOL I, Q, M, D, L or constant Input bit 0 to be compared with
bit 0 of the mask.
IN_BIT1 Input BOOL I, Q, M, D, L or constant Input bit 1 to be compared with
bit 1 of the mask.
IN_BIT2 Input BOOL I, Q, M, D, L or constant Input bit 2 to be compared with
bit 2 of the mask.
IN_BIT3 Input BOOL I, Q, M, D, L or constant Input bit 3 to be compared with
bit 3 of the mask.
IN_BIT4 Input BOOL I, Q, M, D, L or constant Input bit 4 to be compared with
bit 4 of the mask.
IN_BIT5 Input BOOL I, Q, M, D, L or constant Input bit 5 to be compared with
bit 5 of the mask.
IN_BIT6 Input BOOL I, Q, M, D, L or constant Input bit 6 to be compared with
bit 6 of the mask.
IN_BIT7 Input BOOL I, Q, M, D, L or constant Input bit 7 to be compared with
bit 7 of the mask.
IN_BIT8 Input BOOL I, Q, M, D, L or constant Input bit 8 to be compared with
bit 8 of the mask.
IN_BIT9 Input BOOL I, Q, M, D, L or constant Input bit 9 to be compared with
bit 9 of the mask.
IN_BIT10 Input BOOL I, Q, M, D, L or constant Input bit 10 to be compared
with bit 10 of the mask.
IN_BIT11 Input BOOL I, Q, M, D, L or constant Input bit 11 to be compared
with bit 11 of the mask.
IN_BIT12 Input BOOL I, Q, M, D, L or constant Input bit 12 to be compared
with bit 12 of the mask.
IN_BIT13 Input BOOL I, Q, M, D, L or constant Input bit 13 to be compared
with bit 13 of the mask.
IN_BIT14 Input BOOL I, Q, M, D, L or constant Input bit 14 to be compared
with bit 14 of the mask.
IN_BIT15 Input BOOL I, Q, M, D, L or constant Input bit 15 to be compared
with bit 15 of the mask.
CMP_ST
EP
Input BYTE I, Q, M, D, L, P or constant The step number of the mask
used for the comparison.
OUT Output BOOL I, Q, M, D, L A signal state of "1" indicates
that a match was found.
A signal state of "0" indicates
that a match was found.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1648 System Manual, 01/2013,
Paramete
r
Declarati
on
Data type Memory area Description
ERR_CO
DE
Output WORD I, Q, M, D, L, P Error information
CMP_VA
L
Static ARRAY OF
WORD
I, Q, M, D, L Comparison masks [0 to 15, 0
to 15]: The first number of the
index is the step number and
the second number is the bit
number of the mask.
For additional information on valid data types, refer to "See also".
Parameter ERR_CODE
The following table shows the meaning of the values of the ERR_CODE parameter:
Error code*
(W#16#...)
Explanation
0000 No error
000A The value at the CMP_STEP parameter is greater than 15.
*The error codes can be displayed as integer or hexadecimal value in the program editor. For additional information on
toggling display formats, refer to "See also".
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
SMC: Compare scan matrix
Description
The "Compare scan matrix" instruction is used to compare the signal state of up to 16
programmed input bits (IN_BIT0 to IN_BIT15) with the corresponding bits of the comparison
masks for each step. Processing starts at step 1 and is continued until the last programmed
step (LAST) or until a match is found. The input bit of the IN_BIT0 parameter is compared with
the value of the mask CMP_VAL[x,0], with "x" indicating the step number. All programmed
values are compared in the same manner. If a match is found the signal state of the OUT
parameter is set to "1" and the step number with the matching mask is written in the OUT_STEP
parameter. Unprogrammed input bits or unprogrammed bits of the mask have a default signal
state of "FALSE". If more than one step has a matching mask, only the first one found is
indicated in the OUT_STEP parameter. If no match is found, the signal state of the OUT
parameter is set to "0". In this case the value at the OUT_STEP parameter is greater by "1"
than the value at the LAST parameter.
When you insert the instruction in the program, the "Call options" dialog opens in which you
can specify whether the instruction data will be stored in its own data block (single instance)
or as a local tag (multi-instance) in the block interface. If you create a separate data block, you
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1649
will find it in the project tree in the "Program resources" folder under "Program blocks > System
blocks". For additional information on this topic, refer to "See also".
Parameter
The following table shows the parameters of the "Compare scan matrix" instruction:
Paramete
r
Declarati
on
Data type Memory area Description
EN Input BOOL I, Q, M, D, L Enable input
ENO Output BOOL I, Q, M, D, L Enable output
IN_BIT0 Input BOOL I, Q, M, D, L or constant Input bit 0 to be compared with
bit 0 of the mask.
IN_BIT1 Input BOOL I, Q, M, D, L or constant Input bit 1 to be compared with
bit 1 of the mask.
IN_BIT2 Input BOOL I, Q, M, D, L or constant Input bit 2 to be compared with
bit 2 of the mask.
IN_BIT3 Input BOOL I, Q, M, D, L or constant Input bit 3 to be compared with
bit 3 of the mask.
IN_BIT4 Input BOOL I, Q, M, D, L or constant Input bit 4 to be compared with
bit 4 of the mask.
IN_BIT5 Input BOOL I, Q, M, D, L or constant Input bit 5 to be compared with
bit 5 of the mask.
IN_BIT6 Input BOOL I, Q, M, D, L or constant Input bit 6 to be compared with
bit 6 of the mask.
IN_BIT7 Input BOOL I, Q, M, D, L or constant Input bit 7 to be compared with
bit 7 of the mask.
IN_BIT8 Input BOOL I, Q, M, D, L or constant Input bit 8 to be compared with
bit 8 of the mask.
IN_BIT9 Input BOOL I, Q, M, D, L or constant Input bit 9 to be compared with
bit 9 of the mask.
IN_BIT10 Input BOOL I, Q, M, D, L or constant Input bit 10 to be compared
with bit 10 of the mask.
IN_BIT11 Input BOOL I, Q, M, D, L or constant Input bit 11 to be compared
with bit 11 of the mask.
IN_BIT12 Input BOOL I, Q, M, D, L or constant Input bit 12 to be compared
with bit 12 of the mask.
IN_BIT13 Input BOOL I, Q, M, D, L or constant Input bit 13 to be compared
with bit 13 of the mask.
IN_BIT14 Input BOOL I, Q, M, D, L or constant Input bit 14 to be compared
with bit 14 of the mask.
IN_BIT15 Input BOOL I, Q, M, D, L or constant Input bit 15 to be compared
with bit 15 of the mask.
OUT Output BOOL I, Q, M, D, L A signal state of "1" indicates
that a match was found.
A signal state of "0" indicates
that no match was found.
ERR_CO
DE
Output WORD I, Q, M, D, L, P Error information
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1650 System Manual, 01/2013,
Paramete
r
Declarati
on
Data type Memory area Description
OUT_ST
EP
Output BYTE I, Q, M, D, L, P Contains the step number with
the matching mask, or the
step number which is greater
by "1" than the value at the
LAST parameter, provided no
match is found.
LAST Static BYTE I, Q, M, D, L, P Specifies the step number of
the last step to be scanned for
a matching mask.
CMP_VA
L
Static ARRAY OF
WORD
I, Q, M, D, L Comparison masks [0 to 15, 0
to 15]: The first number of the
index is the step number and
the second number is the bit
number of the mask.
For additional information on valid data types, refer to "See also".
Parameter ERR_CODE
The following table shows the meaning of the values of the ERR_CODE parameter:
Error code*
(W#16#...)
Explanation
0000 No error
000E The value at the LAST parameter is greater than 15.
*The error codes can be displayed as integer or hexadecimal value in the program editor. For additional information on
toggling display formats, refer to "See also".
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
LEAD_LAG: Lead and lag algorithm
Description
The "Lead and lag algorithm" instruction is used to process signals with an analog tag. The
gain value at the GAIN parameter must be greater than zero. The result of the instruction "Lead
and lag algorithm" is calculated using the following equation:
OUT =
LG_TlME
LG_TlME + SAMPLE_T
LD_TlME + SAMPLE_T
LG_TlME + SAMPLE_T
lN - GAlN PREV_OUT + GAlN
LD_TlME
LG_TlME + SAMPLE_T
When the value of the GAIN parameter is less than or equal to zero, the calculation is not
performed and an error information is output on the ERR_CODE parameter.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1651
You can use the "Lead and lag algorithm" instruction in conjunction with loops as a
compensator in dynamic feed-forward control. The instruction consists of two operations. The
"Lead" operation shifts the phase of output OUT so that the output leads the input. The "Lag"
operation, on the other hand, shifts the output so that the output lags behind the input. Because
the "Lag" operation is equivalent to an integration, it can be used as a noise suppressor or as
a low-pass filter. The "Lead" operation is equivalent to a differentiation and can therefore be
used as a high-pass filter. The two operations together (Lead and Lag) result in the output
phase lagging behind the the input at lower frequencies and leading it at higher frequencies.
This means that the "Lead and lag algorithm" instruction can be used as a band pass filter.
When you insert the instruction in the program, the "Call options" dialog opens in which you
can specify whether the instruction data will be stored in its own data block (single instance)
or as a local tag (multi-instance) in the block interface. If you create a separate data block, you
will find it in the project tree in the "Program resources" folder under "Program blocks > System
blocks". For additional information on this topic, refer to "See also".
Parameter
The following table shows the parameters of the "Lead and lag algorithm" instruction:
Parameter Declaration Data type Memory area Description
EN Input BOOL I, Q, M, D, L Enable input
ENO Output BOOL I, Q, M, D, L Enable output
IN Input REAL I, Q, M, D, L, P or
constant
The input value of
the current sample
time (cycle time) to
be processed.
Constants can
also be specified
on the IN
parameter.
SAMPLE_T Input INT I, Q, M, D, L, P or
constant
Sample time
Constants can
also be specified
on the SAMPLE_T
parameter.
OUT Output REAL I, Q, M, D, L Result of the
instruction
ERR_CODE Output WORD I, Q, M, D, L Error information
LD_TIME Static REAL I, Q, M, D, L, P or
constant
Lead time in the
same unit as
sample time.
LG_TIME Static REAL I, Q, M, D, L, P or
constant
Lag time in in the
same unit as
sample time.
GAIN Static REAL I, Q, M, D, L, P or
constant
Gain as % / % (the
ratio of the change
in output to a
change in input as
a steady state).
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1652 System Manual, 01/2013,
Parameter Declaration Data type Memory area Description
PREV_IN Static REAL I, Q, M, D, L, P or
constant
Previous input
PREV_OUT Static REAL I, Q, M, D, L, P or
constant
Previous output
For additional information on valid data types, refer to "See also".
Parameter ERR_CODE
The following table shows the meaning of the values of the ERR_CODE parameter:
Error code*
(W#16#...)
Explanation
0000 No error
0009 The value at the GAIN parameter is less than or equal to zero.
*The error codes can be displayed as integer or hexadecimal value in the program editor. For additional information on
toggling display formats, refer to "See also".
Example
The following example shows how the instruction works:
Note
You can initialize static parameters in the data block.
"LEAD_LAG_DB"
LEAD_LAG
EN ENO
lN
OUT
ERR_CODE SAMPLE_T
"Tag_lnput"
"Tag_lnput_SAMPLE_T" "Tag_ErrorCode"
"Tag_Output_Result"
"Tagln" "TagOut"
The following table shows how the instruction works using specific operand values:
Before processing
In this example the following values are used for the input parameters:
Parameter Operand Value
IN Tag_Input 2.0
SAMPLE_T Tag_InputSampleTime 10
The following values are saved in the instance data block "LEAD_LAG_DB" of the instruction:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1653
Parameter Address Value
LD_TIME DBD12 2.0
LG_TIME DBD16 2.0
GAIN DBD20 1.0
PREV_IN DBD24 6.0
PREV_OUT DBD28 6.0
After processing
The following values are written to the output parameters after the instruction has been
executed:
Parameter Operand Value
OUT Tag_Output_Result 2.0
The following values are saved in the instance data block "LEAD_LAD_DB" of the instruction:
Parameter Operand Value
PREV_IN DBD24 2.0
PREV_OUT DBD28 2.0
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
SEG: Create bit pattern for seven-segment display
Description
The instruction "Create bit pattern for seven-segment display" is used to convert each of the
four hexadecimal digits of the specified source word (IN) into an equivalent bit pattern for a
seven-segment display. The result of the instruction is output in the double word on the OUT
parameter.
The following relation exists between the hexadecimal digits and the assignment of the 7
segments (a, b, c, d, e, f, g):
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1654 System Manual, 01/2013,
Input digit
(Binary)
Assignment of
the segments
g f e d c b a
Display
(Hexadecimal)
Seven-segment display
0000 00111111 0
0001 00000110 1
0010 01011011 2
0011 01001111 3
0100 01100110 4
0101 01101101 5
0110 01111101 6
0111 00000111 7
1000 01111111 8
1001 01100111 9
1010 01110111 A
1011 01111100 B
1100 00111001 C
1101 01011110 D
1110 01111001 E
1111 01110001 F
Parameter
The following table shows the parameters of the "Create bit pattern for seven-segment display"
instruction:
Parameter Declaration Data type Memory area Description
EN Input BOOL I, Q, M, D, L Enable input
ENO Output BOOL I, Q, M, D, L Enable output
IN Input WORD I, Q, M, D, L, P or
constant
Source word with
four hexadecimal
digits
OUT Output DWORD I, Q, M, D, L, P Bit pattern for the
seven-segment
display
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1655
Example
The following example shows how the instruction works:
SEG
EN ENO
OUT
lN
"Tagln" "TagOut"
"Tag_lnput" "Tag_Output"
The following table shows how the instruction works using specific operand values:
Parameter Operand Value
Hexadecimal Binary
IN Tag_Input W#16#1234 0001 0010 0011 0100
OUT Tag_Output DW#16065B4F66 000 00110 0101 1011 0100
1111 0110 0110
Display: 1234
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
BCDCPL: Create tens complement
Description
The "Create tens complement" instruction is used to create the tens complement of a seven-
digit BCD number specified on the IN parameter. This instruction uses the following
mathematical formula to calculate:
10000000 (as BCD)
7-digit BCD value
----------------------------------------
Tens complement (as BCD)
Parameters
The following table shows the parameters of the "Create tens complement" instruction:
Parameter Declaration Data type Memory area Description
EN Input BOOL I, Q, M, D, L Enable input
ENO Output BOOL I, Q, M, D, L Enable output
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1656 System Manual, 01/2013,
Parameter Declaration Data type Memory area Description
IN Input DWORD I, Q, M, D, L, P or
constant
7-digit BCD
number
ERR_CODE Output DWORD I, Q, M, D, L, P Result of the
instruction
Example
The following example shows how the instruction works:
EN ENO
lN ERR_CODE
"Tag_lnput" "Tag_Output"
"Tagln" "TagOut"
BCDCPL
The following table shows how the instruction functions using specific values:
Parameter Operand Value*
IN Tag_Input DW#16#01234567
ERR_CODE Tag_Output DW#16#08765433
*The error codes can be displayed as integer or hexadecimal value in the program editor. For additional
information on toggling display formats, refer to "See also".
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
BITSUM: Count number of set bits
Description
The "Count number of set bits" instruction is used to count the number of bits of an operand
that is set to the signal state "1". The operand whose bits are to be counted is specified on the
IN parameter. The result of the instruction is output on the RET_VAL parameter.
Parameters
The following table shows the parameters of the "Count number of set bits" instruction:
Parameter Declaration Data type Memory area Description
EN Input BOOL I, Q, M, D, L Enable input
ENO Output BOOL I, Q, M, D, L Enable output
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1657
Parameter Declaration Data type Memory area Description
IN Input DWORD I, Q, M, D, L, P or
constant
Operand whose
set bits are
counted
RET_VAL Output INT I, Q, M, D, L, P Number of bits to
be set
Example
The following example shows how the instruction works:
BlTSUM
EN ENO
lN RET_VAL
"Tag_lnput" "Tag_Output"
"Tagln" "TagOut"
The following table shows how the instruction functions using specific values:
Parameter Operand Value*
IN Tag_Input DW#16#12345678
RET_VAL Tag_Output W#16#000D (13 Bits)
*The error codes can be displayed as integer or hexadecimal value in the program editor. For additional
information on toggling display formats, refer to "See also".
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
9.8.2.2 FBD
Bit logic operations
&: AND logic operation
Description
You can use the instruction "AND logic operation" to query the signal states of two or more
specified operands and evaluate them according to the AND truth table.
If the signal state of all the operands is "1", then the condition is fulfilled and the instruction
returns the result "1". If the signal state of one of the operands is "0", then the condition is not
fulfilled and the instruction generates the result "0".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1658 System Manual, 01/2013,
Parameters
The following table shows the parameters of the instruction "AND logic operation":
Parameter Declaration Data type Memory area Description
S7-1200 S7-1500
<Operand> Input BOOL I, Q, M, D, L I, Q, M, D, L, T,
C
The operand
indicates the
bit whose
signal state will
be queried.
Example
The following example shows how the instruction works:
&
=
"Tagln_1"
"Tagln_2"
"TagOut"
Output "TagOut" is set, when the signal state of the operands "TagIn_1" and "TagIn_2" is "1"
and reset when the state of the operands "TagIn_1" and "TagIn_2" is "0".
See also
AND truth table (Page 1659)
Example of detecting the direction of a conveyor belt (Page 1398)
Example of controlling room temperature (Page 1402)
Overview of the valid data types (Page 899)
Adding additional inputs and outputs to FBD elements (Page 1144)
Insert input (Page 1663)
AND truth table
Results of the logic operation
The following table shows the results that arise from the AND logic operation of two operands:
Signal state of the first operand Signal state of the second
operand
Result of the logic operation
1 1 1
0 1 0
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1659
Signal state of the first operand Signal state of the second
operand
Result of the logic operation
1 0 0
0 0 0
See also
&: AND logic operation (Page 1658)
Overview of the valid data types (Page 899)
>=1: OR logic operation
Description
You can use the instruction "OR logic operation" to query the signal states of two or more
specified operands and evaluate them according to the OR truth table.
If the signal state of one of the operands is "1", then the condition is fulfilled and the instruction
returns the result "1". If the signal state of all the operands is "0", then the condition is not
fulfilled and the instruction generates the result "0".
Parameters
The following table shows the parameters of the instruction "OR logic operation":
Parameter Declaration Data type Memory area Description
S7-1200 S7-1500
<Operand> Input BOOL I, Q, M, D, L I, Q, M, D, L, T,
C
The operand
indicates the
bit whose
signal state will
be queried.
Example
The following example shows how the instruction works:
"Tagln_1"
"Tagln_2"
"TagOut"
> = 1
=
Output "TagOut" is set, when the signal state of the operands "TagIn_1" or "TagIn_2" is "1".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1660 System Manual, 01/2013,
See also
OR truth table (Page 1661)
Example of controlling a conveyor belt (Page 1397)
Adding additional inputs and outputs to FBD elements (Page 1144)
Overview of the valid data types (Page 899)
Insert input (Page 1663)
OR truth table
Results of the logic operation
The following table shows the results that arise from the OR logic operation of two operands:
Signal state of the first operand Signal state of the second
operand
Result of the logic operation
1 0 1
0 1 1
1 1 1
0 0 0
See also
>=1: OR logic operation (Page 1660)
Overview of the valid data types (Page 899)
X: EXCLUSIVE OR logic operation
Description
You can use the instruction "EXCLUSIVE OR logic operation" to query the result of a signal
state query according to the EXCLUSIVE OR truth table.
With an instruction "EXCLUSIVE OR logic operation", the signal state is "1" when the signal
state of one of the two specified operands is "1". When more than two operands are queried,
the common RLO is "1" if an odd number of the queried operands returns the result "1".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1661
Parameters
The following table shows the parameters of the instruction "EXCLUSIVE OR logic operation":
Parameter Declaration Data type Memory area Description
S7-1200 S7-1500
<Operand> Input BOOL I, Q, M, D, L I, Q, M, D, L, T,
C
The operand
indicates the
bit whose
signal state will
be queried.
Example
The following example shows how the instruction works:
X
=
"Tagln_1"
"Tagln_2"
"TagOut"
Output "TagOut" is set when the signal state of the operands "TagIn_1" and "TagIn_2" is "1".
When both operands return the signal state "1" or "0", the output "TagOut" is reset.
See also
EXCLUSIVE OR truth table (Page 1662)
Adding additional inputs and outputs to FBD elements (Page 1144)
Overview of the valid data types (Page 899)
Insert input (Page 1663)
EXCLUSIVE OR truth table
Results of the logic operation
The following table shows the results that arise from the EXCLUSIVE OR logic operation of
two operands:
Signal state of the first operand Signal state of the second
operand
Result of the logic operation
1 0 1
0 1 1
1 1 0
0 0 0
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1662 System Manual, 01/2013,
The following table shows the results that arise from the EXCLUSIVE OR logic operation of
three operands:
Signal state of the first
operand
Signal state of the
second operand
Signal state of the third
operand
Result of the logic
operation
1 0 0 1
0 1 1 0
0 1 0 1
1 0 1 0
0 0 1 1
1 1 0 0
1 1 1 1
0 0 0 0
See also
X: EXCLUSIVE OR logic operation (Page 1661)
Overview of the valid data types (Page 899)
Insert input
Description
The "Insert input" instruction is used to add an input to the box of one of the following
instructions:
"AND logic operation"
"OR logic operation"
"EXCLUSIVE OR logic operation"
You can query the signal state of several operands by the extension of an instruction box.
Parameters
The following table shows the parameters of the instruction "Insert input":
Parameter Declaration Data type Memory area Description
S7-1200 S7-1500
<Operand> Input BOOL I, Q, M, D, L I, Q, M, D, L, T,
C
The operand
indicates the
bit whose
signal state will
be queried.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1663
Example
The following example shows how the instruction works:
"Tagln_1"
"Tagln_2"
"Tagln_3"
"TagOut"
&
=
The box of the instruction "AND logic operation" was extended by an additional input at which
the signal state of the operand "TagIn_3" is queried. The output "TagOut" is set, when the
signal state of the operands "TagIn_1", "TagIn_2" and "TagIn_3" returns the signal state "1".
See also
&: AND logic operation (Page 1658)
>=1: OR logic operation (Page 1660)
X: EXCLUSIVE OR logic operation (Page 1661)
Overview of the valid data types (Page 899)
Invert RLO
Description
You use the "Invert RLO" instruction to invert the signal state of the result of logic operation
(RLO).
Example
The following example shows how the instruction works:
&
&
&
> = 1
=
"Tagln_1"
"Tagln_2"
"Tagln_3"
"Tagln_4"
"Tagln_5"
"TagOut"
The output "TagOut" is set when the following conditions are fulfilled:
The input "TagIn_1" and/or "TagIn_2" has signal state "0".
The input "TagIn_3" and/or "TagIn_4" has signal state "0" or the input "TagIn_5" has signal
state "1".
See also
Overview of the valid data types (Page 899)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1664 System Manual, 01/2013,
=: Assignment
Description
You can use the instruction "Assignment" to set the bit of a specified operand. If the result of
logic operation (RLO) at the box input has the signal state "1", the specified operand is set to
signal state "1". If the signal state at the box input is "0", the bit of the specified operand is
reset to "0".
The instruction does not influence the RLO. The RLO at the box input is assigned directly to
the operand above the assignment box.
Parameters
The following table shows the parameters of the instruction "Assignment":
Parameters Declaration Data type Memory area Description
<Operand> Output BOOL I, Q, M, D, L Operand to which
the RLO is
assigned.
Example
The following example shows how the instruction works:
&
> = 1
=
"Tagln_1"
"Tagln_3"
"TagOut"
"Tagln_2"
The operand "TagOut" is set at the output of the "Assignment" instruction when one of the
following conditions is fulfilled:
The inputs "TagIn_1" and "TagIn_2" have the signal state "1".
The signal state at the input "TagIn_3" is "0".
See also
Overview of the valid data types (Page 899)
Example of detecting the fill level of a storage area (Page 1399)
Example of controlling room temperature (Page 1402)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1665
/=: Negate assignment
Description
The instruction "Negate assignment" inverts the result of logic operation (RLO) and assigns
this to the operand above the box. If the RLO at the input of the box is "1", the binary operand
is reset. If the RLO at the input of the box is "0", the operand is set to signal state "1".
Parameters
The following table shows the parameters of the instruction "Negate assignment":
Parameters Declaration Data type Memory area Description
<Operand> Output BOOL I, Q, M, D, L Operand to which
the negated RLO
is assigned.
Example
The following example shows how the instruction works:
/ =
&
> = 1
"Tagln_1"
"Tagln_3"
"TagOut"
"Tagln_2"
The operand "TagOut" is reset when the following conditions are fulfilled:
The operand "TagIn_1" or "TagIn_2" has the signal state "1".
The operand "TagIn_3" has the signal state "0".
See also
Overview of the valid data types (Page 899)
R: Reset output
Description
You can use the "Reset output" instruction to reset the signal state of a specified operand to
"0".
The instruction is only executed if the result of logic operation (RLO) at the box input is "1". If
the box input has the signal state "1", the specified operand is reset to "0". If there is an RLO
of "0" at the box input, the signal state of the specified operand remains unchanged.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1666 System Manual, 01/2013,
Parameters
The following table shows the parameters of the "Reset output" instruction:
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500
<Operand> Output BOOL I, Q, M, D, L I, Q, M, D, L, T,
C
Operand that
is reset if
RLO = "1".
Example
The following example shows how the instruction works:
&
> = 1
R
"Tagln_1"
"Tagln_3"
"TagOut"
"Tagln_2"
Operand "TagOut" is reset when one of the following conditions is fulfilled:
The operands "TagIn_1" and "TagIn_2" have signal state "1".
The operand "TagIn_3" has the signal state "0".
See also
Example of controlling a conveyor belt (Page 1397)
Example of detecting the direction of a conveyor belt (Page 1398)
Overview of the valid data types (Page 899)
S: Set output
Description
You can use the instruction "Set output" to set the signal state of a specified operand to "1".
The instruction is only executed if the result of logic operation (RLO) at the box input is "1". If
the box input has the signal state "1", the specified operand is set to "1". If there is an RLO of
"0" at the box input, the signal state of the specified operand remains unchanged.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1667
Parameters
The following table shows the parameters of the instruction "Set output":
Parameters Declaratio
n
Data type Memory area Description
<Operand> Output BOOL I, Q, M, D, L Operand which is set with
RLO = "1".
Example
The following example shows how the instruction works:
&
> = 1
S
"Tagln_1"
"Tagln_3"
"TagOut"
"Tagln_2"
The "TagOut" operand is set when one of the following conditions is fulfilled:
The operands "TagIn_1" and "TagIn_2" have signal state "1".
The operand "TagIn_3" has the signal state "0".
See also
Overview of the valid data types (Page 899)
SET_BF: Set bit field
Description
You use the instruction "Set bit field" to set multiple bits starting from a certain address.
You use the input N to define the number of bits to be set. The address of the first bit to be set
is defined by (<Operand>). If the value of the N input is greater than the number of bits in a
selected byte, the bits of the next byte are set. The bits remain set until they are explicitly reset,
for example, by another instruction.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1668 System Manual, 01/2013,
Parameters
The following table shows the parameters of the instruction "Set bit field":
Parameters Declaration Data type Memory area Description
EN Input BOOL I, Q, M, D, L Enable input
N Input UINT Constant Number of bits to
be set
<Operand> Output BOOL I, Q, M
In the case of a DB
or an IDB, an
element of an
ARRAY[..] of
BOOL
Pointer to the first
bit to be set.
Example
The following example shows how the instruction works:
5
&
SET_BF
N
EN
"Tagln_1"
"MyDB".MyBoolArray[4]
"Tagln_2"
If the operands "TagIn_1" and "TagIn_2" have the signal state "1", 5 bits are set starting at the
address of the operand "MyDB".MyBoolArray[4].
See also
Overview of the valid data types (Page 899)
RESET_BF: Reset bit field
Description
You use the instruction "Reset bit field" to reset several bits starting from a certain address.
You use the value of the N input to define the number of bits to be reset. The address of the
first bit to be reset is defined by (<Operand>). If the value of the input N is greater than the
number of bits in a selected byte, the bits of the next byte are reset. The bits remain reset until
they are explicitly set, for example, by another instruction.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1669
Parameters
The following table shows the parameters of the instruction "Reset bit field":
Parameters Declaration Data type Memory area Description
EN Input BOOL I, Q, M, D, L Enable input
N Input UINT Constant Number of bits to
be reset.
<Operand> Output BOOL I, Q, M
In the case of a DB
or an IDB, an
element of an
ARRAY[..] of
BOOL
Pointer to the first
bit to be reset.
Example
The following example shows how the instruction works:
5
"Tagln_1"
"MyDB".MyBoolArray[4]
"Tagln_2"
EN
N
RESET_BF
&
If the operands "TagIn_1" and "TagIn_2" have the signal state "1", 5 bits are reset starting at
the address of the operand "MyDB".MyBoolArray[4].
See also
Overview of the valid data types (Page 899)
SR: Set/reset flip-flop
Description
You can use the instruction "Set/reset flip-flop" to set or reset the bit of a specified operand
based on the signal state of the inputs S and R1. If the signal state is "1" at input S and "0" at
input R1, the specified operand is set to "1". If the signal state is "0" at input S and "1" at input
R1, the specified operand will be reset to "0".
Input R1 takes priority over input S. When the signal state is "1" on both inputs S and R1, the
signal state of the specified operand is reset to "0".
The instruction is not executed if the signal state at the two inputs S and R1 is "0". The signal
state of the operand then remains unchanged.
The current signal state of the operand is transferred to output Q and can be queried there.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1670 System Manual, 01/2013,
Parameters
The following table shows the parameters of the instruction "Set/reset flip-flop":
Parameter Declaration Data type Memory area Description
S7-1200 S7-1500
S Input BOOL I, Q, M, D, L I, Q, M, D, L, T,
C
Enable setting
R1 Input BOOL I, Q, M, D, L I, Q, M, D, L, T,
C
Enable
resetting
<Operand> InOut BOOL I, Q, M, D, L I, Q, M, D, L Operand that
is set or reset
Q Output BOOL I, Q, M, D, L I, Q, M, D, L Signal state of
the operand
Example
The following example shows how the instruction works:
"Tagln_1" S
Q R1
SR
"TagOut"
"TagSR"
"Tagln_2"
=
The operands "TagSR" and "TagOut" are set when the following conditions are fulfilled:
The operand "TagIn_1" has the signal state "1".
The operand "TagIn_2" has the signal state "0".
The operands "TagSR" and "TagOut" are reset when one of the following conditions is fulfilled:
The operand "TagIn_1" has signal state "0" and the operand "TagIn_2" has signal state "1".
The operands "TagIn_1" and "TagIn_2" have signal state "1".
See also
Overview of the valid data types (Page 899)
RS: Reset/set flip-flop
Description
You can use the instruction "Reset/set flip-flop" to reset or set the bit of a specified operand
based on the signal state of the inputs R and S1. If the signal state is "1" at input R and "0" at
input S1, the specified operand will be reset to "0". If the signal state is "0" at input R and "1"
at input S1, the specified operand is set to "1".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1671
Input S1 takes priority over input R. When the signal state is "1" at both inputs R and S1, the
signal state of the specified operand is set to "1".
The instruction is not executed if the signal state at the two inputs R and S1 is "0". The signal
state of the operand then remains unchanged.
The current signal state of the operand is transferred to output Q and can be queried there.
Parameters
The following table shows the parameters of the instruction "Reset/set flip-flop":
Parameter Declaration Data type Memory area Description
S7-1200 S7-1500
R Input BOOL I, Q, M, D, L I, Q, M, D, L, T,
C
Enable
resetting
S1 Input BOOL I, Q, M, D, L I, Q, M, D, L, T,
C
Enable setting
<Operand> InOut BOOL I, Q, M, D, L I, Q, M, D, L Operand that
is reset or set.
Q Output BOOL I, Q, M, D, L I, Q, M, D, L Signal state of
the operand
Example
The following example shows how the instruction works:
"Tagln_1"
R
Q S1
RS
"TagOut"
"TagRS"
"Tagln_2"
=
The operands "TagRS" and "TagOut" are reset when the following conditions are fulfilled:
The operand "TagIn_1" has the signal state "1".
The operand "TagIn_2" has the signal state "0".
The operands "TagRS" and "TagOut" are set when the following conditions are fulfilled:
The operand "TagIn_1" has signal state "0" and the operand "TagIn_2" has signal state "1".
The operands "TagIn_1" and "TagIn_2" have signal state "1".
See also
Overview of the valid data types (Page 899)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1672 System Manual, 01/2013,
P: Scan operand for positive signal edge
Description
You can use the instruction "Scan operand for positive signal edge" to determine whether there
is a "0" to "1" change in the signal state of a specified operand (<Operand1>). The instruction
compares the current signal state of <Operand1> with the signal state of the previous scan,
which is saved in an edge memory bit (<Operand2>). If the instruction detects a change in the
result of logic operation (RLO) from "0" to "1", there is a positive, rising edge.
If a rising edge is detected, the output of the instruction has the signal state "1". In all other
cases, the signal state at the output of the instruction is "0".
Specify the operand to be queried (<Operand1>) in the operand placeholder above the
instruction. Specify the edge memory bit (<Operand2>) in the operand placeholder below the
instruction.
Note
The address of the edge memory bit must not be used more than once in the program,
otherwise the memory bit is overwritten. This would influence edge evaluation and the result
would no longer be unequivocal. The memory area of the edge memory bit has to be located
in a DB (static area for FB) or in the bit memory area.
Parameters
The following table shows the parameters of the "Scan operand for positive signal edge"
instruction:
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500
<Operand1> Input BOOL I, Q, M, D, L I, Q, M, D, L, T,
C
Signal to be
scanned
<Operand2> InOut BOOL I, Q, M, D, L I, Q, M, D, L Edge memory
bit in which the
signal state of
the previous
query is saved.
Example
The following example shows how the instruction works:
=
&
P
"Tagln_1"
"TagOut"
"Tag_M"
"Tagln_2"
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1673
Output "TagOut" is set when the following conditions are fulfilled:
There is a rising edge at input "TagIn_1".
The signal state of the operand "TagIn_2" is "1".
See also
Overview of the valid data types (Page 899)
Example of detecting the direction of a conveyor belt (Page 1398)
N: Scan operand for negative signal edge
Description
You can use the instruction "Scan operand for negative signal edge" to determine whether
there is a "1" to "0" change in the signal state of a specified operand (<Operand1>). The
instruction compares the current signal state of <Operand1> with the signal state of the
previous scan, which is saved in an edge memory bit (<Operand2>). If the instruction detects
a change in the result of logic operation (RLO) from "1" to "0", there is a negative, falling edge.
If a falling edge is detected, the output of the instruction has the signal state "1". In all other
cases, the signal state at the output of the instruction is "0".
Specify the operand to be queried (<Operand1>) in the operand placeholder above the
instruction. Specify the edge memory bit (<Operand2>) in the operand placeholder below the
instruction.
Note
The address of the edge memory bit must not be used more than once in the program,
otherwise the memory bit is overwritten. This would influence edge evaluation and the result
would no longer be unequivocal. The memory area of the edge memory bit has to be located
in a DB (static area for FB) or in the bit memory area.
Parameters
The following table shows the parameters of the "Scan operand for negative signal edge"
instruction:
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500
<Operand1> Input BOOL I, Q, M, D, L I, Q, M, D, L, T,
C
Signal to be
scanned
<Operand2> InOut BOOL I, Q, M, D, L I, Q, M, D, L Edge memory
bit in which the
signal state of
the previous
query is saved.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1674 System Manual, 01/2013,
Example
The following example shows how the instruction works:
=
&
N
"Tagln_1"
"TagOut"
"Tag_M"
"Tagln_2"
Output "TagOut" is set when the following conditions are fulfilled:
There is a falling edge at input "TagIn_1".
The signal state of the operand "TagIn_2" is "1".
See also
Overview of the valid data types (Page 899)
P=: Set operand on positive signal edge
Description
You can use the instruction "Set operand on positive signal edge" to set a specified operand
(<Operand2>) when there is a "0" to "1" change in the result of logic operation (RLO). The
instruction compares the current RLO with the RLO from the previous query, which is saved
in the edge memory bit (<Operand1>). If the instruction detects a change in the result of logic
operation (RLO) from "0" to "1", there is a positive, rising edge.
When a positive edge is detected, <Operand2> is set to signal state "1" for one program cycle.
In all other cases, the operand has the signal state "0".
You specify the operand (<Operand2>) to be set in the operand placeholder above the
instruction. Specify the edge memory bit (<Operand1>) in the operand placeholder below the
instruction.
Note
The address of the edge memory bit must not be used more than once in the program,
otherwise the memory bit is overwritten. This would influence edge evaluation and the result
would no longer be unequivocal. The memory area of the edge memory bit has to be located
in a DB (static area for FB) or in the bit memory area.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1675
Parameters
The following table shows the parameters of the instruction "Set operand on positive signal
edge":
Parameters Declaration Data type Memory area Description
<Operand2> Output BOOL I, Q, M, D, L Operand which is
set when there is a
positive signal
edge.
<Operand1> InOut BOOL I, Q, M, D, L Edge memory bit
Example
The following example shows the parameters of the instruction:
&
P=
"Tagln_1"
"Tagln_2"
"TagOut"
"Tag_M"
The "TagOut" output is set for one program cycle, when the signal state at the input of the
instruction box switches from "0" to "1" (positive signal edge). In all other cases, the "TagOut"
output has signal state "0".
See also
Overview of the valid data types (Page 899)
N=: Set operand on negative signal edge
Description
You can use the instruction "Set operand on negative signal edge" to set a specified operand
(<Operand1>) when there is a "1" to "0" change in the result of logic operation (RLO). The
instruction compares the current RLO with the RLO from the previous query, which is saved
in the edge memory bit (<Operand2>). If the instruction detects a change in the result of logic
operation (RLO) from "1" to "0", there is a negative, falling edge.
When a negative edge is detected, <Operand1> is set to signal state "1" for one program cycle.
In all other cases, the operand has the signal state "0".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1676 System Manual, 01/2013,
You specify the operand (<Operand1>) to be set in the operand placeholder above the
instruction. Specify the edge memory bit (<Operand2>) in the operand placeholder below the
instruction.
Note
The address of the edge memory bit must not be used more than once in the program,
otherwise the memory bit is overwritten. This would influence edge evaluation and the result
would no longer be unequivocal. The memory area of the edge memory bit has to be located
in a DB (static area for FB) or in the bit memory area.
Parameters
The following table shows the parameters of the instruction "Set operand on negative signal
edge":
Parameters Declaration Data type Memory area Description
<Operand1> Output BOOL I, Q, M, D, L Operand which is
set when there is a
negative signal
edge.
<Operand2> InOut BOOL I, Q, M, D, L Edge memory bit
Example
The following example shows how the instruction works:
&
N=
"Tagln_1"
"Tagln_2"
"TagOut"
"Tag_M"
The operand "TagOut" is set for one program cycle if the signal state at the input of the
instruction box changes from "1" to "0" (negative signal edge). In all other cases, the operand
"TagOut" has the signal state "0".
See also
Overview of the valid data types (Page 899)
P_TRIG: Scan RLO for positive signal edge
Description
Use the instruction "Scan RLO for positive signal edge" to query a "0" to "1" change in the
signal state of the result of logic operation (RLO). The instruction compares the current signal
state of the RLO with the signal state of the previous query, which is saved in an edge memory
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1677
bit (<Operand>). If the instruction detects a change in the result of logic operation (RLO) from
"0" to "1", there is a positive, rising edge.
If a rising edge is detected, the output of the instruction has the signal state "1". In all other
cases, the signal state at the output of the instruction is "0".
Note
The address of the edge memory bit must not be used more than once in the program,
otherwise the memory bit is overwritten. This would influence edge evaluation and the result
would no longer be unequivocal. The memory area of the edge memory bit has to be located
in a DB (static area for FB) or in the bit memory area.
Parameters
The following table shows the parameters of the instruction "Scan RLO for positive signal edge":
Parameters Declaration Data type Memory area Description
CLK Input BOOL I, Q, M, D, L Current RLO
<Operand> InOut BOOL M, D Edge memory bit
in which the RLO
of the previous
query is saved.
Q Output BOOL I, Q, M, D, L Result of edge
evaluation
Example
The following example shows how the instruction works:
P_TRlG
CLK Q JMP
&
> = 1
"Tagln_1"
"TagOut"
"Tag_M"
"Tagln_2"
CAS1
The RLO of the preceding bit logic operation is saved in the edge memory bit "Tag_M". If a "0"
to "1" change is detected in the signal state of the RLO, the program jumps to jump label CAS1.
See also
Overview of the valid data types (Page 899)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1678 System Manual, 01/2013,
N_TRIG: Scan RLO for negative signal edge
Description
Use the instruction "Scan RLO for negative signal edge" to query a "1" to "0" change in the
signal state of the result of logic operation (RLO). The instruction compares the current signal
state of the RLO with the signal state of the previous query saved in the edge memory bit
(<Operand>). If the instruction detects a change in the result of logic operation (RLO) from "1"
to "0", there is a negative, falling edge.
If a falling edge is detected, the output of the instruction has the signal state "1". In all other
cases, the signal state at the output of the instruction is "0".
Note
The address of the edge memory bit must not be used more than once in the program,
otherwise the memory bit is overwritten. This would influence edge evaluation and the result
would no longer be unequivocal. The memory area of the edge memory bit has to be located
in a DB (static area for FB) or in the bit memory area.
Parameters
The following table shows the parameters of the instruction "Scan RLO for negative signal
edge":
Parameter Declaration Data type Memory area Description
CLK Input BOOL I, Q, M, D, L Current RLO
<Operand> InOut BOOL M, D Edge memory bit
in which the RLO
of the previous
query is saved.
Q Output BOOL I, Q, M, D, L Result of edge
evaluation
Example
The following example shows how the instruction works:
N_TRlG
CLK Q JMP
&
> = 1
"Tagln_1"
"TagOut"
"Tag_M"
"Tagln_2"
CAS1
The RLO of the preceding bit logic operation is saved in the edge memory bit "Tag_M". If a "1"
to "0" change is detected in the signal state of the RLO, the program jumps to jump label CAS1.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1679
See also
Overview of the valid data types (Page 899)
R_TRIG: Set tag on positive signal edge
Description
You can use the "Set tag on positive signal edge" instruction to set a specified tag in the
instance DB when there is a "0" to "1" change in the result of logic operation (RLO). The
instruction compares the current RLO at the input CLK with the RLO from the previous query,
which is saved in the specified instance DB. If the instruction detects a change in the result of
logic operation (RLO) from "0" to "1", there is a positive, rising edge.
If a positive edge is detected, the tag in the instance DB is set to signal state "1" and the output
Q returns the signal state "1" In all other cases, the signal state at the output of the instruction
is "0".
When you insert the instruction in the program, the "Call options" dialog opens automatically.
In this dialog you can specify whether the edge memory bit is stored in its own data block
(single instance) or as a local tag (multiple instance) in the block interface. If you create a
separate data block, you will find this in the project tree in the "Program resources" folder under
"Program blocks > System blocks". For additional information on this topic, refer to "See also".
Parameters
The following table shows the parameters of the instruction "Set tag on positive signal edge":
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500
EN Input BOOL I, Q, M, D, L I, Q, M, D, L, T,
C
Enable input
ENO Output BOOL I, Q, M, D, L I, Q, M, D, L Enable output
CLK Input BOOL I, Q, M, D, L or
constant
I, Q, M, D, L, T,
C or constant
Incoming
signal whose
edge will be
queried.
Q Output BOOL I, Q, M, D, L I, Q, M, D, L Result of edge
evaluation
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1680 System Manual, 01/2013,
Example
The following example shows how the instruction works:
R_TRlG
CLK
Q
&
> = 1
"Tagln_1"
"Tagln_3"
"TagOut"
"Tagln_2"
EN "Tagln"
ENO
%DB1
"R_TRlG_DB"
The RLO of the preceding query is saved in the instance DB "R_TRIG_DB". If a change is the
signal state of the RLO from "0" to "1" is detected in the operands "TagIn_1" and "TagIn_2" or
in the operand "TagIn_3", the output "TagOut" has signal state "1".
See also
Overview of the valid data types (Page 899)
F_TRIG: Set tag on negative signal edge
Description
You can use the "Set tag on negative signal edge" instruction to set a specified tag in the
instance DB when there is a "1" to "0" change in the result of logic operation (RLO). The
instruction compares the current RLO at the input CLK with the RLO from the previous query,
which is saved in the specified instance DB. If the instruction detects a change in the result of
logic operation (RLO) from "1" to "0", there is a negative, falling edge.
If a negative edge is detected, the tag in the instance DB is set to signal state "1" and the output
Q returns the signal state "1" In all other cases, the signal state at the output of the instruction
is "0".
When you insert the instruction in the program, the "Call options" dialog opens automatically.
In this dialog you can specify whether the edge memory bit is stored in its own data block
(single instance) or as a local tag (multiple instance) in the block interface. If you create a
separate data block, you will find this in the project tree in the "Program resources" folder under
"Program blocks > System blocks". For additional information on this topic, refer to "See also".
Parameters
The following table shows the parameters of the instruction "Set tag on negative signal edge":
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500
EN Input BOOL I, Q, M, D, L I, Q, M, D, L, T,
C
Enable input
ENO Output BOOL I, Q, M, D, L I, Q, M, D, L Enable output
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1681
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500
CLK Input BOOL I, Q, M, D, L or
constant
I, Q, M, D, L, T,
C or constant
Incoming
signal whose
edge will be
queried.
Q Output BOOL I, Q, M, D, L I, Q, M, D, L Result of edge
evaluation
Example
The following example shows how the instruction works:
F_TRlG
CLK
Q
&
> = 1
"Tagln_1"
"Tagln_3"
"TagOut"
"Tagln_2"
EN "Tagln"
ENO
%DB1
"F_TRlG_DB"
The RLO of the preceding query is saved in the instance DB "F_TRIG_DB". If a change is the
signal state of the RLO from "1" to "0" is detected in the operands "TagIn_1" and "TagIn_2" or
in the operand "TagIn_3", the output "TagOut" has signal state "1".
See also
Overview of the valid data types (Page 899)
Timer operations
IEC Timers
TP: Generate pulse
Description
You can use the instruction "Generate pulse" to set output Q for the duration PT. The instruction
is started when the result of logic operation (RLO) at input IN changes from "0" to "1" (positive
signal edge). The configured time duration PT begins when the instruction starts. Output Q is
set for the time duration PT, regardless of the subsequent course of the input signal (positive
edge). Even when a new positive signal edge is detected, the signal state of the Q output is
not affected as long as the PT duration is running.
The current timer value can be queried at the output ET. The timer value starts at T#0s and
ends when the value of the time duration PT is reached. If the configured time duration PT is
reached and the signal state at input IN is "0", the ET output is reset.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1682 System Manual, 01/2013,
Each call of the "Generate pulse" instruction must be assigned an IEC Timer in which the
instruction data is stored.
Note
If the timer is not called in the program because it is skipped, for example, output ET returns
a constant value as soon as the timer has expired.
For S7-1200 CPU
An IEC Timer is a structure of the data type IEC_TIMER or TP_TIME that you can declare as
follows:
Declaration of a data block of system data type IEC_TIMER (for example, "MyIEC_TIMER")
Declaration as a local tag of the type TP_TIME or IEC_TIMER in the "Static" section of a
block (for example, #MyIEC_TIMER)
For S7-1500 CPU
An IEC Timer is a structure of the data type IEC_TIMER, IEC_LTIMER, TP_TIME or TP_LTIME
that you can declare as follows:
Declaration of a data block of system data type IEC_TIMER or IEC_LTIMER (for example,
"MyIEC_TIMER")
Declaration as a local tag of the type TP_TIME, TP_LTIME, IEC_TIMER or IEC_LTIMER
in the "Static" section of a block (for example, #MyIEC_TIMER)
When you insert the instruction in the program, the "Call options" dialog opens in which you
can specify whether the IEC Timer is stored in its own data block (single instance) or as a local
tag (multiple instance) in the block interface. If you create a separate data block, you will find
this in the project tree in the "Program resources" folder under "Program blocks > System
blocks". For additional information on this topic, refer to "See also".
The instruction data is updated both when the instruction is called and also each time the
outputs Q or ET are accessed.
The execution of the "Generate pulse" instruction requires a preceding logic operation. It can
be placed within or at the end of the network.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1683
Parameters
The following table shows the parameters of the "Generate pulse" instruction:
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500 S7-1200 S7-1500
IN Input BOOL BOOL I, Q, M, D, L I, Q, M, D, L,
T, C
Start input
PT Input TIME TIME,
LTIME
I, Q, M, D, L
or constant
I, Q, M, D, L
or constant
Duration of
the pulse.
The value of
the PT
parameter
must be
positive.
Q Output BOOL BOOL I, Q, M, D, L I, Q, M, D, L Pulse output
ET Output TIME TIME,
LTIME
I, Q, M, D, L I, Q, M, D, L Current
timer value
For additional information on valid data types, refer to "See also".
Timing diagram
The following figure shows the timing diagram of the "Generate pulse" instruction:
See also
Overview of the valid data types (Page 899)
Example of controlling room temperature (Page 1402)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1684 System Manual, 01/2013,
TON: Generate on-delay
Description
You can use the instruction "Generate on-delay" to delay setting of the Q output by the time
configured with the PT time. The instruction is started when the result of logic operation (RLO)
at input IN changes from "0" to "1" (positive signal edge). The programmed time PT begins
when the instruction starts. When the duration PT expires, output Q has the signal state "1".
Output Q remains set as long as the start input is still "1". When the signal state at the start
input changes from "1" to "0", the Q output is reset. The timer function is started again when
a new positive signal edge is detected at the start input.
The current timer value can be queried at the output ET. The timer value starts at T#0s and
ends when the value of the time duration PT is reached. The ET output is reset as soon as the
signal state at the IN input changes to "0".
Each call of the "Generate on-delay" instruction must be assigned an IEC Timer in which the
instruction data is stored.
Note
If the timer is not called in the program because it is skipped, for example, output ET returns
a constant value as soon as the timer has expired.
For S7-1200 CPU
An IEC Timer is a structure of the data type IEC_TIMER or TON_TIME that you can declare
as follows:
Declaration of a data block of system data type IEC_TIMER (for example, "MyIEC_TIMER")
Declaration as a local tag of the type TON_TIME or IEC_TIMER in the "Static" section of a
block (for example, #MyIEC_TIMER)
For S7-1500 CPU
An IEC Timer is a structure of the data type IEC_TIMER, IEC_LTIMER, TON_TIME or
TON_LTIME that you can declare as follows:
Declaration of a data block of system data type IEC_TIMER or IEC_LTIMER (for example,
"MyIEC_TIMER")
Declaration as a local tag of the type TON_TIME, TON_LTIME, IEC_TIMER or IEC_LTIMER
in the "Static" section of a block (for example, #MyIEC_TIMER)
When you insert the instruction in the program, the "Call options" dialog opens in which you
can specify whether the IEC Timer is stored in its own data block (single instance) or as a local
tag (multiple instance) in the block interface. If you create a separate data block, it is saved to
the "Program resources" folder in the "Program blocks > System blocks" path of the project
tree. For additional information on this topic, refer to "See also".
The instruction data is updated both when the instruction is called and also each time the
outputs Q or ET are accessed.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1685
The execution of the "Generate on-delay" instruction requires a preceding logic operation. It
can be placed within or at the end of the network.
Parameters
The following table shows the parameters of the "Generate on-delay" instruction:
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500 S7-1200 S7-1500
IN Input BOOL BOOL I, Q, M, D, L I, Q, M, D, L,
T, C
Start input
PT Input TIME TIME,
LTIME
I, Q, M, D, L
or constant
I, Q, M, D, L
or constant
Duration of
the on delay.
The value of
the PT
parameter
must be
positive.
Q Output BOOL BOOL I, Q, M, D, L I, Q, M, D, L Output that
is set when
the time PT
expires.
ET Output TIME TIME,
LTIME
I, Q, M, D, L I, Q, M, D, L Current
timer value
For additional information on valid data types, refer to "See also".
Timing diagram
The following figure shows the timing diagram of the "Generate on-delay" instruction:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1686 System Manual, 01/2013,
See also
Overview of the valid data types (Page 899)
TOF: Generate off-delay
Description
You can use the "Generate off-delay" instruction to delay setting of the Q output by the time
configured with the PT time. The output Q is set when the result of logic operation (RLO) at
input IN changes from "0" to "1" (positive signal edge). When the signal state at input IN
changes back to "0" (positive signal edge), the configured time duration PT starts. Output Q
remains set as long as the time duration PT is running. When the PT time duration expires,
the Q output is reset. If the signal state at input IN changes to "1" before the PT time duration
expires, the timer is reset. The signal state at the output Q will continue to be "1".
The current timer value can be queried at the output ET. The timer value starts at T#0s and
ends when the value of the time duration PT is reached. When the time duration PT expires,
the ET output remains set to the current value until input IN changes back to "1". If input IN
changes to "1" before the time duration PT has expired, the ET output is reset to the value
T#0s.
Each call of the "Generate off-delay" instruction must be assigned to an IEC Timer in which
the instruction data is stored.
Note
If the timer is not called in the program because it is skipped, for example, output ET returns
a constant value as soon as the timer has expired.
For S7-1200 CPU
An IEC Timer is a structure of the data type IEC_TIMER or TOF_TIME that you can declare
as follows:
Declaration of a data block of system data type IEC_TIMER (for example, "MyIEC_TIMER")
Declaration as a local tag of the type TOF_TIME or IEC_TIMER in the "Static" section of a
block (for example, #MyIEC_TIMER)
For S7-1500 CPU
An IEC Timer is a structure of the data type IEC_TIMER, IEC_LTIMER, TOF_TIME or
TOF_LTIME that you can declare as follows:
Declaration of a data block of system data type IEC_TIMER or IEC_LTIMER (for example,
"MyIEC_TIMER")
Declaration as a local tag of the type TOF_TIME, TOF_LTIME, IEC_TIMER or IEC_LTIMER
in the "Static" section of a block (for example, #MyIEC_TIMER)
When you insert the instruction in the program, the "Call options" dialog opens in which you
can specify whether the IEC Timer is stored in its own data block (single instance) or as a local
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1687
tag (multiple instance) in the block interface. If you create a separate data block, you will find
this in the project tree in the "Program resources" folder under "Program blocks > System
blocks". For additional information on this topic, refer to "See also".
The instruction data is updated both when the instruction is called and also each time the
outputs Q or ET are accessed.
The execution of the "Generate off-delay" instruction requires a preceding logic operation. It
can be placed within or at the end of the network.
Parameters
The following table shows the parameters of the "Generate off-delay" instruction:
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500 S7-1200 S7-1500
IN Input BOOL BOOL I, Q, M, D, L I, Q, M, D, L,
T, C
Start input
PT Input TIME TIME,
LTIME
I, Q, M, D, L
or constant
I, Q, M, D, L
or constant
Duration of
the off delay
The value of
the PT
parameter
must be
positive.
Q Output BOOL BOOL I, Q, M, D, L I, Q, M, D, L Output that
is reset
when the
timer PT
expires.
ET Output TIME TIME,
LTIME
I, Q, M, D, L I, Q, M, D, L Current
timer value
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1688 System Manual, 01/2013,
Timing diagram
The following figure shows the timing diagram of the "Generate off-delay" instruction:
See also
Overview of the valid data types (Page 899)
TONR: Time accumulator
Description
The instruction "Time accumulator" is used to accumulate timer values within a period set by
the parameter PT. The instruction is executed and the configured time duration PT is started
when the result of logic operation (RLO) at input IN changes from "0" to "1" (positive edge).
While the time set at PT is running, the timer values are accumulated that are recorded at
signal state "1" at input IN. The accumulated time is written to output ET and can be queried
there. When the current timer value PT is reached, the output Q has the signal state "1". Output
Q remains set at "1", even when the signal state at input IN changes to "0".
The R input resets the outputs ET and Q regardless of the signal state at the start input.
Each call of the "Time accumulator" instruction must be assigned to an IEC Timer in which the
instruction data is stored.
For S7-1200 CPU
An IEC Timer is a structure of the data type IEC_TIMER or TONR_TIME that you can declare
as follows:
Declaration of a data block of system data type IEC_TIMER (for example, "MyIEC_TIMER")
Declaration as a local tag of the type TONR_TIME or IEC_TIMER in the "Static" section of
a block (for example, #MyIEC_TIMER)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1689
For S7-1500 CPU
An IEC Timer is a structure of the data type IEC_TIMER, IEC_LTIMER, TONR_TIME or
TONR_LTIME that you can declare as follows:
Declaration of a data block of system data type IEC_TIMER or IEC_LTIMER (for example,
"MyIEC_TIMER")
Declaration as a local tag of the type TONR_TIME, TONR_LTIME, IEC_TIMER or
IEC_LTIMER in the "Static" section of a block (for example, #MyIEC_TIMER)
When you insert the instruction in the program, the "Call options" dialog opens in which you
can specify whether the IEC Timer is stored in its own data block (single instance) or as a local
tag (multiple instance) in the block interface. If you create a separate data block, you will find
this in the project tree in the "Program resources" folder under "Program blocks > System
blocks". For additional information on this topic, refer to "See also".
The instruction data is updated both when the instruction is called and also each time the
outputs Q or ET are accessed.
The execution of the "Time accumulator" instruction requires a preceding logic operation. It
can be placed within or at the end of the network.
Parameters
The following table shows the parameters of the "Time accumulator" instruction:
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500 S7-1200 S7-1500
IN Input BOOL BOOL I, Q, M, D, L I, Q, M, D, L,
T, C
Start input
R Input BOOL BOOL I, Q, M, D, L
or constant
I, Q, M, D, L
or constant
Reset input
PT Input TIME TIME,
LTIME
I, Q, M, D, L
or constant
I, Q, M, D, L
or constant
Maximum
duration of
time
recording.
The value of
the PT
parameter
must be
positive.
Q Output BOOL BOOL I, Q, M, D, L I, Q, M, D, L Output that
is set when
the time PT
expires.
ET Output TIME TIME,
LTIME
I, Q, M, D, L I, Q, M, D, L Current
timer value
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1690 System Manual, 01/2013,
Timing diagram
The following figure shows the timing diagram of the "Time accumulator" instruction:
See also
Overview of the valid data types (Page 899)
TP: Start pulse timer
Description
Use the instruction "Start pulse timer" to start an IEC Timer with a specified duration as pulse.
The IEC Timer is started when the result of logic operation (RLO) changes from "0" to "1"
(positive signal edge). The IEC Timer runs for the specified time duration regardless of the
subsequent course of the RLO. The expiry of the IEC Timer is also not affected by the detection
of a new rising edge. As long as the IEC Timer is running, the querying of the timer status for
"1" returns the signal state "1". When the IEC Timer has expired, the timer status returns the
signal state "0".
Note
The start and the query of the IEC Timer may be on different expiry levels as each query of
the outputs Q or ET updates the IEC_TIMER structure.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1691
For S7-1200 CPU
The instruction "Start pulse timer" stores its data in a structure of the data type IEC_TIMER or
TP_TIME. You can declare the structure as follows:
Declaration of a data block of system data type IEC_TIMER (for example, "MyIEC_TIMER")
Declaration as a local tag of the type TP_TIME or IEC_TIMER in the "Static" section of a
block (for example, #MyIEC_TIMER)
For S7-1500 CPU
The instruction "Start pulse timer" stores its data in a structure of the data type IEC_TIMER,
IEC_LTIMER, TP_TIME or TP_LTIME. You can declare the structure as follows:
Declaration of a data block of system data type IEC_TIMER or IEC_LTIMER (for example,
"MyIEC_TIMER")
Declaration as a local tag of the type TP_TIME, TP_LTIME, IEC_TIMER or IEC_LTIMER
in the "Static" section of a block (for example, #MyIEC_TIMER)
The instruction data is updated both when the instruction is called and also each time the
specified timer is accessed.
The current timer status is saved in the structure components Q of the IEC Timer. You can
query the timer status with the help of a binary logic operation. The query for Q or ET (e. g.
"MyTimer".Q or "MyTimer".ET) updates the IEC_TIMER structure.
The execution of the instruction "Start pulse timer" assumes a preceding logic operation. It can
be placed only at the end of the network.
Parameters
The following table shows the parameters of the instruction "Start pulse timer":
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500
VALUE Input TIME TIME, LTIME I, Q, M, D, L or
constant
Duration with
which the IEC
Timer runs.
<IEC Timer> InOut IEC_TIMER,
TP_TIME
IEC_TIMER,
IEC_LTIMER,
TP_TIME,
TP_LTIME
D, L IEC Timer
which is
started.
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1692 System Manual, 01/2013,
Example
The following example shows how the instruction works:
TlME
"Tag_lnput"
"DB1".
MylEC_TlMER
TP
"Tag_TlME" VALUE
The instruction "Start pulse timer" is executed when the signal state of the operand "Tag_Input"
changes from "0" to "1". The timer "DB1".MyIEC_TIMER is started for the time stored in the
operand "TagTime".
"Tag_Output"
"DB1".MylEC_
TlMER.Q
=
As long as the timer "DB1".MyIEC_TIMER is running, the timer status
("DB1".MyIEC_TIMER.Q) has signal state "1" and the operand "Tag_Output" is set. When the
IEC Timer has expired, the signal state of the time status changes back to "0" and the
"Tag_Output" operand is reset.
See also
Overview of the valid data types (Page 899)
TON: Start on-delay timer
Description
Use the "Start on-delay timer" instruction to start an IEC Timer with a specified duration as on-
delay. The IEC Timer is started when the result of logic operation (RLO) changes from "0" to
"1" (positive signal edge). The IEC Timer runs for the specified time duration. The output returns
the signal state "1" if the RLO at the input of the instruction has the signal state "1". If the RLO
changes to "0" before the end of the timer, the running IEC Timer is reset. The query of the
timer status for "1" returns the signal state "0". The IEC Timer restarts when the next rising
signal edge is detected at the input of the instruction.
Note
The start and the query of the IEC Timer may be on different expiry levels as each query of
the outputs Q or ET updates the IEC_TIMER structure.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1693
For S7-1200 CPU
The instruction "Start on-delay timer" stores its data in a structure of the data type IEC_TIMER
or TON_TIME. You can declare the structure as follows:
Declaration of a data block of system data type IEC_TIMER (for example, "MyIEC_TIMER")
Declaration as a local tag of the type TON_TIME or IEC_TIMER in the "Static" section of a
block (for example, #MyIEC_TIMER)
For S7-1500 CPU
The "Start on-delay timer" instruction stores its data in a structure of the data type IEC_TIMER,
IEC_LTIMER, TON_TIME or TON_LTIME. You can declare the structure as follows:
Declaration of a data block of system data type IEC_TIMER or IEC_LTIMER (for example,
"MyIEC_TIMER")
Declaration as a local tag of the type TON_TIME, TON_LTIME, IEC_TIMER or IEC_LTIMER
in the "Static" section of a block (for example, #MyIEC_TIMER)
The instruction data is updated both when the instruction is called and also each time the
specified timer is accessed.
The current timer status is saved in the structure components ET of the IEC Timer. You can
query the timer status with the help of a binary logic operation. The query for Q or ET (e. g.
"MyTimer".Q or "MyTimer".ET) updates the IEC_TIMER structure.
The execution of the "Start on-delay timer" instruction assumes a preceding logic operation.
It can be placed only at the end of the network.
Parameters
The following table shows the parameters of the instruction "Start on-delay timer":
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500
VALUE Input TIME TIME, LTIME I, Q, M, D, L or
constant
Duration with
which the IEC
Timer runs.
<IEC Timer> InOut IEC_TIMER,
TON_TIME
IEC_TIMER,
IEC_LTIMER,
TON_TIME,
TON_LTIME
D, L IEC Timer
which is
started.
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1694 System Manual, 01/2013,
Example
The following example shows how the instruction works:
"Tag_lnput"
"MylEC_TlMER"
TON
TlME
"Tag_TlME" VALUE
The "Start on-delay timer" instruction is executed when the signal state of the operand
"Tag_Input" changes from "0" to "1". The "MyIEC_TIMER" timer is started for the time stored
in the "Tag_TIME" operand.
"Tag_Output"
"MylEC_TlMER".Q =
If the timer "MyIEC_TIMER" has expired and the operand "Tag_Input" has the signal state "1",
querying the timer status ("MyIEC_TIMER".Q) returns signal state "1" and the "Tag_Output"
operand is set. When the signal state of the operand "Tag_Input" changes to "0", the querying
of the timer status returns the signal state "0" and the operand "Tag_Output" is reset.
See also
Overview of the valid data types (Page 899)
TOF: Start off-delay timer
Description
Use the "Start off-delay timer" instruction to start an IEC Timer with a specified duration as off-
delay. The query of the timer status for "1" returns the signal state "0" if the result of the logic
operation (RLO) at the input of the instruction has the signal state "1". When the RLO changes
from "1" to "0" (negative signal edge), the IEC Timer starts with the specified time duration.
The timer status remains at signal state "1" as long as the IEC Timer is running. When the
timer has run out and the RLO at the input of the instruction has the signal state "0", the timer
status is set to the signal state "0". If the RLO changes to "1" before the end of the timer, the
running IEC Timer is reset and the timer status remain at the signal state "1".
Note
The start and the query of the IEC Timer may be on different expiry levels as each query of
the outputs Q or ET updates the IEC_TIMER structure.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1695
For S7-1200 CPU
The instruction "Start off-delay timer" stores its data in a structure of the data type IEC_TIMER
or TOF_TIME. You can declare the structure as follows:
Declaration of a data block of system data type IEC_TIMER (for example, "MyIEC_TIMER")
Declaration as a local tag of the type TOF_TIME or IEC_TIMER in the "Static" section of a
block (for example, #MyIEC_TIMER)
For S7-1500 CPU
The "Start off-delay timer" instruction stores its data in a structure of the data type IEC_TIMER,
IEC_LTIMER, TOF_TIME or TOF_LTIME. You can declare the structure as follows:
Declaration of a data block of system data type IEC_TIMER or IEC_LTIMER (for example,
"MyIEC_TIMER")
Declaration as a local tag of the type TOF_TIME, TOF_LTIME, IEC_TIMER or IEC_LTIMER
in the "Static" section of a block (for example, #MyIEC_TIMER)
The instruction data is updated both when the instruction is called and also each time the
specified timer is accessed.
The current timer status is saved in the structure components ET of the IEC Timer. You can
query the timer status with the help of a binary logic operation. The query for Q or ET (e. g.
"MyTimer".Q or "MyTimer".ET) updates the IEC_TIMER structure.
The execution of the "Start off-delay timer" instruction assumes a preceding logic operation.
It can be placed only at the end of the network.
Parameters
The following table shows the parameters of the instruction "Start off-delay timer":
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500
VALUE Input TIME TIME, LTIME I, Q, M, D, L or
constant
Duration with which
the IEC Timer runs.
<IEC Timer> InOut IEC_TIMER,
TOF_TIME
IEC_TIMER,
IEC_LTIMER
, TOF_TIME,
TOF_LTIME
D, L IEC Timer which is
started.
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1696 System Manual, 01/2013,
Example
The following example shows how the instruction works:
"Tag_lnput"
#MylEC_TlMER
TOF
TlME
"Tag_TlME" VALUE
The "Start off-delay timer" instruction is executed when the signal state of the operand
"Tag_Input" changes from "1" to "0". The #MyIEC_TIMER timer is started for the time stored
in the operand "Tag_TIME".
#MylEC_TlMER
"Tag_Output"
=
As long as timer #MyIEC_TIMER is running, the query of the time status (#MyIEC_TIMER.Q)
returns the signal state "1" and operand "Tag_Output" is set. If the timer has expired and the
operand "Tag_Input" has the signal state "0", the query of the timer status returns the signal
state "0". If the signal state of the operand "Tag_Input" changes to "1" before timer
#MyIEC_TIMER expires, the timer is reset. When the signal state of the operand "Tag_Input"
is "1", the query of the timer status returns the signal state "1".
See also
Overview of the valid data types (Page 899)
TONR: Time accumulator
Description
You can use the "Time accumulator" instruction to record how long the signal is at the input
of instruction "1". The instruction is started when the result of logic operation (RLO) changes
from "0" to "1" (positive signal edge). The time is recorded as long at the RLO is "1". If the RLO
changes to "0", the instruction is halted. If the RLO changes back to "1", the time recording is
continued. The query of the timer status for "1" returns the signal state "1" if the recorded time
exceeds the value of the specified time duration and the RLO at the input of coil is "1".
The timer status and the currently expired timer can be reset to "0" using the "Reset timer"
instruction.
Note
The start and the query of the IEC Timer may be on different expiry levels as each query of
the outputs Q or ET updates the IEC_TIMER structure.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1697
For S7-1200 CPU
The "Time accumulator" instruction stores its data in a structure of the data type IEC_TIMER
or TONR_TIME. You can declare the structure as follows:
Declaration of a data block of system data type IEC_TIMER (for example, "MyIEC_TIMER")
Declaration as a local tag of the type TONR_TIME or IEC_TIMER in the "Static" section of
a block (for example, #MyIEC_TIMER)
For S7-1500 CPU
The "Time accumulator" instruction stores its data in a structure of the data type IEC_TIMER,
IEC_LTIMER, TONR_TIME or TONR_LTIME. You can declare the structure as follows:
Declaration of a data block of system data type IEC_TIMER or IEC_LTIMER (for example,
"MyIEC_TIMER")
Declaration as a local tag of the type TONR_TIME, TONR_LTIME, IEC_TIMER or
IEC_LTIMER in the "Static" section of a block (for example, #MyIEC_TIMER)
The instruction data is updated both when the instruction is called and also each time the
specified timer is accessed.
The current timer status is saved in the structure components ET of the IEC Timer. You can
query the timer status with the help of a binary logic operation. The query for Q or ET (e. g.
"MyTimer".Q or "MyTimer".ET) updates the IEC_TIMER structure.
The execution of the "Time accumulator" instruction requires a preceding logic operation. It
can be placed only at the end of the network.
Parameters
The following table shows the parameters of the "Time accumulator" instruction:
Parameters Declaration Data type Memory area Descripti
on
S7-1200 S7-1500
VALUE Input TIME TIME, LTIME I, Q, M, D, L or
constant
Duration
with
which
the IEC
Timer
runs.
<IEC Timer> InOut IEC_TIMER,
TONR_TIME
IEC_TIMER,
IEC_LTIMER,
TONR_TIME,
TONR_LTIME
D, L IEC
Timer
which is
started.
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1698 System Manual, 01/2013,
Example
The following example shows how the instruction works:
"Tag_lnput"
"MylEC_TlMER"
TONR
TlME
"Tag_TlME" VALUE
The "Time accumulator" instruction is executed if there is a positive signal edge in the RLO.
The time is recorded as long as the operand "Tag_Input" has the signal state "1".
"Tag_Output"
"MylEC_TlMER".Q =
If the recorded time exceeds the value of the operand "Tag_TIME", then the query of the timer
status ("MyIEC_TIMER".Q) will return the signal state "1" and the operand "Tag_Output" will
be set.
See also
Overview of the valid data types (Page 899)
RT: Reset timer (Page 1699)
RT: Reset timer
Description
You can use the "Reset timer" instruction to reset an IEC Timer to "0". You specify the IEC
Timer to be reset by entering the name of the data block that contains the structure of the IEC
Timer in the placeholder above the instruction.
The instruction is only executed if the result of logic operation (RLO) at the box input is "1".
When the instruction is executed the structure components of the IEC Timer are reset to "0"
in the specified data block. If the RLO at box input is "0", the instruction is not executed.
The instruction does not influence the RLO. The RLO at the box input is transferred directly to
the box output.
You must assign a IEC Timer declared in the program to the "Reset timer" instruction.
The instruction data is updated only when the instruction is called and not each time the
assigned IEC Timer is accessed. The query of the data is only identical from the call of the
instruction to the next call of the instruction.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1699
Parameters
The following table shows the parameters of the instruction "Reset timer":
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500
<IEC Timer> InOut IEC_TIMER,
TP_TIME,
TON_TIME,
TOF_TIME,
TONR_TIME
IEC_TIMER,
IEC_LTIMER,
TP_TIME,
TP_LTIME,
TON_TIME,
TON_LTIME,
TOF_TIME,
TOF_LTIME,
TONR_TIME,
TONR_LTIME
D, L IEC Timer,
which is reset.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
"Tag_lnput_1"
"TON_DB"
TON
TlME
lN
Q PT
ET
"Tag_Status"
"Tag_PT"
"Tag_ET"
=
The "Generate on-delay" instruction executes when the signal state of the "Tag_Input_1"
operand changes from "0" to "1". The IEC Timer stored in the instance data block "TON_DB"
is started with the time duration that is specified by the operand "Tag_PT".
RT
"Tag_lnput_2"
"TON_DB"
&
"Tag_lnput_3"
If the operands "Tag_Input_2" and "Tag_Input_3" have the signal state "1", the "Reset timer"
instruction is executed and the IEC Timer stored in the data block "TON_DB" is reset.
See also
Overview of the valid data types (Page 899)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1700 System Manual, 01/2013,
PT: Load time duration
Description
Use the "Load time duration" instruction to set the time duration of an IEC Timer. The instruction
is executed in every cycle when the result of logic operation (RLO) at the input of the instruction
has the signal state "1". The instruction writes the specified time duration to the structure of
the specified IEC Timer.
Note
If the specified IEC Timer is running during the execution, the instruction overwrites the
current time duration of the specified IEC Timer. As a result, the timer status of the IEC Timer
can change.
You must assign a IEC Timer declared in the program to the "Load time duration" instruction.
The instruction data is updated when the instruction is called and each time the assigned IEC
Timer is accessed. The query for Q or ET (e. g. "MyTimer".Q or "MyTimer".ET) updates the
IEC_TIMER structure.
Parameters
The following table shows the parameters of the instruction "Load time duration":
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500
PT Input TIME TIME, LTIME I, Q, M, D, L or
constant
Time duration
<IEC Timer> InOut IEC_TIMER,
TP_TIME,
TON_TIME,
TOF_TIME,
TONR_TIME
IEC_TIMER,
IEC_LTIMER,
TP_TIME,
TP_LTIME,
TON_TIME,
TON_LTIME,
TOF_TIME,
TOF_LTIME,
TONR_TIME,
TONR_LTIME
D, L IEC Timer, the
duration of
which is set.
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1701
Example
The following example shows how the instruction works:
"Tag_lnput_1"
"TON_DB"
TON
TlME
lN
Q PT
ET
"Tag_Status"
"Tag_PT"
"Tag_ET"
=
The "Generate on-delay" instruction executes when the signal state of the "Tag_Input_1"
operand changes from "0" to "1". The IEC Timer stored in the instance data block "TON_DB"
is started with the time duration that is specified by the operand "Tag_PT".
PT
"Tag_lnput_2"
"TON_DB"
"Tag_PT_2" PT
The "Load time duration" instruction is executed when the operand "Tag_Input_2" has the
signal state "1". The instruction writes the time duration "Tag_PT_2" in the instance data block
"TON_DB" and at the same time overwrites the value of the operand "Tag_PT" within the data
block. As a result, the signal state of the timer status can change at the next query or upon
access to "MyTimer".Q or "MyTimer".ET.
Note
The "Tag_Input_2" is executed as pulse flag in order that the time duration is loaded only
throughout one program cycle.
See also
Overview of the valid data types (Page 899)
SIMATIC Timers
S_PULSE: Assign pulse timer parameters and start
Description
The "Assign pulse timer parameters and start" instruction starts a programmed timer when a
transition from "0" to "1" (positive signal edge) is detected in the result of logic operation (RLO)
at input S. The timer expires with the programmed duration (TV) as long as the signal state at
input S is "1". If the signal state at input S changes to "0" before the programmed duration
expires, the timer is stopped. In this case, the signal state at output Q is "0".
The duration is made up internally of a timer value and a time base and is programmed at
parameter TV. When the instruction is started, the programmed timer value is counted down
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1702 System Manual, 01/2013,
to zero. The time base determines the time period of the timer value. The current timer value
is output binary-coded at output BI and BCD-coded at output BCD.
If the timer is running and the signal state at input R changes to "1", the current timer value
and the time base are also set to zero. If the timer is not running, the signal state "1" at the R
input has no effect.
The "Assign pulse timer parameters and start" instruction needs a preceding logic operation
for the edge evaluation and can be placed within or at the end of the network.
The instruction data is updated with each access. It can therefore happen that the query of the
data at the start of the cycle returns different values than at the end of the cycle.
Note
In each case, the instruction decrements a specific value by one unit in an interval that is
defined by its time basis until the time value is equal to "0". The decrementation takes place
asynchronous to the user program. The resulting timer is therefore always up to one time
interval shorter than the time base.
Parameters
The following table shows the parameters of the "Assign pulse timer parameters and start"
instruction:
Parameters Declaration Data type Memory area Description
<Timer> InOut/Input TIMER T Time of the
instruction
The number of
timers depends on
the CPU.
S Input BOOL I, Q, M, T, C, D, L,
P
Start input
TV Input S5TIME, WORD I, Q, M, D, L or
constant
Time duration
R Input BOOL I, Q, M, T, C, D, L,
P or constant
Reset input
BI Output WORD I, Q, M, D, L, P Current timer
value (binary-
coded)
BCD Output WORD I, Q, M, D, L, P Current timer
value (BCD
format)
Q Output BOOL I, Q, M, D, L, P Status of the timer
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1703
Timing diagram
The following figure shows the timing diagram of the "Assign pulse timer parameters and start"
instruction:
RLO at input S
Timer running
Query "1"
Query "0"
RLO at input R
t = programmed time
t t t
Example
The following example shows how the instruction works:
S_PULSE
=
Bl S
TV
R Q
BCD
"TagValue_1"
"TagValue_2"
"TagOut"
"Timer_1"
"Tagln_1"
"Tagln_Number"
"Tagln_2"
"Timer_1" starts when the signal state of the "TagIn_1" operand changes from "0" to "1". The
timer runs for the timer value of the "TagIn_Number" operand as long as the "TagIn_1" operand
has the signal state "1". If the signal state of the operand "TagIn_1" changes from "1" to "0"
before the timer expires, the timer "Timer_1" is stopped. The "TagOut" operand is reset to
signal state "0".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1704 System Manual, 01/2013,
The "TagOut" operand has the signal state "1" as long as the timer is running and the "TagIn_1"
operand has the signal state "1". When the time has expired or is reset, the "TagOut" operand
is reset to "0".
See also
Overview of the valid data types (Page 899)
S_PEXT: Assign extended pulse timer parameters and start
Description
The "Assign extended pulse timer parameters and start" instruction starts a programmed timer
when a transition from "0" to "1" (positive signal edge) is detected in the result of logic operation
(RLO) at input S. The timer expires with the programmed duration (TV), even if the signal state
at input S changes to "0". As long as the timer is running, output Q has the signal state "1".
When the timer has expired, output Q is reset to "0". If the signal state at input S changes from
"0" to "1" while the timer is running, the timer is restarted with the duration programmed at
input TV.
The duration is made up internally of a timer value and a time base and is programmed at
parameter TV. When the instruction is started, the programmed timer value is counted down
to zero. The time base determines the time period of the timer value. The current timer value
is output binary-coded at output BI and BCD-coded at output BCD.
If the timer is running and the signal state at input R changes to "1", the current timer value
and the time base are also set to zero. If the timer is not running, the signal state "1" at the R
input has no effect.
The "Assign extended pulse timer parameters and start" instruction needs a preceding logic
operation for the edge evaluation and can be placed within or at the end of the network.
The instruction data is updated with each access. It can therefore happen that the query of the
data at the start of the cycle returns different values than at the end of the cycle.
Note
In each case, the instruction decrements a specific value by one unit in an interval that is
defined by its time basis until the time value is equal to "0". The decrementation takes place
asynchronous to the user program. The resulting timer is therefore always up to one time
interval shorter than the time base.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1705
Parameters
The following table shows the parameters of the "Assign extended pulse timer parameters and
start" instruction:
Parameters Declaration Data type Memory area Description
<Timer> InOut/Input TIMER T Time of the
instruction
The number of
timers depends on
the CPU.
S Input BOOL I, Q, M, T, C, D, L,
P
Start input
TV Input S5TIME, WORD I, Q, M, D, L or
constant
Time duration
R Input BOOL I, Q, M, T, C, D, L,
P or constant
Reset input
BI Output WORD I, Q, M, D, L, P Current timer
value (binary-
coded)
BCD Output WORD I, Q, M, D, L, P Current timer
value (BCD
format)
Q Output BOOL I, Q, M, D, L, P Status of the timer
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1706 System Manual, 01/2013,
Timing diagram
The following figure shows the timing diagram of the "Assign extended pulse timer parameters
and start" instruction:
RLO at input S
Timer running
Query "1"
Query "0"
RLO at input R
t = programmed time
t t t
Example
The following example shows how the instruction works:
=
Bl S
TV
R Q
BCD
S_PEXT
"TagValue_1"
"TagValue_2"
"TagOut"
"Timer_1"
"Tagln_1"
"Tagln_Number"
"Tagln_2"
"Timer_1" starts when the signal state of the "TagIn_1" operand changes from "0" to "1". The
timer runs for the timer value of the "TagIn_Number" operand without being affected by a
negative edge at the S input. If the signal state at the "TagIn_1" operand changes from "0" to
"1" before the timer expires, the timer is restarted.
The "TagOut" operand has the signal state "1" as long as the timer is running. When the time
has expired or is reset, the "TagOut" operand is reset to "0".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1707
See also
Overview of the valid data types (Page 899)
S_ODT: Assign on-delay timer parameters and start
Description
The "Assign on-delay timer parameters and start" instruction starts a programmed timer when
a transition from "0" to "1" (positive signal edge) is detected in the result of logic operation
(RLO) at input S. The timer expires with the programmed duration (TV) as long as the signal
state at input S is "1". If the timer has expired correctly and input S still has signal state "1",
output Q returns signal state "1". If the signal state at input S changes from "1" to "0" while the
timer is running, the timer is stopped. In this case, output Q is reset to signal state "0".
The duration is made up internally of a timer value and a time base and is programmed at
parameter TV. When the instruction is started, the programmed timer value is counted down
to zero. The time base determines the time period of the timer value. The current timer value
is output binary-coded at output BI and BCD-coded at output BCD.
If the time is running and the signal state at input R changes from "0" to "1", the current timer
value and the time base are also set to zero. In this case, the signal state at output Q is "0".
The timer is reset if the signal state is "1" at the R input even if the timer is not running and the
RLO at input S is "1".
The "Assign on-delay timer parameters and start" instruction needs a preceding logic operation
for the edge evaluation and can be placed within or at the end of the network.
The instruction data is updated with each access. It can therefore happen that the query of the
data at the start of the cycle returns different values than at the end of the cycle.
Note
In each case, the instruction decrements a specific value by one unit in an interval that is
defined by its time basis until the time value is equal to "0". The decrementation takes place
asynchronous to the user program. The resulting timer is therefore always up to one time
interval shorter than the time base.
Parameters
The following table shows the parameters of the "Assign on-delay timer parameters and start"
instruction:
Parameters Declaration Data type Memory area Description
<Timer> InOut/Input TIMER T Time of the
instruction
The number of
timers depends on
the CPU.
S Input BOOL I, Q, M, T, C, D, L,
P
Start input
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1708 System Manual, 01/2013,
Parameters Declaration Data type Memory area Description
TV Input S5TIME, WORD I, Q, M, D, L or
constant
Time duration
R Input BOOL I, Q, M, T, C, D, L,
P or constant
Reset input
BI Output WORD I, Q, M, D, L, P Current timer
value (binary-
coded)
BCD Output WORD I, Q, M, D, L, P Current timer
value (BCD
format)
Q Output BOOL I, Q, M, D, L, P Status of the timer
For additional information on valid data types, refer to "See also".
Timing diagram
The following figure shows the timing diagram of the "Assign on-delay timer parameters and
start" instruction:
RLO at input S
Timer running
Query "1"
Query "0"
RLO at input R
t = programmed time
t t t
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1709
Example
The following example shows how the instruction works:
=
Bl S
TV
R Q
BCD
S_ODT
"TagValue_1"
"TagValue_2"
"TagOut"
"Timer_1"
"Tagln_1"
"Tagln_Number"
"Tagln_2"
"Timer_1" starts when the signal state of the "TagIn_1" operand changes from "0" to "1". The
timer expires with the value of operand "TagIn_Number". If the timer has expired and the signal
state of the operand is "1", the "TagOut" operand is set to "1". If the signal state at the "TagIn_1"
operand changes from "1" to "0" before the timer expires, the timer is stopped. The "TagOut"
operand has the signal state "0".
See also
Overview of the valid data types (Page 899)
S_ODTS: Assign retentive on-delay timer parameters and start
Description
The "Assign retentive on-delay timer parameters and start" instruction starts a programmed
timer when a transition from "0" to "1" (positive signal edge) is detected in the result of logic
operation (RLO) at input S. The timer expires with the programmed duration (TV), even if the
signal state at input S changes to "0". If the timer has expired, the "Q" output returns signal
state "1" regardless of the signal state at input "S". If the signal state at input S changes from
"0" to "1" while the timer is running, the timer is restarted with the duration programmed at
input (TV).
The duration is made up internally of a timer value and a time base and is programmed at
parameter TV. When the instruction is started, the programmed timer value is counted down
to zero. The time base determines the time period of the timer value. The current timer value
is output binary-coded at output BI and BCD-coded at output BCD.
Signal state "1" at input R resets the current timer value and time base to "0" regardless of the
signal state at start input S. In this case, the signal state at output Q is "0".
The "Assign retentive on-delay timer parameters and start" instruction needs a preceding logic
operation for the edge evaluation and can be placed within or at the end of the network.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1710 System Manual, 01/2013,
The instruction data is updated with each access. It can therefore happen that the query of the
data at the start of the cycle returns different values than at the end of the cycle.
Note
In each case, the instruction decrements a specific value by one unit in an interval that is
defined by its time basis until the time value is equal to "0". The decrementation takes place
asynchronous to the user program. The resulting timer is therefore always up to one time
interval shorter than the time base.
Parameters
The following table shows the parameters of the "Assign retentive on-delay timer parameters
and start" instruction:
Parameters Declaration Data type Memory area Description
<Timer> InOut/Input TIMER T Time of the
instruction
The number of
timers depends on
the CPU.
S Input BOOL I, Q, M, T, C, D, L,
P
Start input
TV Input S5TIME, WORD I, Q, M, D, L or
constant
Time duration
R Input BOOL I, Q, M, T, C, D, L,
P or constant
Reset input
BI Output WORD I, Q, M, D, L, P Current timer
value (binary-
coded)
BCD Output WORD I, Q, M, D, L, P Current timer
value (BCD
format)
Q Output BOOL I, Q, M, D, L, P Status of the timer
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1711
Timing diagram
The following figure shows the timing diagram of the "Assign retentive on-delay timer
parameters and start" instruction:
RLO at input S
Timer running
Query "1"
Query "0"
RLO at input R
t = programmed time
t t t
Example
The following example shows how the instruction works:
=
Bl S
TV
R Q
BCD
S_ODTS
"TagValue_1"
"TagValue_2"
"TagOut"
"Timer_1"
"Tagln_1"
"Tagln_Number"
"Tagln_2"
"Timer_1" starts when the signal state of the "TagIn_1" operand changes from "0" to "1". The
timer expires with the timer value of the "TagIn_Number" operand, even when the signal state
of the "TagIn_1" operand changes to "0". When the time expires, the "TagOut" operand is reset
to "1". If the signal state at the "TagIn_1" operand changes from "0" to "1" while the timer is
running, the timer is restarted.
See also
Overview of the valid data types (Page 899)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1712 System Manual, 01/2013,
S_OFFDT: Assign off-delay timer parameters and start
Description
The "Assign off-delay timer parameters and start" instruction starts a programmed timer when
a transition from "1" to "0" (negative signal edge) is detected in the result of logic operation
(RLO) at input S. The timer expires with the programmed duration (TV). As long as the timer
is running or input S returns signal state "1", output Q has signal state "1". If the timer has
expired and the signal state is "0", output Q is reset to signal state "0". If the signal state at
input S changes from "0" to "1" while the timer is running, the timer is stopped. The timer is
only restarted after a falling signal edge is detected at input S.
The duration is made up internally of a timer value and a time base and is programmed at
parameter TV. When the instruction is started, the programmed timer value is counted down
to zero. The time base determines the time period of the timer value. The current timer value
is output binary-coded at output BI and BCD-coded at output BCD.
Signal state "1" at input R resets the current timer value and time base to "0". In this case, the
signal state at output Q is "0".
The "Assign off-delay timer parameters and start" instruction needs a preceding logic operation
for the edge evaluation and can be placed within or at the end of the network.
The instruction data is updated with each access. It can therefore happen that the query of the
data at the start of the cycle returns different values than at the end of the cycle.
Note
In each case, the instruction decrements a specific value by one unit in an interval that is
defined by its time basis until the time value is equal to "0". The decrementation takes place
asynchronous to the user program. The resulting timer is therefore always up to one time
interval shorter than the time base.
Parameters
The following table shows the parameters of the "Assign off-delay timer parameters and start"
instruction:
Parameters Declaration Data type Memory area Description
<Timer> InOut/Input TIMER T Time of the
instruction
The number of
timers depends on
the CPU.
S Input BOOL I, Q, M, T, C, D, L,
P
Start input
TV Input S5TIME, WORD I, Q, M, D, L or
constant
Time duration
R Input BOOL I, Q, M, T, C, D, L,
P or constant
Reset input
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1713
Parameters Declaration Data type Memory area Description
BI Output WORD I, Q, M, D, L, P Current timer
value (binary-
coded)
BCD Output WORD I, Q, M, D, L, P Current timer
value (BCD
format)
Q Output BOOL I, Q, M, D, L, P Status of the timer
For additional information on valid data types, refer to "See also".
Timing diagram
The following figure shows the timing diagram of the "Assign off-delay timer parameters and
start" instruction:
RLO at input S
Timer running
Query "1"
Query "0"
RLO at input R
t = programmed time
t t t t
Example
The following example shows how the instruction works:
=
Bl S
TV
R Q
BCD
S_OFFDT
"TagValue_1"
"TagValue_2"
"TagOut"
"Timer_1"
"Tagln_1"
"Tagln_Number"
"Tagln_2"
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1714 System Manual, 01/2013,
"Timer_1" starts when the signal state of the "TagIn_1" operand changes from "1" to "0". The
timer expires with the value of operand "TagIn_Number". The "TagOut" operand is set to "1"
if the timer is running or the "TagIn_1" operand has the signal state "0". If the signal state at
the "TagIn_1" operand changes from "0" to "1" while the timer is running, the timer is reset.
See also
Overview of the valid data types (Page 899)
SP: Start pulse timer
Description
The instruction "Start pulse timer" starts a programmed timer when a change from "0" to "1"
(positive signal edge) is detected in the result of logic operation (RLO) at the start input. The
timer runs with the specified duration as long as the RLO has the signal state "1". As long as
the timer is running, the query of timer status "1" returns the signal state "1". If there is a change
from "1" to "0" in the RLO before the timer value has elapsed, the timer stops. In this case, the
query for timer status for "1" returns the signal state "0".
The duration is made up internally of a timer value and a time base and is programmed at
parameter TV. When the instruction is started, the programmed timer value is counted down
to zero. The time base determines the time period of the timer value.
The "Start pulse timer" instruction needs a preceding logic operation for the edge evaluation
and can only be placed on the right edge of the network.
Note
In each case, the instruction decrements a specific value by one unit in an interval that is
defined by its time basis until the time value is equal to "0". The decrementation takes place
asynchronous to the user program. The resulting timer is therefore always up to one time
interval shorter than the time base.
Parameters
The following table shows the parameters of the instruction "Start pulse timer":
Parameters Declaration Data type Memory area Description
<Operand> Input BOOL I, Q, M, T, C, D, L,
P
Start input
TV Input S5TIME, WORD I, Q, M, D, L or
constant
Time duration
<Timer> InOut/Input TIMER T Timer which is
started.
The number of
timers depends on
the CPU.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1715
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
SP
TV
Network 1
Network 2
Network 3
"Tagln_1"
"Tagln_2"
"Timer_1"
"Timer_1"
"Timer_1"
"Tagln_Number"
=
"TagOut"
R
"Timer_1" starts when the signal state of the "TagIn_1" operand changes from "0" to "1". The
timer expires with the timer value of the "TagIn_Number" operand as long as the signal state
of the "TagIn_1" operand is "1". If the signal state at the "TagIn_1" operand changes from "1"
to "0" before the timer expires, the timer is stopped. As long as the timer is running, the "TagOut"
operand returns signal state "1". If the signal state of the "TagIn_1" operand changes from "0"
to "1", the timer is reset, i.e. the timer is stopped and the current timer value is set to "0".
See also
Overview of the valid data types (Page 899)
SE: Start extended pulse timer
Description
The "Start extended pulse timer" instruction starts a programmed timer when a change from
"0" to "1" (positive signal edge) is detected in the result of logic operation (RLO) at the start
input. The timer runs for the specified time period even when the RLO changes to signal state
"0". As long as the timer is running, the query of timer status "1" returns the signal state "1". If
the RLO changes from "0" to "1" while the timer is running, the timer is restarted with the
programmed time period. When the timer expires, the query for timer status for "1" returns the
signal state "0".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1716 System Manual, 01/2013,
The duration is made up internally of a timer value and a time base and is programmed at
parameter TV. When the instruction is started, the programmed timer value is counted down
to zero. The time base determines the time period of the timer value.
The "Start extended pulse timer" instruction needs a preceding logic operation for the edge
evaluation and can only be placed on the right edge of the network.
Note
In each case, the instruction decrements a specific value by one unit in an interval that is
defined by its time basis until the time value is equal to "0". The decrementation takes place
asynchronous to the user program. The resulting timer is therefore always up to one time
interval shorter than the time base.
Parameters
The following table shows the parameters of the instruction "Start extended pulse timer":
Parameters Declaration Data type Memory area Description
<Operand> Input BOOL I, Q, M, T, C, D, L,
P
Start input
TV Input S5TIME, WORD I, Q, M, D, L or
constant
Time duration
<Timer> InOut/Input TIMER T Timer which is
started.
The number of
timers depends on
the CPU.
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1717
Example
The following example shows how the instruction works:
SE
TV
Network 1
Network 2
Network 3
"Tagln_1"
"Tagln_2"
"Timer_1"
"Timer_1"
"Timer_1"
"Tagln_Number"
=
"TagOut"
R
"Timer_1" starts when the signal state of the "TagIn_1" operand changes from "0" to "1". The
timer expires with the timer value of the "TagIn_Number" operand without being affected by a
negative edge at the RLO. As long as the timer is running, the "TagOut" operand returns signal
state "1". If the signal state at the "TagIn_1" operand changes from "0" to "1" before the timer
expires, the timer is restarted.
See also
Overview of the valid data types (Page 899)
SD: Start on-delay timer
Description
The "Start on-delay timer" instruction starts a programmed timer when a change from "0" to
"1" (positive signal edge) is detected in the result of logic operation (RLO) at the start input.
The timer runs for the specified period of time as long as the RLO is "1". If the timer has expired
and the RLO has the signal state "1", the query timer status "1" returns the signal state "1". If
the RLO changes from "1" to "0" while the timer is running, the timer is stopped. In this case,
querying the timer status for "1" returns the signal state "0".
The duration is made up internally of a timer value and a time base and is programmed at
parameter TV. When the instruction is started, the programmed timer value is counted down
to zero. The time base determines the time period of the timer value.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1718 System Manual, 01/2013,
The "Start on-delay timer" instruction needs a preceding logic operation for the edge evaluation
and can only be placed on the right edge of the network.
Note
In each case, the instruction decrements a specific value by one unit in an interval that is
defined by its time basis until the time value is equal to "0". The decrementation takes place
asynchronous to the user program. The resulting timer is therefore always up to one time
interval shorter than the time base.
Parameters
The following table shows the parameters of the instruction "Start on-delay timer":
Parameters Declaration Data type Memory area Description
<Operand> Input BOOL I, Q, M, T, C, D, L,
P
Start input
TV Input S5TIME, WORD I, Q, M, D, L or
constant
Time duration
<Timer> InOut/Input TIMER T Timer which is
started.
The number of
timers depends on
the CPU.
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1719
Example
The following example shows how the instruction works:
SD
TV
Network 1
Network 2
Network 3
"Tagln_1"
"Tagln_2"
"Timer_1"
"Timer_1"
"Timer_1"
"Tagln_Number"
=
"TagOut"
R
"Timer_1" starts when the signal state of the "TagIn_1" operand changes from "0" to "1". The
timer expires with the value of operand "TagIn_Number". If the timer has expired and the RLO
has the signal state "1", the "TagOut" operand is set to "1". If the signal state at the "TagIn_1"
operand changes from "1" to "0" before the timer expires, the timer is stopped. If the signal
state of the "TagIn_2" operand changes to "1", "Timer_1" is reset, i.e. the timer is stopped and
the current timer value is set to "0".
See also
Overview of the valid data types (Page 899)
SS: Start retentive on-delay timer
Description
The "Start retentive on-delay timer" instruction starts a programmed timer when a change from
"0" to "1" (positive signal edge) is detected in the result of logic operation (RLO) at the start
input. The timer runs for the specified time period even when the RLO changes to signal state
"0". When the timer expires, the query for timer status for "1" returns the signal state "1". When
the timer expires, the timer can only be restarted if it is explicitly reset.
The duration is made up internally of a timer value and a time base and is programmed at
parameter TV. When the instruction is started, the programmed timer value is counted down
to zero. The time base determines the time period of the timer value.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1720 System Manual, 01/2013,
The "Start retentive on-delay timer" instruction needs a preceding logic operation for the edge
evaluation and can only be placed on the right edge of the network.
Note
In each case, the instruction decrements a specific value by one unit in an interval that is
defined by its time basis until the time value is equal to "0". The decrementation takes place
asynchronous to the user program. The resulting timer is therefore always up to one time
interval shorter than the time base.
Parameters
The following table shows the parameters of the instruction "Start retentive on-delay timer":
Parameters Declaration Data type Memory area Description
<Operand> Input BOOL I, Q, M, T, C, D, L,
P
Start input
TV Input S5TIME, WORD I, Q, M, D, L or
constant
Time duration
<Timer> InOut/Input TIMER T Timer which is
started.
The number of
timers depends on
the CPU.
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1721
Example
The following example shows how the instruction works:
SS
TV
Network 1
Network 2
Network 3
"Tagln_1"
"Tagln_2"
"Timer_1"
"Timer_1"
"Timer_1"
"Tagln_Number"
=
"TagOut"
R
"Timer_1" starts when the signal state of the "TagIn_1" operand changes from "0" to "1". The
timer expires with the value of operand "TagIn_Number". When the time expires, the "TagOut"
operand is reset to "1". If the signal state at the "TagIn_1" operand changes from "0" to "1"
while the timer is running, the timer is restarted. If the signal state of the "TagIn_2" operand
changes to "1", "Timer_1" is reset, i.e. the timer is stopped and the current timer value is set
to "0".
See also
Overview of the valid data types (Page 899)
SF: Start off-delay timer
Description
The "Start off-delay timer" instruction starts a programmed timer when a change from "1" to
"0" (negative signal edge) is detected in the result of logic operation (RLO) at the start input.
The timer runs for the specified time period. As long as the timer is running, the query of timer
status "1" returns the signal state "1". If the RLO changes from "0" to "1" while the timer is
running, the timer is reset. The timer is always restarted when the RLO changes from "1" to
"0".
The duration is made up internally of a timer value and a time base and is programmed at
parameter TV. When the instruction is started, the programmed timer value is counted down
to zero. The time base determines the time period of the timer value.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1722 System Manual, 01/2013,
The "Start off-delay timer" instruction needs a preceding logic operation for the edge evaluation
and can only be placed on the right edge of the network.
Note
In each case, the instruction decrements a specific value by one unit in an interval that is
defined by its time basis until the time value is equal to "0". The decrementation takes place
asynchronous to the user program. The resulting timer is therefore always up to one time
interval shorter than the time base.
Parameters
The following table shows the parameters of the instruction "Start off-delay timer":
Parameters Declaration Data type Memory area Description
<Operand> Input BOOL I, Q, M, T, C, D, L,
P
Start input
TV Input S5TIME, WORD I, Q, M, D, L or
constant
Time duration
<Timer> InOut/Input TIMER T Timer which is
started.
The number of
timers depends on
the CPU.
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1723
Example
The following example shows how the instruction works:
SF
TV
Network 1
Network 2
Network 3
"Tagln_1"
"Tagln_2"
"Timer_1"
"Timer_1"
"Timer_1"
"Tagln_Number"
=
"TagOut"
R
"Timer_1" starts when the signal state of the "TagIn_1" operand changes from "1" to "0". The
timer expires with the value of operand "TagIn_Number". As long as the timer is running, the
"TagOut" operand is set to "1". If the signal state at the "TagIn_1" operand changes from "1"
to "0" while the timer is running, the timer is restarted. If the signal state of the "TagIn_2"
operand changes to "1", "Timer_1" is reset, i.e. the timer is stopped and the current timer value
is set to "0".
See also
Overview of the valid data types (Page 899)
Counter operations
IEC Counters
CTU: Count up
Description
You can use the "Count up" instruction to increment the value at output CV. When the signal
state at the CU input changes from "0" to "1" (positive signal edge), the instruction is executed
and the current counter value at the CV output is incremented by one. When the instruction
executes for the first time, the current counter value at the CV output is set to zero. The counter
is incremented each time a positive signal edge is detected, until it reaches the high limit for
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1724 System Manual, 01/2013,
the specified data type at output CV. When the high limit is reached, the signal state at the CU
input no longer has an effect on the instruction.
You can scan the counter status at the Q output. The signal state at the Q output is determined
by the PV parameter. If the current counter value is greater than or equal to the value of the
PV parameter, the Q output is set to signal state "1". In all other cases, the Q output has signal
state "0". You can also specify a constant for the PV parameter.
The value at the CV output is reset to "0" and saved to an edge memory bit when the signal
state at input R changes to "1". As long as the R input has signal state "1", the signal state at
the CU input has no effect on the instruction.
Note
Avoid using a counter at more than one point in the program (risk of counting errors).
Each call of the "Count up" instruction must be assigned to an IEC Counter in which the
instruction data is stored. An IEC Counter is a structure with one of the following data types:
For S7-1200 CPU
Data block of system data type IEC_counter
(global DB)
Local tag
IEC_SCOUNTER / IEC_USCOUNTER
IEC_COUNTER / IEC_UCOUNTER
IEC_DCOUNTER / IEC_UDCOUNTER
CTU_SINT / CTU_USINT
CTU_INT / CTU_UINT
CTU_DINT / CTU_UDINT
IEC_SCOUNTER / IEC_USCOUNTER
IEC_COUNTER / IEC_UCOUNTER
IEC_DCOUNTER / IEC_UDCOUNTER
For S7-1500 CPU
Data block of system data type IEC_counter
(global DB)
Local tag
IEC_SCOUNTER / IEC_USCOUNTER
IEC_COUNTER / IEC_UCOUNTER
IEC_DCOUNTER / IEC_UDCOUNTER
IEC_LCOUNTER / IEC_ULCOUNTER
CTU_SINT / CTU_USINT
CTU_INT / CTU_UINT
CTU_DINT / CTU_UDINT
CTU_LINT / CTU_ULINT
IEC_SCOUNTER / IEC_USCOUNTER
IEC_COUNTER / IEC_UCOUNTER
IEC_DCOUNTER / IEC_UDCOUNTER
IEC_LCOUNTER / IEC_ULCOUNTER
You can declare an IEC Counter as follows:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1725
Declaration of a data block of system data type IEC_COUNTER (for example,
"MyIEC_COUNTER")
Declaration as a local tag of the type CTU or IEC_COUNTER in the "Static" section of a
block (for example, #MyIEC_COUNTER)
When you insert the instruction in the program, the "Call options" dialog opens in which you
can specify whether the IEC Counter is stored in its own data block (single instance) or as a
local tag (multiple instance) in the block interface. If you create a separate data block, it is
saved to the "Program resources" folder in the "Program blocks > System blocks" path of the
project tree. For additional information on this topic, refer to "See also".
The execution of the "Count up" instruction requires a preceding logic operation. It can be
placed within or at the end of the network.
Parameters
The following table shows the parameters of the "Count up" instruction:
Parameters Declaration Data type Memory area Description
CU Input BOOL I, Q, M, D, L or
constant
Count input
R Input BOOL I, Q, M, T, C, D, L,
P or constant
Reset input
PV Input Integers I, Q, M, D, L, P or
constant
Value at which the
output Q is set.
Q Output BOOL I, Q, M, D, L Counter status
CV Output Integers, CHAR,
DATE
I, Q, M, D, L, P Current counter
value
You can select the data type of the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
CU
R
PV Q
CV
"Tagln_1"
"Tagln_2"
"Tag_PV"
"Tag_CV"
"TagOut"
CTU
lNT
"CTU_DB"
When the signal state of the "TagIn_1" operand changes from "0" to "1", the "Count up"
instruction executes and the current counter value of the "Tag_CV" operand is incremented
by one. With each additional positive signal edge, the counter value is incremented until the
high limit of the specified data type (INT = 32767) is reached.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1726 System Manual, 01/2013,
The value of the PV parameter is adopted as the limit for determining the "TagOut" output.
The "TagOut" output has signal state "1" as long as the current counter value is greater than
or equal to the value of the "Tag_PV" operand. In all other cases, the "TagOut" output returns
the signal state "0".
See also
Overview of the valid data types (Page 899)
CTD: Count down
Description
You can use the "Count down" instruction to decrement the value at output CV. When the
signal state at the CD input changes from "0" to "1" (positive signal edge), the instruction is
executed and the current counter value at the CV output is decremented by one. When the
instruction executes the first time, the counter value of the CV parameter will be set to the
value of the PV parameter. Each time a positive signal edge is detected, the counter value is
decremented until it reaches the low limit value of the specified data type. When the low limit
is reached, the signal state at the CD input no longer has an effect on the instruction.
You can scan the counter status at the Q output. If the current counter value is less than or
equal to "0", the Q output is set to signal state "1". In all other cases, the Q output has signal
state "0". You can also specify a constant for the PV parameter.
The value at the CV output is set to the value of the PV parameter and saved to a edge memory
bit when the signal state at the LD input changes from "0" to "1". As long as the LD input has
signal state "1", the signal state at the CD input has no effect on the instruction.
Note
Avoid using a counter at more than one point in the program (risk of counting errors).
Each call of the "Count down" instruction must be assigned to an IEC Counter in which the
instruction data is stored. An IEC Counter is a structure with one of the following data types:
For S7-1200 CPU
Data block of system data type IEC_counter
(global DB)
Local tag
IEC_SCOUNTER / IEC_USCOUNTER
IEC_COUNTER / IEC_UCOUNTER
IEC_DCOUNTER / IEC_UDCOUNTER
CTD_SINT / CTD_USINT
CTD_INT / CTD_UINT
CTD_DINT / CTD_UDINT
IEC_SCOUNTER / IEC_USCOUNTER
IEC_COUNTER / IEC_UCOUNTER
IEC_DCOUNTER / IEC_UDCOUNTER
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1727
For S7-1500 CPU
Data block of system data type IEC_counter
(global DB)
Local tag
IEC_SCOUNTER / IEC_USCOUNTER
IEC_COUNTER / IEC_UCOUNTER
IEC_DCOUNTER / IEC_UDCOUNTER
IEC_LCOUNTER / IEC_ULCOUNTER
CTD_SINT / CTD_USINT
CTD_INT / CTD_UINT
CTD_DINT / CTD_UDINT
CTD_LINT / CTD_ULINT
IEC_SCOUNTER / IEC_USCOUNTER
IEC_COUNTER / IEC_UCOUNTER
IEC_DCOUNTER / IEC_UDCOUNTER
IEC_LCOUNTER / IEC_ULCOUNTER
You can declare an IEC Counter as follows:
Declaration of a data block of system data type IEC_COUNTER (for example,
"MyIEC_COUNTER")
Declaration as a local tag of the type CTD or IEC_COUNTER in the "Static" section of a
block (for example, #MyIEC_COUNTER)
When you insert the instruction in the program, the "Call options" dialog opens in which you
can specify whether the IEC Counter is stored in its own data block (single instance) or as a
local tag (multiple instance) in the block interface. If you create a separate data block, it is
saved to the "Program resources" folder in the "Program blocks > System blocks" path of the
project tree. For additional information on this topic, refer to "See also".
The execution of the "Count down" instruction requires a preceding logic operation. It can be
placed within or at the end of the network.
Parameters
The following table shows the parameters of the "Count down" instruction:
Parameters Declaration Data type Memory area Description
CD Input BOOL I, Q, M, D, L or
constant
Count input
LD Input BOOL I, Q, M, T, C, D, L,
P or constant
Load input
PV Input Integers I, Q, M, D, L, P or
constant
Value at which the
output Q is set.
Q Output BOOL I, Q, M, D, L Counter status
CV Output Integers, CHAR,
DATE
I, Q, M, D, L, P Current counter
value
You can select the data type of the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1728 System Manual, 01/2013,
Example
The following example shows how the instruction works:
CD
LD
PV Q
CV
"Tagln_1"
"Tagln_2"
"Tag_PV"
"Tag_CV"
"TagOut"
CTD
lNT
"CTD_DB"
When the signal state of the "TagIn_1" operand changes from "0" to "1", the "Count down"
instruction executes and the value at the "Tag_CV" output is decremented by one. With each
additional positive signal edge, the counter value is decremented until the low limit of the
specified data type (INT = -32768) is reached.
The value of the PV parameter is adopted as the limit for determining the "TagOut" output.
The "TagOut" output has signal state "1" as long as the current counter value is less than or
equal to "0". In all other cases, the "TagOut" output returns the signal state "0".
See also
Overview of the valid data types (Page 899)
CTUD: Count up and down
Description
You can use the "Count up and down" instruction to increment and decrement the counter
value at the CV output. If the signal state at the CU input changes from "0" to "1" (positive
signal edge), the current counter value is incremented by one and stored at the CV output. If
the signal state at the CD input changes from "0" to "1" (positive signal edge), the current
counter value at the CV output is decremented by one. If there is a positive signal edge at the
CU and CD inputs in one program cycle, the current counter value at the CV output remains
unchanged.
The counter can be incremented until it reaches the high limit value of the data type specified
at output CV. When the high limit value is reached, the counter value is no longer incremented
on a positive signal edge. When the low limit value of the specified data type is reached, the
counter value is not decremented any further.
When the signal state at the LD input changes to "1", the counter value at the CV output is set
to the value of the PV parameter and stored in a edge memory bit. As long as the LD input
has signal state "1", the signal state at the CU and CD inputs has no effect on the instruction.
The counter value is set to "0" and stored in an edge memory bit when the signal state at input
R changes to "1". As long as the R input has signal state "1", a change in the signal state of
the CU, CD and LD inputs has no effect on the "Count up and down" instruction.
You can scan the current status of the up counter at the QU output. If the current counter value
is greater than or equal to the value of the PV parameter, the QU output is set to signal state
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1729
"1". In all other cases, the QU output has signal state "0". You can also specify a constant for
the PV parameter.
You can scan the current status of the down counter at the QD output. If the current counter
value is less than or equal to zero, the QD output is set to signal state "1". In all other cases,
the QD output has signal state "0".
Note
Avoid using a counter at more than one point in the program (risk of counting errors).
Each call of the "Count up and down" instruction must be assigned an IEC Counter in which
the instruction data is stored. An IEC Counter is a structure with one of the following data types:
For S7-1200 CPU
Data block of system data type IEC_counter
(global DB)
Local tag
IEC_SCOUNTER / IEC_USCOUNTER
IEC_COUNTER / IEC_UCOUNTER
IEC_DCOUNTER / IEC_UDCOUNTER
CTUD_SINT / CTUD_USINT
CTUD_INT / CTUD_UINT
CTUD_DINT / CTUD_UDINT
IEC_SCOUNTER / IEC_USCOUNTER
IEC_COUNTER / IEC_UCOUNTER
IEC_DCOUNTER / IEC_UDCOUNTER
For S7-1500 CPU
Data block of system data type IEC_counter
(global DB)
Local tag
IEC_SCOUNTER / IEC_USCOUNTER
IEC_COUNTER / IEC_UCOUNTER
IEC_DCOUNTER / IEC_UDCOUNTER
IEC_LCOUNTER / IEC_ULCOUNTER
CTUD_SINT / CTUD_USINT
CTUD_INT / CTUD_UINT
CTUD_DINT / CTUD_UDINT
CTUD_LINT / CTUD_ULINT
IEC_SCOUNTER / IEC_USCOUNTER
IEC_COUNTER / IEC_UCOUNTER
IEC_DCOUNTER / IEC_UDCOUNTER
IEC_LCOUNTER / IEC_ULCOUNTER
You can declare an IEC Counter as follows:
Declaration of a data block of system data type IEC_COUNTER (for example,
"MyIEC_COUNTER")
Declaration as a local tag of the type CTUD or IEC_COUNTER in the "Static" section of a
block (for example, #MyIEC_COUNTER)
When you insert the instruction in the program, the "Call options" dialog opens in which you
can specify whether the IEC Counter is stored in its own data block (single instance) or as a
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1730 System Manual, 01/2013,
local tag (multiple instance) in the block interface. If you create a separate data block, it is
saved to the "Program resources" folder in the "Program blocks > System blocks" path of the
project tree. For additional information on this topic, refer to "See also".
The execution of the "Count up and down" instruction requires a preceding logic operation. It
can be placed within or at the end of the network.
Parameters
The following table shows the parameters of the "Count up and down" instruction:
Parameters Declaration Data type Memory area Description
CU Input BOOL I, Q, M, D, L or
constant
Count up input
CD Input BOOL I, Q, M, D, L or
constant
Count down input
R Input BOOL I, Q, M, T, C, D, L,
P or constant
Reset input
LD Input BOOL I, Q, M, T, C, D, L,
P or constant
Load input
PV Input Integers I, Q, M, D, L, P or
constant
Value at which the
output QU is set.
QU Output BOOL I, Q, M, D, L Up-counter status
QD Output BOOL I, Q, M, D, L Down-counter
status
CV Output Integers, CHAR,
DATE
I, Q, M, D, L, P Current counter
value
You can select the data type of the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
CU
LD
PV QU
CV
CD
R QD
"Tagln_CU"
"Tagln_CD"
"Tagln_R"
"Tagln_LD"
"Tag_PV"
"Tag_CV"
"TagOut_QU"
"TagOut_QD"
CTUD
lNT
"CTUD_DB"
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1731
If the signal state at the "TagIn_CU" or "TagIn_CD" input changes from "0" to "1" (positive
signal edge), the "Count up and down" instruction is executed. When there is a positive signal
edge at the "TagIn_CU" input, the current counter value is incremented by one and stored at
the "Tag_CV" output. When there is a positive signal edge at the "TagIn_CD" input, the counter
value is decremented by one and stored at the "Tag_CV" output. When there is a positive edge
at the CU input, the counter value is incremented until it reaches the high limit value (INT =
32767). If input CD has a positive signal edge, the counter value is decremented until it reaches
the low limit value (INT = -32768).
The "TagOut_GU" output has signal state "1" as long as the current counter value is greater
than or equal to the value at the "Tag_PV" input. In all other cases, the "TagOut_QU" output
returns the signal state "0".
The "TagOut_QD" output has signal state "1" as long as the current counter value is less than
or equal to "0". In all other cases, the "TagOut_QD" output has signal state "0".
See also
Overview of the valid data types (Page 899)
Example of detecting the fill level of a storage area (Page 1399)
SIMATIC counters
S_CUD: Assign parameters and count up / down
Description
You can use the "Assign parameters and count up / down" instruction to increment or
decrement the value of a counter. If the signal state at the CU input changes from "0" to "1"
(positive signal edge), the current counter value is incremented by one. If the signal state at
the CD input changes from "0" to "1" (positive signal edge), the counter value is decremented
by one. The current counter value is output as a hexadecimal value at output CV and BCD-
coded at output CV_BCD. If there is a positive signal edge at the CU and CD inputs in one
program cycle, the counter value remains unchanged.
The counter value is incremented until the high limit of "999" is reached. When the high limit
value is reached, the counter value is no longer incremented on a positive signal edge. When
the low limit of "0" is reached, the counter value is no longer decremented.
When the signal state at input S changes from "0" to "1", the counter value is set to the value
of the PV parameter. If the counter is set and if RLO is "1" at the inputs CU and CD, the counter
counts accordingly in the next scan cycle, even if no change in the signal edge is detected.
The counter value is set to zero when the signal state at the R input changes to "1". As long
as the R input has the signal state "1", processing of the signal state of the CU, CD and S
inputs has no effect on the counter value.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1732 System Manual, 01/2013,
The signal state at output Q is "1" if the counter value is greater than zero. If the counter value
is equal to zero, output Q has the signal state "0".
Note
Avoid using a counter at more than one point in the program (risk of counting errors).
The "Assign parameters and count up / down" instruction needs a preceding logic operation
for the edge evaluation and can be placed within or at the end of the network.
Parameters
The following table shows the parameters of the "Assign parameters and count up / down"
instruction:
Parameters Declaration Data type Memory area Description
<Counter> InOut/Input COUNTER C Counter of the
instruction
The number of
counters depends
on the CPU.
CU Input BOOL I, Q, M, D, L, T, C Count up input
CD Input BOOL I, Q, M, D, L, T, C
or constant
Count down input
S Input BOOL I, Q, M, D, L, T, C
or constant
Input for
presetting counter
PV Input WORD I, Q, M, D, L, C or
constant
Preset counter
value (C#0 to
C#999)
R Input BOOL I, Q, M, D, L, T, C
or constant
Reset input
CV Output WORD, S5TIME,
DATE
I, Q, M, D, L Current counter
value
(hexadecimal)
CV_BCD Output WORD, S5TIME,
DATE
I, Q, M, D, L Current counter
value (BCD
format)
Q Output BOOL I, Q, M, D, L Status of the
counter
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1733
Example
The following example shows how the instruction works:
=
S_CUD
CU
Q
CV
CD
PV CV_BCD
R
S
"Tagln_2"
"Tagln_1"
"Tagln_3"
"Tagln_4"
"TagPresetValue"
"TagValue_1"
"TagOut"
"TagValue_2"
"Counter_1"
If the signal state at the "TagIn_1" or "TagIn_2" input changes from "0" to "1" (positive signal
edge), the "Assign parameters and count up / down" instruction is executed. When there is a
positive signal edge at the "TagIn_1" input and the current counter value is less than "999",
the counter value is incremented by one. When there is a positive signal edge at the "TagIn_2"
input and the current counter value is greater than "0", the counter value is decremented by
one.
When the signal state at the "TagIn_3" input changes from "0" to "1", the counter value is set
to the value of the "TagPresetValue" operand. The counter value is reset to "0" when the
"TagIn_4" operand has signal state "1".
The current counter value is hexadecimal in the "TagValue_1" operand and BCD-coded in the
"TagValue_2" operand.
The "TagOut" output has the signal state "1" as long as the current counter value is not equal
to "0".
See also
Overview of the valid data types (Page 899)
S_CU: Assign parameters and count up
Description
You can use the "Assign parameters and count up" instruction to increment the value of a
counter. If the signal state at the CU input changes from "0" to "1" (positive signal edge), the
current counter value is incremented by one. The current counter value is output as a
hexadecimal value at output CV and BCD-coded at output CV_BCD. The count is incremented
until the limit of "999" is reached. When the limit is reached, the counter value is no longer
incremented on a positive signal edge.
When the signal state at input S changes from "0" to "1", the counter value is set to the value
of the PV parameter. If the counter is set and if RLO at input CU is "1", the counter will count
accordingly in the next scan cycle, even when no change has been detected in the signal edge.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1734 System Manual, 01/2013,
The counter value is set to zero when the signal state at the R input changes to "1". As long
as the R input has the signal state "1", processing of the signal state of the CU and S inputs
has no effect on the counter value.
The signal state at output Q is "1" if the counter value is greater than zero. If the counter value
is equal to zero, output Q has the signal state "0".
Note
Avoid using a counter at more than one point in the program (risk of counting errors).
The "Assign parameters and count up" instruction needs a preceding logic operation for the
edge evaluation and can be placed within or at the end of the network.
Parameters
The following table shows the parameters of the "Assign parameters and count up" instruction:
Parameters Declaration Data type Memory area Description
<Counter> InOut/Input COUNTER C Counter of the
instruction
The number of
counters depends
on the CPU.
CU Input BOOL I, Q, M, D, L, T, C Count up input
S Input BOOL I, Q, M, D, L, T, C
or constant
Input for
presetting counter
PV Input WORD I, Q, M, D, L, C or
constant
Preset counter
value (C#0 to
C#999)
R Input BOOL I, Q, M, D, L, T, C
or constant
Reset input
CV Output WORD, S5TIME,
DATE
I, Q, M, D, L Current counter
value
(hexadecimal)
CV_BCD Output WORD, S5TIME,
DATE
I, Q, M, D, L Current counter
value (BCD
format)
Q Output BOOL I, Q, M, D, L Status of the
counter
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1735
Example
The following example shows how the instruction works:
=
CU
Q
CV
PV CV_BCD
R
S
S_CU
"Tagln_2"
"Tagln_1"
"Tagln_3"
"TagPresetValue"
"TagValue_1"
"TagOut"
"TagValue_2"
"Counter_1"
When the signal state at the "TagIn_1" input changes from "0" to "1" (positive signal edge) and
the current counter value is less than "999", the counter value is incremented by one. When
the signal state at the "TagIn_2" input changes from "0" to "1", the counter value is set to the
value of the "TagPresetValue" operand. The counter value is reset to "0" when the "TagIn_3"
operand has signal state "1".
The current counter value is hexadecimal in the "TagValue_1" operand and BCD-coded in the
"TagValue_2" operand.
The "TagOut" output has the signal state "1" as long as the current counter value is not equal
to "0".
See also
Overview of the valid data types (Page 899)
S_CD: Assign parameters and count down
Description
You can use the "Assign parameters and count down" instruction to decrement the value of a
counter. If the signal state at the CD input changes from "0" to "1" (positive signal edge), the
counter value is decremented by one. The current counter value is output as a hexadecimal
value at output CV and BCD-coded at output CV_BCD. The count is decremented until the
low limit of "0" is reached. When the low limit is reached, the counter value is no longer
decremented on a positive signal edge.
When the signal state at input S changes from "0" to "1", the counter value is set to the value
of the PV parameter. If the counter is set and if RLO at input CD is "1", the counter will count
accordingly in the next scan cycle, even when no change has been detected in the signal edge.
The counter value is set to zero when the signal state at the R input changes to "1". As long
as the R input has the signal state "1", processing of the signal state of the CD and S inputs
has no effect on the counter value.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1736 System Manual, 01/2013,
The signal state at output Q is "1" if the counter value is greater than zero. If the counter value
is equal to zero, output Q has the signal state "0".
Note
Avoid using a counter at more than one point in the program (risk of counting errors).
The "Assign parameters and count down" instruction needs a preceding logic operation for the
edge evaluation and can be placed within or at the end of the network.
Parameters
The following table shows the parameters of the "Assign parameters and count down"
instruction:
Parameters Declaration Data type Memory area Description
<Counter> InOut/Input COUNTER C Counter of the
instruction
The number of
counters depends
on the CPU.
CD Input BOOL I, Q, M, D, L or
constant
Count down input
S Input BOOL I, Q, M, D, L, T, C
or constant
Input for
presetting counter
PV Input WORD I, Q, M, D, L, C or
constant
Preset counter
value (C#0 to
C#999)
R Input BOOL I, Q, M, D, L, T, C
or constant
Reset input
CV Output WORD, S5TIME,
DATE
I, Q, M, D, L Current counter
value
(hexadecimal)
CV_BCD Output WORD, S5TIME,
DATE
I, Q, M, D, L Current counter
value (BCD
format)
Q Output BOOL I, Q, M, D, L Status of the
counter
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1737
Example
The following example shows how the instruction works:
=
CD
Q
CV
PV CV_BCD
R
S
S_CD
"Tagln_2"
"Tagln_1"
"Tagln_3"
"TagPresetValue"
"TagValue_1"
"TagOut"
"TagValue_2"
"Counter_1"
When the signal state at the "TagIn_1" input changes from "0" to "1" (positive signal edge) and
the current counter value is greater than "0", the counter value is decremented by one. When
the signal state at the "TagIn_2" input changes from "0" to "1", the counter value is set to the
value of the "TagPresetValue" operand. The counter value is reset to "0" when the "TagIn_3"
operand has signal state "1".
The current counter value is hexadecimal in the "TagValue_1" operand and BCD-coded in the
"TagValue_2" operand.
The "TagOut" output has the signal state "1" as long as the current counter value is not equal
to "0".
See also
Overview of the valid data types (Page 899)
SC: Set counter value
Description
You can use the "Set counter value" instruction to increment the value of a counter. The
instruction is executed when the result of logic operation (RLO) at the start input of the
instruction changes from "0" to "1". If the instruction is executed, the counter is set to the
specified counter value.
The "Set counter value" instruction needs a preceding logic operation for the edge evaluation
and can only be placed on the right edge of the network.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1738 System Manual, 01/2013,
Parameters
The following table shows the parameters of the "Set counter value" instruction:
Parameters Declaration Data type Memory area Description
<Operand> Input BOOL I, Q, M, T, C, D, L Start input
PV Input WORD I, Q, M, D, L or
constant
Value with which
the counter is
preset in the BCD
format.
(C#0 to C#999)
<Counter> InOut/Input COUNTER C Counter which is
preset.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
SC
PV
C#100
"Tagln"
"Counter_1"
"Counter_1" starts with the value "100" when the signal state of the "TagIn" operand changes
from "0" to "1".
See also
Overview of the valid data types (Page 899)
CU: Count up
Description
You use the "Count up" instruction to increment the value of the specified counter by the count
of one on a rising edge at the start input. The count is incremented until the limit of "999" is
reached. When the limit is reached, the counter value is no longer incremented on a positive
signal edge.
The "Count up" instruction needs a preceding logic operation for the edge evaluation and can
only be placed on the right edge of the network.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1739
Parameters
The following table shows the parameters of the "Count up" instruction:
Parameters Declaration Data type Memory area Description
<Operand> Input BOOL I, Q, M, T, C, D, L Start input
<Counter> InOut/Input COUNTER C Counter whose
value is
incremented.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
SC
CU
PV
Network 1
Network 2
Network 3
"Tagln_1"
"Tagln_3"
"Tagln_2"
"Counter_1"
"Counter_1"
"Counter_1"
R
C#100
When the signal state of the operand "TagIn_1" changes from "0" to "1" (positive signal edge),
the counter "Counter_1" is preset with the value "100".
The value of "Counter_1" is incremented by the count of one when the signal state of the
"TagIn_2" operand changes from "0" to "1".
If the "TagIn_3" operand returns signal state "1", the value of "Counter_1" is reset to "0".
See also
Overview of the valid data types (Page 899)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1740 System Manual, 01/2013,
CD: Count down
Description
You use the "Count down" instruction to decrement the value of the specified counter by the
count of one on a rising edge at the start input. The count is decremented until the limit of "0"
is reached. When the limit is reached, the counter value is no longer changed on a positive
signal edge.
The "Count down" instruction needs a preceding logic operation for the edge evaluation and
can only be placed on the right edge of the network.
Parameters
The following table shows the parameters of the "Count down" instruction:
Parameters Declaration Data type Memory area Description
<Operand> Input BOOL I, Q, M, T, C, D, L Start input
<Counter> InOut/Input COUNTER C Counter whose
value is
decremented.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
SC
CD
PV
Network 1
Network 2
Network 3
"Tagln_1"
"Tagln_3"
"Tagln_2"
"Counter_1"
"Counter_1"
"Counter_1"
R
C#100
When the signal state of the operand "TagIn_1" changes from "0" to "1" (positive signal edge),
the counter "Counter_1" is preset with the value "100".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1741
The value of "Counter_1" is incremented by the count of one when the signal state of the
"TagIn_2" operand changes from "0" to "1".
If the "TagIn_3" operand returns signal state "1", the value of "Counter_1" is reset to "0".
See also
Overview of the valid data types (Page 899)
Comparator operations
CMP ==: Equal
Description
You can use the "Equal" instruction to query whether the value at input IN1 is equal to the
value at input IN2.
If the condition of the comparison is satisfied, the instruction returns the result of logic operation
(RLO) "1". If the comparison condition is not fulfilled, the instruction returns RLO "0".
The individual characters are compared by means of their ASCII code (for example, 'a' is
greater than 'A') during the comparison of the strings. The comparison is performed from left
to right. The first character to be different decides the result of the comparison.
The following table shows examples of string comparisons:
IN1 IN2 RLO of the instruction
'AA' 'AA' 1
'Hello World' 'HelloWorld' 0
'AA' 'aa' 0
The "Equal" instruction also compares individual characters of a string STRING). The number
of the character to be compared is specified in square brackets beside the operand name.
"MyString[2]", for example, compares the second character of the "MyString" string.
If IEC check is enabled, the operands to be compared must be of the same data type. If IEC
check is not enabled, the width (length) of the operands must be the same. If the floating-point
numbers are being compared, the operands to be compared must be of the same data type
regardless of the IEC check setting.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1742 System Manual, 01/2013,
Parameters
The following table shows the parameters of the instruction "Equal":
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500
IN1 Input Bit strings,
integers,
floating-point
numbers,
character
strings, TIME,
DATE, TOD,
DTL
Bit strings,
integers,
floating-point
numbers,
character
strings, TIME,
LTIME, DATE,
TOD, LTOD,
DTL, DT, LDT
I, Q, M, D, L, P
or constant
First value to
compare
IN2 Input Bit strings,
integers,
floating-point
numbers,
character
strings, TIME,
DATE, TOD,
DTL
Bit strings,
integers,
floating-point
numbers,
character
strings, TIME,
LTIME, DATE,
TOD, LTOD,
DTL, DT, LDT
I, Q, M, D, L, P
or constant
Second value
to compare
You can select the data type of the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also":
Example
The following example shows how the instruction works:
==
lNT
lN1
lN2
&
S
"Tagln_1" "Tag_Value1"
"Tag_Value2"
"TagOut"
Output "TagOut" is set when the following conditions are fulfilled:
The operand "TagIn_1" has the signal state "1".
The condition of the comparison instruction is fulfilled ("Tag_Value1" = "Tag_Value2").
See also
Overview of the valid data types (Page 899)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1743
CMP <>: Not equal
Description
You can use the "Not equal" instruction to query whether the value at input IN1 is not equal
to the value at input IN2.
If the condition of the comparison is satisfied, the instruction returns the result of logic operation
(RLO) "1". If the comparison condition is not fulfilled, the instruction returns RLO "0".
The individual characters are compared by means of their ASCII code (for example, 'a' is
greater than 'A') during the comparison of the strings. The comparison is performed from left
to right. The first character to be different decides the result of the comparison.
The following table shows examples of string comparisons:
IN1 IN2 RLO of the instruction
'AA' 'aa' 1
'Hello World' 'HelloWorld' 1
'AA' 'AA' 0
The "Not equal" instruction also compares individual characters of a string STRING). The
number of the character to be compared is specified in square brackets beside the operand
name. "MyString[2]", for example, compares the second character of the "MyString" string.
If IEC check is enabled, the operands to be compared must be of the same data type. If IEC
check is not enabled, the width (length) of the operands must be the same. If the floating-point
numbers are being compared, the operands to be compared must be of the same data type
regardless of the IEC check setting.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1744 System Manual, 01/2013,
Parameters
The following table shows the parameters of the instruction "Not equal":
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500
IN1 Input Bit strings,
integers,
floating-point
numbers,
character
strings, TIME,
DATE, TOD,
DTL
Bit strings,
integers,
floating-point
numbers,
character
strings, TIME,
LTIME, DATE,
TOD, LTOD,
DTL, DT, LDT
I, Q, M, D, L, P
or constant
First value to
compare
IN2 Input Bit strings,
integers,
floating-point
numbers,
character
strings, TIME,
DATE, TOD,
DTL
Bit strings,
integers,
floating-point
numbers,
character
strings, TIME,
LTIME, DATE,
TOD, LTOD,
DTL, DT, LDT
I, Q, M, D, L, P
or constant
Second value
to compare
You can select the data type of the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
< >
lNT
lN1
lN2
&
S
"Tagln_1" "Tag_Value1"
"Tag_Value2"
"TagOut"
Output "TagOut" is set when the following conditions are fulfilled:
The operand "TagIn_1" has the signal state "1".
The condition of the comparison instruction is fulfilled ("Tag_Value1" <> "Tag_Value2").
See also
Overview of the valid data types (Page 899)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1745
CMP >=: Greater or equal
Description
You can use the "Greater or equal" instruction to query whether the value at input IN1 is greater
or equal to the value at input IN2. Both values to be compared must be of the same data type.
If the condition of the comparison is satisfied, the instruction returns the result of logic operation
(RLO) "1". If the comparison condition is not fulfilled, the instruction returns RLO "0".
The individual characters are compared by means of their ASCII code (for example, 'a' is
greater than 'A') during the comparison of the strings. The comparison is performed from left
to right. The first character to be different decides the result of the comparison. If the left part
of the longer string is identical to the shorter string, the longer string is considered greater.
The following table shows examples of string comparisons:
IN1 IN2 RLO of the instruction
'BB' 'AA' 1
'AAA' 'AA' 1
'Hello World' 'Hello World' 1
'Hello World' 'HelloWorld' 0
'AA' 'aa' 0
'AAA' 'a' 0
The "Greater or equal" instruction also compares individual characters of a string (STRING).
The number of the character to be compared is specified in square brackets beside the operand
name. "MyString[2]", for example, compares the second character of the "MyString" string.
In comparing timer values, the RLO of the instruction is "1" if the timer at input IN1 is greater
(more recent) than or equal to the timer at input IN2.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1746 System Manual, 01/2013,
Parameters
The following table shows the parameters of the instruction "Greater or equal":
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500
IN1 Input Integers,
floating-point
numbers,
character
strings, TIME,
DATE, TOD,
DTL
Integers,
floating-point
numbers,
character
strings, TIME,
LTIME, DATE,
TOD, LTOD,
DTL, DT, LDT
I, Q, M, D, L, P
or constant
First value to
compare
IN2 Input Integers,
floating-point
numbers,
character
strings, TIME,
DATE, TOD,
DTL
Integers,
floating-point
numbers,
character
strings, TIME,
LTIME, DATE,
TOD, LTOD,
DTL, DT, LDT
I, Q, M, D, L, P
or constant
Second value
to compare
You can select the data type of the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
>=
lNT
lN1
lN2
&
S
"Tagln_1" "Tag_Value1"
"Tag_Value2"
"TagOut"
Output "TagOut" is set when the following conditions are fulfilled:
The operand "TagIn_1" has the signal state "1".
The condition of the comparison instruction is fulfilled ("Tag_Value1" >= "Tag_Value2").
See also
Overview of the valid data types (Page 899)
Example of detecting the fill level of a storage area (Page 1399)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1747
CMP <=: Less or equal
Description
You can use the "Less or equal" instruction to query whether the value at input IN1 is less or
equal to the value at input IN2. Both values to be compared must be of the same data type.
If the condition of the comparison is satisfied, the instruction returns the result of logic operation
(RLO) "1". If the comparison condition is not fulfilled, the instruction returns RLO "0".
The individual characters are compared by means of their ASCII code (for example, 'a' is
greater than 'A') during the comparison of the strings. The comparison is performed from left
to right. The first character to be different decides the result of the comparison. If the left part
of the longer string is identical to the shorter string, the shorter string is considered smaller.
The following table shows examples of string comparisons:
IN1 IN2 RLO of the instruction
'AA' 'aa' 1
'AAA' 'a' 1
'Hello World' 'Hello World' 1
'HelloWorld' 'Hello World' 0
'BB' 'AA' 0
'AAA' 'AA' 0
The "Less or equal" instruction also compares individual characters of a string (STRING). The
number of the character to be compared is specified in square brackets beside the operand
name. "MyString[2]", for example, compares the second character of the "MyString" string.
In comparing timer values, the RLO of the instruction is "1" if the timer at input IN1 is smaller
(less recent) than or equal to the timer at input IN2.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1748 System Manual, 01/2013,
Parameters
The following table shows the parameters of the instruction "Less or equal":
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500
IN1 Input Integers,
floating-point
numbers,
character
strings, TIME,
DATE, TOD,
DTL
Integers,
floating-point
numbers,
character
strings, TIME,
LTIME, DATE,
TOD, LTOD,
DTL, DT, LDT
I, Q, M, D, L, P
or constant
First value to
compare
IN2 Input Integers,
floating-point
numbers,
character
strings, TIME,
DATE, TOD,
DTL
Integers,
floating-point
numbers,
character
strings, TIME,
LTIME, DATE,
TOD, LTOD,
DTL, DT, LDT
I, Q, M, D, L, P
or constant
Second value
to compare
You can select the data type of the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
<=
lNT
lN1
lN2
&
S
"Tagln_1" "Tag_Value1"
"Tag_Value2"
"TagOut"
Output "TagOut" is set when the following conditions are fulfilled:
The operand "TagIn_1" has the signal state "1".
The condition of the comparison instruction is fulfilled ("Tag_Value1" <= "Tag_Value2").
See also
Overview of the valid data types (Page 899)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1749
CMP >: Greater than
Description
You can use the "Greater than" instruction to query whether the value at input IN1 is greater
than the value at input IN2. Both values to be compared must be of the same data type.
If the condition of the comparison is satisfied, the instruction returns the result of logic operation
(RLO) "1". If the comparison condition is not fulfilled, the instruction returns RLO "0".
The individual characters are compared by means of their ASCII code (for example, 'a' is
greater than 'A') during the comparison of the strings. The comparison is performed from left
to right. The first character to be different decides the result of the comparison. If the left part
of the longer string is identical to the shorter string, the longer string is considered greater.
The following table shows examples of string comparisons:
IN1 IN2 RLO of the instruction
'BB' 'AA' 1
'AAA' 'AA' 1
'AA' 'aa' 0
'AAA' 'a' 0
The "Greater than" instruction also compares individual characters of a string (STRING). The
number of the character to be compared is specified in square brackets beside the operand
name. "MyString[2]", for example, compares the second character of the "MyString" string.
In comparing timer values, the RLO of the instruction is "1" if the timer at input IN1 is greater
(more recent) than the timer at input IN2.
Parameters
The following table shows the parameters of the instruction "Greater than":
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500
IN1 Input Integers,
floating-point
numbers,
character
strings, TIME,
DATE, TOD,
DTL
Integers,
floating-point
numbers,
character
strings, TIME,
LTIME, DATE,
TOD, LTOD,
DTL, DT, LDT
I, Q, M, D, L, P
or constant
First value to
compare
IN2 Input Integers,
floating-point
numbers,
character
strings, TIME,
DATE, TOD,
DTL
Integers,
floating-point
numbers,
character
strings, TIME,
LTIME, DATE,
TOD, LTOD,
DTL, DT, LDT
I, Q, M, D, L, P
or constant
Second value
to compare
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1750 System Manual, 01/2013,
You can select the data type of the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
>
lNT
lN1
lN2
&
S
"Tagln_1" "Tag_Value1"
"Tag_Value2"
"TagOut"
Output "TagOut" is set when the following conditions are fulfilled:
The operand "TagIn_1" has the signal state "1".
The condition of the comparison instruction is fulfilled ("Tag_Value1" > "Tag_Value2").
See also
Overview of the valid data types (Page 899)
CMP <: Less than
Description
You can use the "Less than" instruction to query whether the value at input IN1 is less than
the value at input IN2. Both values to be compared must be of the same data type.
If the condition of the comparison is satisfied, the instruction returns the result of logic operation
(RLO) "1". If the comparison condition is not fulfilled, the instruction returns RLO "0".
The individual characters are compared by means of their ASCII code (for example, 'a' is
greater than 'A') during the comparison of the strings. The comparison is performed from left
to right. The first character to be different decides the result of the comparison. If the left part
of the longer string is identical to the shorter string, the shorter string is considered smaller.
The following table shows examples of string comparisons:
<Operand1> <Operand2> RLO of the instruction
'AA' 'aa' 1
'AAA' 'a' 1
'BB' 'AA' 0
'AAA' 'AA' 0
The "Less than" instruction also compares individual characters of a string (STRING). The
number of the character to be compared is specified in square brackets beside the operand
name. "MyString[2]", for example, compares the second character of the "MyString" string.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1751
In comparing timer values, the RLO of the instruction is "1" if the timer at input IN1 is less (less
recent) than the timer at input IN2 .
Parameters
The following table shows the parameters of the instruction "Less than":
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500
IN1 Input Integers,
floating-point
numbers,
character
strings, TIME,
DATE, TOD,
DTL
Integers,
floating-point
numbers,
character
strings, TIME,
LTIME, DATE,
TOD, LTOD,
DTL, DT, LDT
I, Q, M, D, L, P
or constant
First value to
compare
IN2 Input Integers,
floating-point
numbers,
character
strings, TIME,
DATE, TOD,
DTL
Integers,
floating-point
numbers,
character
strings, TIME,
LTIME, DATE,
TOD, LTOD,
DTL, DT, LDT
I, Q, M, D, L, P
or constant
Second value
to compare
You can select the data type of the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
<
lNT
lN1
lN2
&
S
"Tagln_1" "Tag_Value1"
"Tag_Value2"
"TagOut"
Output "TagOut" is set when the following conditions are fulfilled:
The operand "TagIn_1" has the signal state "1".
The condition of the comparison instruction is fulfilled ("Tag_Value1" < "Tag_Value2").
See also
Overview of the valid data types (Page 899)
Example of detecting the fill level of a storage area (Page 1399)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1752 System Manual, 01/2013,
IN_RANGE: Value within range
Description
You can use the "Value within range" instruction to query whether of the value at input VAL is
within a specific value range.
You specify the limits of the value range with the MIN and MAX inputs. The "Value within range"
instruction compares the value at input VAL with the values of the inputs MIN and MAX and
sends the result to the box output. If the value at input VAL satisfies the comparison MIN <=
VAL or VAL <=MAX, the box output has the signal state "1". If the comparison is not fulfilled,
the signal state is "0" at the box output.
The comparison function can only execute if the values to be compared are of the same data
type.
Parameters
The following table shows the parameters of the "Value within range" instruction:
Parameters Declaration Data type Memory area Description
MIN Input Integers, floating-
point numbers
I, Q, M, D, L or
constant
Low limit of the
value range
VAL Input Integers, floating-
point numbers
I, Q, M, D, L or
constant
Comparison value
MAX Input Integers, floating-
point numbers
I, Q, M, D, L or
constant
High limit of the
value range
Box output Output BOOL I, Q, M, D, L Result of the
comparison
You can select the data type of the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also":
Example
The following example shows how the instruction works:
=
&
>=1
lN_RANGE
MlN
MAX
VAL
REAL
"Tagln_1"
"Tag_Min"
"Tag_Value"
"Tag_Max"
"Tagln_2"
"Tagln_3"
"TagOut"
Output "TagOut" is set when the following conditions are fulfilled:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1753
The operands "TagIn_1" or "TagIn_2" have signal state "1".
The operand "TagIn_3" has the signal state "1".
The value of the operand "Tag_Value" is within the value range that is specified by the
current values of the operands "Tag_Min" and "Tag_Max" (MIN <= VAL or VAL <= MAX).
See also
Overview of the valid data types (Page 899)
OUT_RANGE: Value outside range
Description
You can use the "Value outside range" instruction to query whether of the value at input VAL
is outside a specific value range.
You specify the limits of the value range with the MIN and MAX inputs. The "Value outside
range" instruction compares the value at input VAL with the values of the inputs MIN and MAX
and sends the result to the box output. If the value at input VAL satisfies the comparison MIN
> VAL or VAL >MAX, the box output has the signal state "1". The box output has the signal
state "1" if a specified operand of data type REAL has an invalid value.
The box output returns the signal state "0", if the value at input VAL does not satisfy the MIN
> VAL or VAL > MAX condition.
The comparison function can only execute if the values to be compared are of the same data
type.
Parameters
The following table shows the parameters of the "Value outside range" instruction:
Parameters Declaration Data type Memory area Description
MIN Input Integers, floating-
point numbers
I, Q, M, D, L or
constant
Low limit of the
value range
VAL Input Integers, floating-
point numbers
I, Q, M, D, L or
constant
Comparison value
MAX Input Integers, floating-
point numbers
I, Q, M, D, L or
constant
High limit of the
value range
Box output Output BOOL I, Q, M, D, L Result of the
comparison
You can select the data type of the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1754 System Manual, 01/2013,
Example
The following example shows how the instruction works:
=
&
>=1
OUT_RANGE
MlN
MAX
VAL
REAL
"Tagln_1"
"Tag_Min"
"Tag_Value"
"Tag_Max"
"Tagln_2"
"Tagln_3"
"TagOut"
Output "TagOut" is set when the following conditions are fulfilled:
The operands "TagIn_1" and "TagIn_2" have signal state "1".
The operand "TagIn_3" has the signal state "1".
The value of the operand "Tag_Value" is outside the value range that is specified by the
values of the operands "Tag_Min" and "Tag_Max" (MIN > VAL or VAL > MAX).
See also
Overview of the valid data types (Page 899)
OK: Check validity
Description
You can use the "Check validity" instruction to check if the value of an operand (<Operand>)
is a valid floating-point number. The check is performed in every program cycle. If the operand
value at the time of the query is a valid floating-point number, the output box will return the
signal state"1". In all other cases, the signal state at the output of the "Check validity" instruction
is "0".
You can use the "Check validity" instruction together with the EN mechanism. If you connect
the instruction box to an EN enable input, the enable input is set only when the result of the
validity query of the value is positive. You can use this function to ensure that an instruction is
enabled only when the value of the specified operand is a valid floating-point number.
Parameters
The following example shows how the "Check validity" instruction works:
Parameters Declaration Data type Memory area Description
<Operand> Input Floating-point
numbers
I, Q, M, D, L Value to be
checked.
For additional information on valid data types, refer to "See also":
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1755
Example
The following example shows how the instruction works:
MUL
lN2 ENO
=
&
EN
lN1 OUT
OK
OK
REAL
"TagOut"
"Tag_Value1"
"Tag_Result"
"Tag_Value2"
"Tag_Value2"
"Tag_Value1"
When the values of the operands "Tag_Value1" and "Tag_Value2" show valid floating-point
numbers, the "Multiply" (MUL) instruction is activated and the ENO output is set. During the
execution of the "Multiply" (MUL) instruction, the value of the operand "Tag_Value1" is
multiplied by the value of operand "Tag_Value2". The product of the multiplication is then stored
in the operand "Tag_Result". If no errors occur during the execution of the instruction, the
outputs ENO and "TagOut" are set to signal state "1".
See also
Overview of the valid data types (Page 899)
NOT_OK: Check invalidity
Description
You can use the "Check invalidity" instruction to check if the value of an operand (<Operand>)
is an invalid floating-point number. The check is performed in every program cycle. If the
operand value at the time of the query is a valid floating-point number, then the output box will
return the signal state "1". In all other cases, the signal state on the output box is "0".
Parameters
The following table shows the parameters of the instruction "Check invalidity":
Parameters Declaration Data type Memory area Description
<Operand> Input Floating-point
numbers
I, Q, M, D, L Value to be
checked.
For additional information on valid data types, refer to "See also":
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1756 System Manual, 01/2013,
Example
The following example shows how the instruction works:
=
MOVE
NOT_OK
EN
ENO lN
OUT
"Tagln_Value"
"Tagln_Value"
"TagOut_Value"
"TagOut"
When the value of operand "TagIn_Value" is an invalid floating-point number, the instruction
"Move value" (MOVE) is not executed. The "TagOut" output is reset to signal state "0".
See also
Overview of the valid data types (Page 899)
Math functions
CALCULATE: Calculate
Description
The "Calculate" instruction is used to define and execute an expression (formula) for the
calculation of mathematical operations or complex logic operations depending on the selected
data type.
You can select the data type of the instruction from the "<???>" drop-down list of the instruction
box. Depending on the selected data type, you can combine the functionality of specific
instructions to execute a complex calculation. The expression to be calculated is specified via
a dialog you can open via the "Calculator" icon at the top of the instruction box. The expression
can contain the names of the input parameters and the syntax of the instructions. It is not
permitted to specify operand names or operand addresses.
The following table shows the instructions that, depending on the selected data type, can be
combined and executed in the expression of the "Calculate" instruction:
Data type Instruction Syntax Example
Bit strings AND: AND logic operation AND IN1 AND IN2 OR IN3
OR: OR logic operation OR
XOR: EXCLUSIVE OR logic operation XOR
INV: Create ones complement NOT
SWAP: Swap
1)
SWAP
Integers ADD: Add + (IN1 + IN2) * IN3;
(ABS(IN2))*(ABS(IN1
))
SUB: Subtract -
MUL: Multiply *
DIV: Divide /
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1757
Data type Instruction Syntax Example
MOD: Return remainder of division MOD
INV: Create ones complement NOT
NEG: Create twos complement -(in1)
ABS: Form absolute value ABS( )
Floating-point numbers ADD: Add + ((SIN(IN2)*SIN(IN2)+
(SIN(IN3)*SIN(IN3))/
IN3;
(SQR(SIN(IN2))+
(SQR(COS(IN3))/IN2
SUB: Subtract -
MUL: Multiply *
DIV: Divide /
EXPT: Exponentiate **
ABS: Form absolute value ABS( )
SQR: Form square SQR( )
SQRT: Form square root SQRT( )
LN: Form natural logarithm LN( )
EXP: Form exponential value EXP( )
FRAC: Return fraction FRAC( )
SIN: Form sine value SIN( )
COS: Form cosine value COS( )
TAN: Form tangent value TAN( )
ASIN: Form arcsine value ASIN( )
ACOS: Form arccosine value ACOS( )
ATAN: Form arctangent value ATAN( )
NEG: Create twos complement -(in1)
TRUNC: Truncate numerical value TRUNC( )
ROUND: Round numerical value ROUND( )
CEIL: Generate next higher integer from floating-
point number
CEIL( )
FLOOR: Generate next lower integer from floating-
point number
FLOOR( )
1)
Not possible for data type BYTE.
In its initial state the instruction box contains at least 2 inputs (IN1 and IN2). The number of
inputs can be extended. The inserted inputs are numbered in ascending order in the box.
The values of the inputs are use to execute the specified expression. Not all defined inputs
have to be used in the expression. The result of the instruction is transferred to the box output
OUT.
If, in the expression, you use inputs that are not available in the box, these inputs are
automatically inserted. Provided that there are no gaps in the numbering of the inputs that are
to be newly defined in the expression. You cannot, for example, use the input IN4 in the
expression if the input IN3 is not defined.
Enable output ENO has the signal state "0" if one of the following conditions applies:
Enable input EN has the signal state "0".
The result or an interim result of the "Calculate" instruction is outside the range permitted
for the data type specified at output OUT.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1758 System Manual, 01/2013,
A floating-point number has an invalid value.
An error occurred during the execution of one of the instructions specified in the expression.
Parameters
The following table shows the parameters of the instruction "Calculate":
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500
EN Input BOOL I, Q, M, D, L I, Q, M, D, L, T,
C
Enable input
ENO Output BOOL I, Q, M, D, L I, Q, M, D, L Enable output
IN1 Input Bit strings,
integers,
floating-point
numbers
I, Q, M, D, L, P
or constant
I, Q, M, D, L, P
or constant
First available
input
IN2 Input Bit strings,
integers,
floating-point
numbers
I, Q, M, D, L, P
or constant
I, Q, M, D, L, P
or constant
Second
available input
INn Input Bit strings,
integers,
floating-point
numbers
I, Q, M, D, L, P
or constant
I, Q, M, D, L, P
or constant
Additionally
inserted inputs
OUT Output Bit strings,
integers,
floating-point
numbers
I, Q, M, D, L, P I, Q, M, D, L, P Output to
which the end
result is to be
transferred.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
OUT
EN
CALCULATE
lNT
lN1
lN2
lN3
lN4
((lN1+lN2)*lN3)/lN4
"Tag_lnput"
"Tag_Value_1"
"Tag_Value_2"
"Tag_Value_3"
"Tag_Value_4"
"Tag_Result"
"Tag_Output"
ENO
=
The following table shows how the instruction works using specific operand values:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1759
Parameters Operand Value
IN1 Tag_Value_1 4
IN2 Tag_Value_2 4
IN3 Tag_Value_3 3
IN4 Tag_Value_4 2
OUT Tag_Result 12
The "Calculate" instruction is executed when input "Tag_Input" has the signal state "1". The
value of operand "Tag_Value_1" is added to the value of operand "Tag_Value_2". The sum is
multiplied with the value of the operand "Tag_Value_3". The product is divided by the value of
the operand "Tag_Value_4". The quotient is transferred as end result to the operand
"Tag_Result" at the OUT output of the instruction. If no errors occur during the execution of
the individual instructions, output ENO and the operand "Tag_Output" are set to "1".
See also
Overview of the valid data types (Page 899)
Adding additional inputs and outputs to FBD elements (Page 1144)
Removing instruction inputs and outputs (Page 1145)
Basics of the EN/ENO mechanism (Page 987)
ADD: Add
Description
You can use the "Add" instruction to add the value at input IN1 to the value at input IN2 and
query the sum at output OUT (OUT := IN1+IN2).
In its initial state the instruction box contains at least 2 inputs (IN1 and IN2). The number of
inputs can be extended. The inserted inputs are numbered in ascending order in the box.
During the execution of the instruction, the values of all available input parameters are added.
The sum is stored at output OUT.
Enable output ENO has the signal state "0" if one of the following conditions applies:
Enable input EN has the signal state "0".
The result of the instruction is outside the range permitted for the data type specified at
output OUT.
A floating-point number has an invalid value.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1760 System Manual, 01/2013,
Parameters
The following table shows the parameters of the instruction "Add":
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500
EN Input BOOL I, Q, M, D, L I, Q, M, D, L, T,
C
Enable input
ENO Output BOOL I, Q, M, D, L I, Q, M, D, L Enable output
IN1 Input Integers,
floating-point
numbers
I, Q, M, D, L, P
or constant
I, Q, M, D, L, P
or constant
First number to
be added
IN2 Input Integers,
floating-point
numbers
I, Q, M, D, L, P
or constant
I, Q, M, D, L, P
or constant
Second
number to be
added
INn Input Integers,
floating-point
numbers
I, Q, M, D, L, P
or constant
I, Q, M, D, L, P
or constant
Optional input
values, which
are added.
OUT Output Integers,
floating-point
numbers
I, Q, M, D, L, P I, Q, M, D, L, P Sum
You can select the data type of the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also":
Example
The following example shows how the instruction works:
ADD
= ENO
EN
lN2
lN1 OUT
lNT
"Tag_Result"
"Tag_Value2"
"Tag_Value1"
"TagOut"
"Tagln"
If the operand "TagIn" has the signal state "1", the "Add" instruction is executed. The value of
operand "Tag_Value1" is added to the value of operand "Tag_Value2". The result of the
addition is stored in the operand "Tag_Result". If the instruction is executed without errors, the
ENO enable output has the signal state "1" and the "TagOut" output is set.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1761
See also
Overview of the valid data types (Page 899)
Removing instruction inputs and outputs (Page 1145)
Basics of the EN/ENO mechanism (Page 987)
Selecting a data type (Page 1130)
Adding additional inputs and outputs to FBD elements (Page 1144)
SUB: Subtract
Description
You can use the "Subtract" instruction to subtract the value at input IN2 from the value at input
IN1 and query the difference at output OUT (OUT := IN1-IN2).
Enable output ENO has the signal state "0" if one of the following conditions applies:
Enable input EN has the signal state "0".
The result of the instruction is outside the range permitted for the data type specified at
output OUT.
A floating-point number has an invalid value.
Parameters
The following table shows the parameters of the instruction "Subtract":
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500
EN Input BOOL I, Q, M, D, L I, Q, M, D, L, T,
C
Enable input
ENO Output BOOL I, Q, M, D, L I, Q, M, D, L Enable output
IN1 Input Integers,
floating-point
numbers
I, Q, M, D, L, P
or constant
I, Q, M, D, L, P
or constant
Minuend
IN2 Input Integers,
floating-point
numbers
I, Q, M, D, L, P
or constant
I, Q, M, D, L, P
or constant
Subtrahend
OUT Output Integers,
floating-point
numbers
I, Q, M, D, L, P I, Q, M, D, L, P Difference
You can select the data type of the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1762 System Manual, 01/2013,
Example
The following example shows how the instruction works:
SUB
= ENO
EN
lN2
lN1 OUT
lNT
"Tag_Result"
"Tag_Value2"
"Tag_Value1"
"TagOut"
"Tagln"
If the operand "TagIn" has the signal state "1", the "Subtract" instruction is executed. The value
of operand "Tag_Value2" is subtracted from the value of operand "Tag_Value1". The result of
the subtraction is stored in the operand "Tag_Result". If the instruction is executed without
errors, the ENO enable output has the signal state "1" and the "TagOut" output is set.
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
Selecting a data type (Page 1130)
MUL: Multiply
Description
You can use the "Multiply" instruction to multiply the value at input IN1 with the value at input
IN2 and query the total at output OUT (OUT := IN1*IN2).
In its initial state the instruction box contains at least 2 inputs (IN1 and IN2). The number of
inputs can be extended. The inserted inputs are numbered in ascending order in the box. When
the instruction is executed, the values of all available input parameters are multiplied. The
product is stored at the OUT output.
Enable output ENO has the signal state "0" if one of the following conditions applies:
Enable input EN has the signal state "0".
The result is outside the range permitted for the data type specified at output OUT.
A floating-point number has an invalid value.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1763
Parameters
The following table shows the parameters of the instruction "Multiply":
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500
EN Input BOOL I, Q, M, D, L I, Q, M, D, L, T,
C
Enable input
ENO Output BOOL I, Q, M, D, L I, Q, M, D, L Enable output
IN1 Input Integers,
floating-point
numbers
I, Q, M, D, L, P
or constant
I, Q, M, D, L, P
or constant
First value for
multiplication
IN2 Input Integers,
floating-point
numbers
I, Q, M, D, L, P
or constant
I, Q, M, D, L, P
or constant
Second value
for
multiplication
INn Input Integers,
floating-point
numbers
I, Q, M, D, L, P
or constant
I, Q, M, D, L, P
or constant
Optional input
values, which
are multiplied.
OUT Output Integers,
floating-point
numbers
I, Q, M, D, L, P I, Q, M, D, L, P Product
You can select the data type of the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
MUL
S ENO
EN
lN2
lN1 OUT
REAL
"Tag_Result"
"Tag_Value2"
"Tag_Value1"
"Tagln"
"TagOut"
If the operand "TagIn" has the signal state "1", the "Multiply" instruction is executed. The value
of operand "Tag_Value1" is multiplied with the value of operand "Tag_Value2". The result of
the multiplication is stored in the operand "Tag_Result". If the instruction is executed without
errors, the ENO enable output has the signal state "1" and the "TagOut" output is set.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1764 System Manual, 01/2013,
See also
Overview of the valid data types (Page 899)
Removing instruction inputs and outputs (Page 1145)
Basics of the EN/ENO mechanism (Page 987)
Selecting a data type (Page 1130)
Adding additional inputs and outputs to FBD elements (Page 1144)
DIV: Divide
Description
You can use the "Divide" instruction to divide the value at input IN1 by the value at input IN2
and query the quotient at output OUT (OUT := IN1/IN2).
Enable output ENO has the signal state "0" if one of the following conditions applies:
Enable input EN has the signal state "0".
The result of the instruction is outside the range permitted for the data type specified at
output OUT.
A floating-point number has an invalid value.
Parameters
The following table shows the parameters of the instruction "Divide":
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500
EN Input BOOL I, Q, M, D, L I, Q, M, D, L, T,
C
Enable input
ENO Output BOOL I, Q, M, D, L I, Q, M, D, L Enable output
IN1 Input Integers,
floating-point
numbers
I, Q, M, D, L, P
or constant
I, Q, M, D, L, P
or constant
Dividend
IN2 Input Integers,
floating-point
numbers
I, Q, M, D, L, P
or constant
I, Q, M, D, L, P
or constant
Divisor
OUT Output Integers,
floating-point
numbers
I, Q, M, D, L, P I, Q, M, D, L, P Quotient value
You can select the data type of the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1765
Example
The following example shows how the instruction works:
DlV
S ENO
EN
lN2
lN1 OUT
REAL
"Tag_Result"
"Tag_Value2"
"Tag_Value1"
"Tagln"
"TagOut"
If the operand "TagIn" has the signal state "1", the "Divide" instruction is executed. The value
of operand "Tag_Value1" is divided by the value of operand "Tag_Value2". The result of the
division is stored in the operand "Tag_Result". If the instruction is executed without errors, the
ENO enable output has the signal state "1" and the "TagOut" output is set.
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
Selecting a data type (Page 1130)
MOD: Return remainder of division
Description
You can use the "Return remainder of division" instruction to divide the value at input IN1 by
the value at input IN2 and query the quotient at output OUT.
Parameters
The following table shows the parameters of the instruction "Return remainder of division":
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500
EN Input BOOL I, Q, M, D, L I, Q, M, D, L, T,
C
Enable input
ENO Output BOOL I, Q, M, D, L I, Q, M, D, L Enable output
IN1 Input Integers I, Q, M, D, L, P
or constant
I, Q, M, D, L, P
or constant
Dividend
IN2 Input Integers I, Q, M, D, L, P
or constant
I, Q, M, D, L, P
or constant
Divisor
OUT Output Integers I, Q, M, D, L, P I, Q, M, D, L, P Remainder of
division
You can select the data type of the instruction from the "<???>" drop-down list of the instruction
box.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1766 System Manual, 01/2013,
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
MOD
S ENO
EN
lN2
lN1 OUT
DlNT
"Tag_Result"
"Tag_Value2"
"Tag_Value1"
"Tagln"
"TagOut"
If the operand "TagIn" has the signal state "1", the "Return remainder of division" instruction
is executed. The value of operand "Tag_Value1" is divided by the value of operand
"Tag_Value2". The remainder of division is stored in operand "Tag_Result". If the instruction
is executed without errors, the ENO enable output has the signal state "1" and the "TagOut"
output is set.
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
Selecting a data type (Page 1130)
NEG: Create twos complement
Description
You can use the "Create twos complement" instruction to change the sign of the value at input
IN and query the result at output OUT. If there is a positive value at input IN, for example, the
negative equivalent of this value is sent to output OUT.
Enable output ENO has the signal state "0" if one of the following conditions applies:
Enable input EN has the signal state "0".
The result of the instruction is outside the range permitted for the data type specified at
output OUT.
A floating-point number has an invalid value.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1767
Parameters
The following table shows the parameters of the "Create twos complement" instruction:
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500 S7-1200 S7-1500
EN Input BOOL BOOL I, Q, M, D, L I, Q, M, D, L,
T, C
Enable input
ENO Output BOOL BOOL I, Q, M, D, L I, Q, M, D, L Enable
output
IN Input SINT, INT,
DINT,
Floating-
point
numbers
SINT, INT,
DINT, LINT,
Floating-
point
numbers
I, Q, M, D, L,
P or
constant
I, Q, M, D, L,
P or
constant
Input value
OUT Output SINT, INT,
DINT,
Floating-
point
numbers
SINT, INT,
DINT, LINT,
Floating-
point
numbers
I, Q, M, D, L,
P
I, Q, M, D, L,
P
Twos
complement
of the input
value
You can select the data type of the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
NEG
=
ENO
EN
lN
OUT
REAL
"Tagln_Value"
"TagOut_Value"
"TagOut"
"Tagln"
If the operand "TagIn" has the signal state "1", the "Create twos complement" instruction is
executed. The sign of the value at input "TagIn_Value" is changed and the result is stored at
output "TagOut_Value". If the instruction is executed without errors, the ENO enable output
has the signal state "1" and the "TagOut" output is set.
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
Adding additional inputs and outputs to FBD elements (Page 1144)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1768 System Manual, 01/2013,
INC: Increment
Description
You can use the "Increment" instruction to change the value of the operand at parameter IN/
OUT to the next higher value and query the result.
Enable output ENO has the signal state "0" if one of the following conditions applies:
Enable input EN has the signal state "0".
A floating-point number has an invalid value.
Parameters
The following table shows the parameters of the "Increment" instruction:
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500
EN Input BOOL I, Q, M, D, L I, Q, M, D, L, T,
C
Enable input
ENO Output BOOL I, Q, M, D, L I, Q, M, D, L Enable output
IN/OUT InOut Integers I, Q, M, D, L I, Q, M, D, L Value to be
incremented.
You can select the data type of the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
=
lNC
&
EN
ENO lN/OUT
lNT
"Tag_lnOut"
"TagOut"
"Tagln_1"
"Tagln_2"
If the operands TagIn_1 and TagIn_2 have the signal state "1", the value of the operand
"Tag_InOut" is incremented by one and the output "TagOut" is set.
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
Adding additional inputs and outputs to FBD elements (Page 1144)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1769
DEC: Decrement
Description
You can use the "Decrement" instruction to change the value of the operand at parameter IN/
OUT to the next lower value and query the result.
Enable output ENO has the signal state "0" if one of the following conditions applies:
Enable input EN has the signal state "0".
A floating-point number has an invalid value.
Parameters
The following table shows the parameters of the instruction "Decrement":
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500
EN Input BOOL I, Q, M, D, L I, Q, M, D, L, T,
C
Enable input
ENO Output BOOL I, Q, M, D, L I, Q, M, D, L Enable output
IN/OUT InOut Integers I, Q, M, D, L I, Q, M, D, L Value to be
decremented.
You can select the data type of the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
=
DEC
&
EN
ENO lN/OUT
lNT
"Tag_lnOut"
"TagOut"
"Tagln_1"
"Tagln_2"
If the operands "TagIn_1" and "TagIn_2" have the signal state "1", the value of the operand
"Tag_InOut" is decremented by one and the output "TagOut" is set.
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
Adding additional inputs and outputs to FBD elements (Page 1144)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1770 System Manual, 01/2013,
ABS: Form absolute value
Description
You can use the "Form absolute value" instruction to calculate the absolute value of the value
specified at input IN. The result of the instruction is provided at output OUT and can be queried
there.
Enable output ENO has the signal state "0" if one of the following conditions applies:
Enable input EN has the signal state "0".
A floating-point number has an invalid value.
Parameters
The following table shows the parameters of the instruction "Form absolute value":
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500 S7-1200 S7-1500
EN Input BOOL BOOL I, Q, M, D, L I, Q, M, D, L,
T, C
Enable input
ENO Output BOOL BOOL I, Q, M, D, L I, Q, M, D, L Enable
output
IN Input SINT, INT,
DINT,
floating-
point
numbers
SINT, INT,
DINT, LINT,
floating-
point
numbers
I, Q, M, D, L,
P or
constant
I, Q, M, D, L,
P or
constant
Input value
OUT Output SINT, INT,
DINT,
floating-
point
numbers
SINT, INT,
DINT, LINT,
floating-
point
numbers
I, Q, M, D, L,
P
I, Q, M, D, L,
P
Absolute
value of the
input value
You can select the data type of the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
ABS
=
ENO
EN
lN
OUT
REAL
"Tagln_Value"
"TagOut_Value"
"TagOut"
"Tagln"
The following table shows how the instruction works using specific operand values:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1771
Parameters Operand Value
IN TagIn_Value -6.234
OUT TagOut_Value 6.234
If the operand "TagIn" has the signal state "1", the "Form absolute value" instruction is
executed. The instruction calculates the absolute value of the value at input "TagIn_Value"
and sends the result to output "TagOut_Value". If no errors occur during the execution of the
instruction, the output "TagOut" is set.
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
Adding additional inputs and outputs to FBD elements (Page 1144)
MIN: Get minimum
Description
The "Get minimum" instruction compares the values at the available inputs and writes the
lowest value to the OUT output. In its initial state the instruction box contains at least 2 (IN1
and IN2) and not more than 100 inputs. The number of inputs can be extended. The inserted
inputs are numbered in ascending order in the box.
The instruction can only be executed if the tags on all inputs are of the same data type and
the enable input EN has the signal state "1".
Enable output ENO has the signal state "0" if one of the following conditions applies:
Enable input EN has the signal state "0".
The specified tags are not of the same data type.
A floating-point number has an invalid value.
Parameters
The following table shows the parameters of the "Get minimum" instruction:
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500 S7-1200 S7-1500
EN Input BOOL BOOL I, Q, M, D, L I, Q, M, D, L,
T, C
Enable input
ENO Output BOOL BOOL I, Q, M, D, L I, Q, M, D, L Enable
output
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1772 System Manual, 01/2013,
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500 S7-1200 S7-1500
IN1 Input Integers,
floating-
point
numbers,
TIME,
TOD,
DATE
Integers,
floating-
point
numbers,
timers, TOD,
LTOD,
DATE, LDT
I, Q, M, D, L,
P or constant
I, Q, M, D, L,
P or constant
First input
value
IN2 Input Integers,
floating-
point
numbers,
TIME,
TOD,
DATE
Integers,
floating-
point
numbers,
timers, TOD,
LTOD,
DATE, LDT
I, Q, M, D, L,
P or constant
I, Q, M, D, L,
P or constant
Second
input value
INn Input Integers,
floating-
point
numbers,
TIME,
TOD,
DATE
Integers,
floating-
point
numbers,
timers, TOD,
LTOD,
DATE, LDT
I, Q, M, D, L,
P or constant
I, Q, M, D, L,
P or constant
Additionally
inserted
inputs
whose
values are to
be
compared.
OUT Output Integers,
floating-
point
numbers,
TIME,
TOD,
DATE
Integers,
floating-
point
numbers,
timers, TOD,
LTOD,
DATE, LDT
I, Q, M, D, L,
P
I, Q, M, D, L,
P
Result
You can select the data type of the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
=
&
EN
ENO
OUT
lN1
lN2 "TagOut_Value"
"Tagln_Value1"
"Tagln_Value2"
lN3
"Tagln_Value3"
"TagOut"
"Tagln_1"
"Tagln_2"
MlN
lNT
The following table shows how the instruction works using specific operand values:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1773
Parameters Operand Value
IN1 TagIn_Value1 12222
IN2 TagIn_Value2 14444
IN3 TagIn_Value3 13333
OUT TagOut_Value 12222
If the "TagIn_1" and "TagIn_2" operands have signal state "1", the "Get minimum" instruction
is executed. The instruction compares the values of the specified operands and copies the
lowest value ("TagIn_Value1") to output "TagOut_Value". If no errors occur during the
execution of the instruction, the output "TagOut" is set.
See also
Overview of the valid data types (Page 899)
Removing instruction inputs and outputs (Page 1145)
Basics of the EN/ENO mechanism (Page 987)
Adding additional inputs and outputs to FBD elements (Page 1144)
MAX: Get maximum
Description
The "Get maximum" instruction compares the values at the available inputs and writes the
highest value to the OUT output. In its initial state the instruction box contains at least 2 (IN1
and IN2) and not more than 100 inputs. The number of inputs can be extended. The inserted
inputs are numbered in ascending order in the box.
The instruction can only be executed if the tags on all inputs are of the same data type and
the enable input EN has the signal state "1".
Enable output ENO has the signal state "0" if one of the following conditions applies:
Enable input EN has the signal state "0".
The specified tags are not of the same data type.
A floating-point number has an invalid value.
Parameters
The following table shows the parameters of the "Get maximum" instruction:
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500 S7-1200 S7-1500
EN Input BOOL BOOL I, Q, M, D, L I, Q, M, D, L,
T, C
Enable input
ENO Output BOOL BOOL I, Q, M, D, L I, Q, M, D, L Enable
output
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1774 System Manual, 01/2013,
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500 S7-1200 S7-1500
IN1 Input Integers,
floating-
point
numbers,
TIME,
TOD,
DATE
Integers,
floating-
point
numbers,
timers, TOD,
LTOD,
DATE, LDT
I, Q, M, D, L,
P or constant
I, Q, M, D, L,
P or constant
First input
value
IN2 Input Integers,
floating-
point
numbers,
TIME,
TOD,
DATE
Integers,
floating-
point
numbers,
timers, TOD,
LTOD,
DATE, LDT
I, Q, M, D, L,
P or constant
I, Q, M, D, L,
P or constant
Second
input value
INn Input Integers,
floating-
point
numbers,
TIME,
TOD,
DATE
Integers,
floating-
point
numbers,
timers, TOD,
LTOD,
DATE, LDT
I, Q, M, D, L,
P or constant
I, Q, M, D, L,
P or constant
Additionally
inserted
inputs
whose
values are to
be
compared.
OUT Output Integers,
floating-
point
numbers,
TIME,
TOD,
DATE
Integers,
floating-
point
numbers,
timers, TOD,
LTOD,
DATE, LDT
I, Q, M, D, L,
P
I, Q, M, D, L,
P
Result
You can select the data type of the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
=
&
EN
ENO
OUT
lN1
lN2 "TagOut_Value"
"Tagln_Value1"
"Tagln_Value2"
lN3
"Tagln_Value3"
"TagOut"
"Tagln_1"
"Tagln_2"
MAX
lNT
The following table shows how the instruction works using specific operand values:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1775
Parameters Operand Value
IN1 TagIn_Value1 12222
IN2 TagIn_Value2 14444
IN3 TagIn_Value3 13333
OUT TagOut_Value 14444
If the "TagIn_1" and "TagIn_2" operands have signal state "1", the "Get maximum" instruction
is executed. The instruction compares the values of the specified operands and copies the
highest value ("TagIn_Value2") to output "TagOut_Value". If no errors occur during the
execution of the instruction, the output "TagOut" is set.
See also
Overview of the valid data types (Page 899)
Removing instruction inputs and outputs (Page 1145)
Basics of the EN/ENO mechanism (Page 987)
Adding additional inputs and outputs to FBD elements (Page 1144)
LIMIT: Set limit value
Description
You use the "Set limit value" instruction to limit the value at input IN to the values at the inputs
MN and MX. If the value at the IN input meets the MN condition <= IN <= MX, it is copied to
the OUT output. If the condition is not fulfilled and the input value IN is below the low limit MN,
output OUT is set to the value of the input MN. If the high limit MX is exceeded, output OUT
is set to the value of the input MX.
If the value at input MN is greater than that at input MX, the result is undefined and the enable
output ENO is "0".
Enable output ENO has the signal state "0" if one of the following conditions applies:
Enable input EN has the signal state "0".
The specified tags are not of the same data type.
An operand has an invalid value.
The value at input MN is greater than the value at input MX.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1776 System Manual, 01/2013,
Parameters
The following table shows the parameters of the "Set limit value" instruction:
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500 S7-1200 S7-1500
EN Input BOOL BOOL I, Q, M, D, L I, Q, M, D, L,
T, C
Enable input
ENO Output BOOL BOOL I, Q, M, D, L I, Q, M, D, L Enable
output
MN Input Integers,
floating-
point
numbers,
TIME,
TOD,
DATE, DT
Integers,
floating-
point
numbers,
timers, TOD,
LTOD,
DATE, DT,
LDT
I, Q, M, D, L,
P or constant
I, Q, M, D, L,
P or constant
Low limit
IN Input Integers,
floating-
point
numbers,
TIME,
TOD,
DATE, DT
Integers,
floating-
point
numbers,
timers, TOD,
LTOD,
DATE, DT,
LDT
I, Q, M, D, L,
P or constant
I, Q, M, D, L,
P or constant
Input value
MX Input Integers,
floating-
point
numbers,
TIME,
TOD,
DATE, DT
Integers,
floating-
point
numbers,
timers, TOD,
LTOD,
DATE, DT,
LDT
I, Q, M, D, L,
P or constant
I, Q, M, D, L,
P or constant
High limit
OUT Output Integers,
floating-
point
numbers,
TIME,
TOD,
DATE, DT
Integers,
floating-
point
numbers,
timers, TOD,
LTOD,
DATE, DT,
LDT
I, Q, M, D, L,
P
I, Q, M, D, L,
P
Result
You can select the data type of the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1777
Example
The following example shows how the instruction works:
"Tag_Value"
"Tag_MX"
"Tag_MN"
"Tag_Result"
"TagOut"
"Tagln_1"
"Tagln_2"
=
LlMlT
&
EN
ENO
OUT
lNT
MN
lN
MX
The following table shows how the instruction works using specific operand values:
Parameters Operand Value
MN Tag_MN 12000
IN Tag_Value 8000
MX Tag_MX 16000
OUT Tag_Result 12000
If the "TagIn_1" and "TagIn_2" operands have the signal state "1", the "Set limit value"
instruction is executed. The value of operand "Tag_Value" is compared with the values of
operands "Tag_MN" and "Tag_MX". Since the value at the operand "Tag_Value" is less than
the low limit, the value of the operand "Tag_MN" is copied to output "Tag_Result". If no errors
occur during the execution of the instruction, the output "TagOut" is set.
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
Adding additional inputs and outputs to FBD elements (Page 1144)
SQR: Form square
Description
You can use the "Form square" instruction to square the value at input IN and query the result
at output OUT.
Enable output ENO has the signal state "0" if one of the following conditions applies:
Enable input EN has the signal state "0".
The value at input IN is not a valid floating-point number.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1778 System Manual, 01/2013,
Parameters
The following table shows the parameters of the instruction "Form square":
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500
EN Input BOOL I, Q, M, D, L I, Q, M, D, L, T,
C
Enable input
ENO Output BOOL I, Q, M, D, L I, Q, M, D, L Enable output
IN Input Floating-point
numbers
I, Q, M, D, L, P
or constant
I, Q, M, D, L, P
or constant
Input value
OUT Output Floating-point
numbers
I, Q, M, D, L, P I, Q, M, D, L, P Square of the
input value
You can select the data type of the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
SQR
=
ENO
EN
lN
OUT
REAL
"TagOut"
"Tagln" "Tag_Result"
"Tag_Value"
The following table shows how the instruction works using specific operand values:
Parameters Operand Value
IN Tag_Value 5.0
OUT Tag_Result 25.0
If the operand "TagIn" has the signal state "1", the "Form square" instruction is executed. The
instruction squares the value of the operand "Tag_Value" and sends the result to output
"Tag_Result". If no errors occur during the execution of the instruction, the output "TagOut" is
set.
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1779
SQRT: Form square root
Description
You can use the "Form square root" instruction to form the square root of the value at input IN
and query the result at output OUT. The instruction has a positive result if the input value is
greater than zero. If input values are less than zero, output OUT returns an invalid floating-
point number. If the value at input IN is "0", the result is also "0".
Enable output ENO has the signal state "0" if one of the following conditions applies:
Enable input EN has the signal state "0".
The value at input IN is not a valid floating-point number.
The value at input IN is negative.
Parameters
The following table shows the parameters of the instruction "Form square root":
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500
EN Input BOOL I, Q, M, D, L I, Q, M, D, L, T,
C
Enable input
ENO Output BOOL I, Q, M, D, L I, Q, M, D, L Enable output
IN Input Floating-point
numbers
I, Q, M, D, L, P
or constant
I, Q, M, D, L, P
or constant
Input value
OUT Output Floating-point
numbers
I, Q, M, D, L I, Q, M, D, L Square root of
the input value
You can select the data type of the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
=
ENO
EN
lN
OUT
REAL
SQRT
"TagOut"
"Tagln" "Tag_Result"
"Tag_Value"
The following table shows how the instruction works using specific operand values:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1780 System Manual, 01/2013,
Parameters Operand Value
IN Tag_Value 25.0
OUT Tag_Result 5.0
If the operand "TagIn" has the signal state "1", the "Form square root" instruction is executed.
The instruction calculates the square root of the operand "Tag_Value" and sends the result to
output "Tag_Result". If no errors occur during the execution of the instruction, the output
"TagOut" is set.
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
LN: Form natural logarithm
Description
You can use the "Form natural logarithm" instruction to calculate the natural logarithm to base
e (e = 2.718282) of the value at input IN. The result is sent to output OUT and can be queried
there. The instruction has a positive result if the input value is greater than zero. If input values
are less than zero, output OUT returns an invalid floating-point number.
Enable output ENO has the signal state "0" if one of the following conditions applies:
Enable input EN has the signal state "0".
The value at input IN is not a valid floating-point number.
The value at input IN is negative.
Parameters
The following table shows the parameters of the instruction "Form natural logarithm":
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500
EN Input BOOL I, Q, M, D, L I, Q, M, D, L, T,
C
Enable input
ENO Output BOOL I, Q, M, D, L I, Q, M, D, L Enable output
IN Input Floating-point
numbers
I, Q, M, D, L, P
or constant
I, Q, M, D, L, P
or constant
Input value
OUT Output Floating-point
numbers
I, Q, M, D, L, P I, Q, M, D, L, P Natural
logarithm of
the input value
You can select the data type of the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1781
Example
The following example shows how the instruction works:
=
ENO
EN
lN
OUT
REAL
LN
"TagOut"
"Tagln" "Tag_Result"
"Tag_Value"
If the operand "TagIn" has the signal state "1", the "Form natural logarithm" instruction is
executed. The instruction forms the natural logarithm of the value at input "Tag_Value" and
sends the result to output "Tag_Result". If no errors occur during the execution of the
instruction, the output "TagOut" is set.
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
EXP: Form exponential value
Description
You can use the "Form exponential value" instruction to calculate the exponent from the base
e (e = 2.718282 and the value specified at input IN. The result is provided at output OUTand
can be queried there (OUT = e
IN
).
Enable output ENO has the signal state "0" if one of the following conditions applies:
Enable input EN has the signal state "0".
The value at input IN is not a valid floating-point number.
Parameters
The following table shows the parameters of the instruction "Form exponential value":
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500
EN Input BOOL I, Q, M, D, L I, Q, M, D, L, T,
C
Enable input
ENO Output BOOL I, Q, M, D, L I, Q, M, D, L Enable output
IN Input Floating-point
numbers
I, Q, M, D, L, P
or constant
I, Q, M, D, L, P
or constant
Input value
OUT Output Floating-point
numbers
I, Q, M, D, L, P I, Q, M, D, L, P Exponential
value of the
input value IN
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1782 System Manual, 01/2013,
You can select the data type of the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
=
ENO
EN
lN
OUT
REAL
EXP
"TagOut"
"Tagln" "Tag_Result"
"Tag_Value"
If the operand "TagIn" has the signal state "1", the "Form exponential value" instruction is
executed. The instruction forms the exponent from base e and the value of the operand
"Tag_Value" and sends the result to output "Tag_Result". If no errors occur during the
execution of the instruction, the output "TagOut" is set.
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
SIN: Form sine value
Description
You can use the "Form sine value" instruction to calculate the sine of an angle. The size of the
angle is specified in the radian measure at input IN. The result of the instruction is provided at
output OUT and can be queried there.
Enable output ENO has the signal state "0" if one of the following conditions applies:
Enable input EN has the signal state "0".
The value at input IN is not a valid floating-point number.
Parameters
The following table shows the parameters of the instruction "Form sine value":
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500
EN Input BOOL I, Q, M, D, L I, Q, M, D, L, T,
C
Enable input
ENO Output BOOL I, Q, M, D, L I, Q, M, D, L Enable output
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1783
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500
IN Input Floating-point
numbers
I, Q, M, D, L, P
or constant
I, Q, M, D, L, P
or constant
Size of angle in
the radian
measure
OUT Output Floating-point
numbers
I, Q, M, D, L, P I, Q, M, D, L, P Sine of the
specified angle
You can select the data type of the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
=
ENO
EN
lN
OUT
REAL
SlN
"TagOut"
"Tagln" "Tag_Result"
"Tag_Value"
The following table shows how the instruction works using specific operand values:
Parameters Operand Value
IN Tag_Value +1.570796 (/2)
OUT Tag_Result 1.0
If the operand "TagIn" has the signal state "1", the "Form sine value" instruction is executed.
The instruction calculates the sine of the angle specified at input "Tag_Value" and sends the
result to output "Tag_Result". If no errors occur during the execution of the instruction, the
output "TagOut" is set.
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
COS: Form cosine value
Description
You can use the "Form cosine value" instruction to calculate the cosine of an angle. The size
of the angle is specified in the radian measure at input IN. The result of the instruction is
provided at output OUT and can be queried there.
Enable output ENO has the signal state "0" if one of the following conditions applies:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1784 System Manual, 01/2013,
Enable input EN has the signal state "0".
The value at input IN is not a valid floating-point number.
Parameters
The following table shows the parameters of the instruction "Form cosine value":
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500
EN Input BOOL I, Q, M, D, L I, Q, M, D, L, T,
C
Enable input
ENO Output BOOL I, Q, M, D, L I, Q, M, D, L Enable output
IN Input Floating-point
numbers
I, Q, M, D, L, P
or constant
I, Q, M, D, L, P
or constant
Size of angle in
the radian
measure
OUT Output Floating-point
numbers
I, Q, M, D, L, P I, Q, M, D, L, P Cosine of the
specified angle
You can select the data type of the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
=
ENO
EN
lN
OUT
REAL
COS
"TagOut"
"Tagln" "Tag_Result"
"Tag_Value"
The following table shows how the instruction works using specific operand values:
Parameters Operand Value
IN Tag_Value +1.570796 (/2)
OUT Tag_Result 0
If the operand "TagIn" has the signal state "1", the "Form cosine value" instruction is executed.
The instruction calculates the cosine of the angle specified at input "Tag_Value" and sends
the result to output "Tag_Result". If no errors occur during the execution of the instruction, the
output "TagOut" is set.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1785
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
TAN: Form tangent value
Description
You can use the "Form tangent value" instruction to calculate the tangent of an angle. The size
of the angle is specified in the radian measure at input IN. The result of the instruction is
provided at output OUT and can be queried there.
Enable output ENO has the signal state "0" if one of the following conditions applies:
Enable input EN has the signal state "0".
The value at input IN is not a valid floating-point number.
Parameters
The following table shows the parameters of the instruction "Form tangent value":
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500
EN Input BOOL I, Q, M, D, L I, Q, M, D, L, T,
C
Enable input
ENO Output BOOL I, Q, M, D, L I, Q, M, D, L Enable output
IN Input Floating-point
numbers
I, Q, M, D, L, P
or constant
I, Q, M, D, L, P
or constant
Size of angle in
the radian
measure
OUT Output Floating-point
numbers
I, Q, M, D, L, P I, Q, M, D, L, P Tangent of the
specified angle
You can select the data type of the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
TAN
ENO EN
lN OUT
REAL
"Tag_Result" "Tag_Value"
"TagOut" "Tagln"
The following table shows how the instruction works using specific operand values:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1786 System Manual, 01/2013,
Parameters Operand Value
IN Tag_Value +3.141593 ()
OUT Tag_Result 0
If the operand "TagIn" has the signal state "1", the "Form tangent value" instruction is executed.
The instruction calculates the tangent of the angle specified at input "Tag_Value" and stores
the result at output "Tag_Result". If no errors occur during the execution of the instruction, the
output "TagOut" is set.
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
ASIN: Form arcsine value
Description
You can use the "Form arcsine value" instruction to calculate the size of the angle from the
sine value specified at input IN, which corresponds to this value. Only valid floating-point
numbers within the range -1 to +1 can be specified at input IN. The calculated angle size is
output in radians at output OUT and can range in value from -/2 to +/2.
Enable output ENO has the signal state "0" if one of the following conditions applies:
Enable input EN has the signal state "0".
The value at input IN is not a valid floating-point number.
The value at input IN is outside the permitted range (-1 to +1).
Parameters
The following table shows the parameters of the instruction "Form arcsine value":
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500
EN Input BOOL I, Q, M, D, L I, Q, M, D, L, T,
C
Enable input
ENO Output BOOL I, Q, M, D, L I, Q, M, D, L Enable output
IN Input Floating-point
numbers
I, Q, M, D, L, P
or constant
I, Q, M, D, L, P
or constant
Sine value
OUT Output Floating-point
numbers
I, Q, M, D, L, P I, Q, M, D, L, P Size of angle in
the radian
measure
You can select the data type of the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1787
Example
The following example shows how the instruction works:
=
ENO
EN
lN
OUT
REAL
ASlN
"TagOut"
"Tagln" "Tag_Result"
"Tag_Value"
The following table shows how the instruction works using specific operand values:
Parameters Operand Value
IN Tag_Value 1.0
OUT Tag_Result +1.570796 (/2)
If the operand "TagIn" has the signal state "1", the "Form arcsine value" instruction is executed.
The instruction calculates the size of the angle corresponding to the sine value at input
"Tag_Value". The result of the instruction is stored at output "Tag_Result". If no errors occur
during the execution of the instruction, the output "TagOut" is set.
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
ACOS: Form arccosine value
Description
You can use the "Form arccosine value" instruction to calculate the size of the angle from the
cosine value specified at input IN, which corresponds to this value. Only valid floating-point
numbers within the range -1 to +1 can be specified at input IN. The calculated angle size is
output in radians at output OUT and can range in value from 0 to +.
Enable output ENO has the signal state "0" if one of the following conditions applies:
Enable input EN has the signal state "0".
The value at input IN is not a valid floating-point number.
The value at input IN is outside the permitted range (-1 to +1).
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1788 System Manual, 01/2013,
Parameters
The following table shows the parameters of the instruction "Form arccosine value":
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500
EN Input BOOL I, Q, M, D, L I, Q, M, D, L, T,
C
Enable input
ENO Output BOOL I, Q, M, D, L I, Q, M, D, L Enable output
IN Input Floating-point
numbers
I, Q, M, D, L, P
or constant
I, Q, M, D, L, P
or constant
Cosine value
OUT Output Floating-point
numbers
I, Q, M, D, L, P I, Q, M, D, L, P Size of angle in
the radian
measure
You can select the data type of the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
=
ENO
EN
lN
OUT
REAL
ACOS
"TagOut"
"Tagln" "Tag_Result"
"Tag_Value"
The following table shows how the instruction works using specific operand values:
Parameters Operand Value
IN Tag_Value 0
OUT Tag_Result +1.570796 (/2)
If the operand "TagIn" has the signal state "1", the "Form arccosine value" instruction is
executed. The instruction calculates the size of the angle corresponding to the cosine value
at input "Tag_Value". The result of the instruction is stored at output "Tag_Result". If no errors
occur during the execution of the instruction, the output "TagOut" is set.
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1789
ATAN: Form arctangent value
Description
You can use the "Form arctangent value" instruction to calculate the size of the angle from the
tangent value specified at input IN, which corresponds to this value. Only valid floating-point
numbers may be specified at input IN. The calculated angle size is output in radians at the
output OUT and can range in value from -/2 to +/2.
Enable output ENO has the signal state "0" if one of the following conditions applies:
Enable input EN has the signal state "0".
The value at input IN is not a valid floating-point number.
Parameters
The following table shows the parameters of the instruction "Form arctangent value":
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500
EN Input BOOL I, Q, M, D, L I, Q, M, D, L, T,
C
Enable input
ENO Output BOOL I, Q, M, D, L I, Q, M, D, L Enable output
IN Input Floating-point
numbers
I, Q, M, D, L, P
or constant
I, Q, M, D, L, P
or constant
Tangent value
OUT Output Floating-point
numbers
I, Q, M, D, L, P I, Q, M, D, L, P Size of angle in
the radian
measure
You can select the data type of the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
=
ENO
EN
lN
OUT
REAL
ATAN
"TagOut"
"Tagln" "Tag_Result"
"Tag_Value"
The following table shows how the instruction works using specific operand values:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1790 System Manual, 01/2013,
Parameters Operand Value
IN Tag_Value 1.0
OUT Tag_Result +0.785398 (/4)
If the operand "TagIn" has the signal state "1", the "Form arctangent value" instruction is
executed. The instruction calculates the size of the angle corresponding to the tangent value
at input "Tag_Value". The result of the instruction is stored at output "Tag_Result". If no errors
occur during the execution of the instruction, the output "TagOut" is set.
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
FRAC: Return fraction
Description
You can use the "Return fraction" instruction to determine the decimal places of the value at
the IN input. The result of the query is stored at output OUT and can be queried there. If the
input IN has e.g. the value 123.4567, the output OUT has the value 0.4567.
Enable output ENO has the signal state "0" if one of the following conditions applies:
Enable input EN has the signal state "0".
Errors occur during the execution of the instruction, for example there is no valid floating-
point number at the input.
Parameters
The following table shows the parameters of the "Return fraction" instruction:
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500
EN Input BOOL I, Q, M, D, L I, Q, M, D, L, T,
C
Enable input
ENO Output BOOL I, Q, M, D, L I, Q, M, D, L Enable output
IN Input Floating-point
numbers
I, Q, M, D, L, P
or constant
I, Q, M, D, L, P
or constant
Input value,
whose decimal
places are to
be determined.
OUT Output Floating-point
numbers
I, Q, M, D, L, P I, Q, M, D, L, P Decimal
places of the
input value at
input IN
You can select the data type of the instruction from the "<???>" drop-down list of the instruction
box.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1791
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
REAL
=
FRAC
&
EN
ENO
OUT
lN
"Tag_Result"
"Tag_Value"
"TagOut"
"Tagln_1"
"Tagln_2"
The following table shows how the instruction works using specific operand values:
Parameters Operand Value
IN Tag_Value 2.555
OUT Tag_Result 0.555
If the operands "TagIn_1" and "TagIn_2" have signal state "1", the "Return fraction" instruction
is executed. The decimal places from the value at the operand "Tag_Value" are copied to the
operand "Tag_Result". If the instruction is executed without errors, the ENO enable output has
the signal state "1" and the "TagOut" output is set.
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
Adding additional inputs and outputs to FBD elements (Page 1144)
EXPT: Exponentiate
Description
You can use the "Exponentiate" instruction to raise the value at the input IN1 by a power
specified with the value at input IN2. The result of the instruction is stored at output OUT and
can be queried there (OUT = IN1
IN2
).
The value at input IN1 must be a valid floating-point number. Integers are also allowed for
setting the input IN2.
Enable output ENO has the signal state "0" if one of the following conditions applies:
Enable input EN has the signal state "0".
Errors occur during the instruction processing, for example, if there is an overflow.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1792 System Manual, 01/2013,
Parameters
The following table shows the parameters of the instruction "Exponentiate":
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500
EN Input BOOL I, Q, M, D, L I, Q, M, D, L, T,
C
Enable input
ENO Output BOOL I, Q, M, D, L I, Q, M, D, L Enable output
IN1 Input Floating-point
numbers
I, Q, M, D, L, P
or constant
I, Q, M, D, L, P
or constant
Base value
IN2 Input Integers,
floating-point
numbers
I, Q, M, D, L, P
or constant
I, Q, M, D, L, P
or constant
Value with
which the base
value is
exponentiated
OUT Output Floating-point
numbers
I, Q, M, D, L, P I, Q, M, D, L, P Result
You can select the data type of the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
=
**
EXPT
&
EN
ENO
OUT lN1
lN2
REAL REAL
"Tag_Result"
"Tag_Value1"
"Tag_Value2"
"TagOut"
"Tagln_1"
"Tagln_2"
If the operands "TagIn_1" and "TagIn_2" have signal state "1", the "Exponentiate" instruction
is executed. The value of operand "Tag_Value1" is raised by the power of the value of the
operand "Tag_Value2". The result is stored at output "Tag_Result". If the instruction is executed
without errors, the ENO enable output has the signal state "1" and the "TagOut" output is set.
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
Adding additional inputs and outputs to FBD elements (Page 1144)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1793
Move operations
MOVE: Move value
Description
You use the "Move value" instruction to transfer the content of the operand at the IN input to
the operand at the OUT1 output. The transfer is always made in the direction of ascending
addresses.
The following table shows the possible transfers for the S7-1200 CPU family:
Source (IN) Destination (OUT1)
With IEC check Without IEC check
BYTE BYTE, WORD, DWORD BYTE, WORD, DWORD, SINT, USINT, INT, UINT,
DINT, UDINT, TIME, DATE ,TOD, CHAR
WORD WORD, DWORD BYTE, WORD, DWORD, SINT, USINT, INT, UINT,
DINT, UDINT, TIME, DATE, TOD, CHAR
DWORD DWORD BYTE, WORD, DWORD, SINT, USINT, INT, UINT,
DINT, UDINT, REAL, TIME, DATE, TOD, CHAR
SINT SINT BYTE, WORD, DWORD, SINT, USINT, INT, UINT,
DINT, UDINT, TIME, DATE, TOD
USINT USINT, UINT, UDINT BYTE, WORD, DWORD, SINT, USINT, INT, UINT,
DINT, UDINT, TIME, DATE, TOD
INT INT BYTE, WORD, DWORD, SINT, USINT, INT, UINT,
DINT, UDINT, TIME, DATE, TOD
UINT UINT, UDINT BYTE, WORD, DWORD, SINT, USINT, INT, UINT,
DINT, UDINT, TIME, DATE, TOD
DINT DINT BYTE, WORD, DWORD, SINT, USINT, INT, UINT,
DINT, UDINT, TIME, DATE, TOD
UDINT UDINT BYTE, WORD, DWORD, SINT, USINT, INT, UINT,
DINT, UDINT, TIME, DATE, TOD
REAL REAL DWORD, REAL
LREAL LREAL LREAL
TIME TIME BYTE, WORD, DWORD, SINT, USINT, INT, UINT,
DINT, UDINT, TIME
DATE DATE BYTE, WORD, DWORD, SINT, USINT, INT, UINT,
DINT, UDINT, DATE
TOD TOD BYTE, WORD, DWORD, SINT, USINT, INT, UINT,
DINT, UDINT, TOD
DTL DTL DTL
CHAR CHAR BYTE, WORD, DWORD, CHAR, Character of a
string
1)
Character of a
string
1)
Character of a string Character of a string CHAR
ARRAY
2)
ARRAY ARRAY
STRUCT STRUCT STRUCT
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1794 System Manual, 01/2013,
Source (IN) Destination (OUT1)
With IEC check Without IEC check
PLC data type
(UDT)
PLC data type (UDT) PLC data type (UDT)
IEC_TIMER IEC_TIMER IEC_TIMER
IEC_SCOUNTE
R
IEC_SCOUNTER IEC_SCOUNTER
IEC_USCOUNT
ER
IEC_USCOUNTER IEC_USCOUNTER
IEC_COUNTER IEC_COUNTER IEC_COUNTER
IEC_UCOUNTE
R
IEC_UCOUNTER IEC_UCOUNTER
IEC_DCOUNTE
R
IEC_DCOUNTER IEC_DCOUNTER
IEC_UDCOUN
TER
IEC_UDCOUNTER IEC_UDCOUNTER
The following table shows the possible transfers for the S7-1500 CPU family:
Source (IN) Destination (OUT1)
With IEC check Without IEC check
BYTE BYTE, WORD, DWORD,
LWORD
BYTE, WORD, DWORD, LWORD, SINT, USINT,
INT, UINT, DINT, UDINT, LINT, ULINT, TIME, LTIME,
LDT, DATE ,TOD, LTOD, CHAR
WORD WORD, DWORD, LWORD BYTE, WORD, DWORD, LWORD, SINT, USINT,
INT, UINT, DINT, UDINT, LINT, ULINT, S5TIME,
TIME, LTIME, LDT, DATE, TOD, LTOD, CHAR
DWORD DWORD, LWORD BYTE, WORD, DWORD, LWORD, SINT, USINT,
INT, UINT, DINT, UDINT, LINT, ULINT, REAL, TIME,
LTIME, LDT, DATE, TOD, LTOD, CHAR
LWORD LWORD BYTE, WORD, DWORD, LWORD, SINT, USINT,
INT, UINT, DINT, UDINT, LINT, ULINT, LREAL,
TIME, LTIME, LDT, DATE, TOD, LTOD, CHAR
SINT SINT BYTE, WORD, DWORD, LWORD, SINT, USINT,
INT, UINT, DINT, UDINT, LINT, ULINT, TIME, LTIME,
LDT, DATE, TOD, LTOD
USINT USINT, UINT, UDINT,
ULINT
BYTE, WORD, DWORD, LWORD, SINT, USINT,
INT, UINT, DINT, UDINT, LINT, ULINT, TIME, LTIME,
LDT, DATE, TOD, LTOD
INT INT BYTE, WORD, DWORD, LWORD, SINT, USINT,
INT, UINT, DINT, UDINT, LINT, ULINT, TIME, LTIME,
LDT, DATE, TOD, LTOD
UINT UINT, UDINT, ULINT BYTE, WORD, DWORD, LWORD, SINT, USINT,
INT, UINT, DINT, UDINT, LINT, ULINT, TIME, LTIME,
LDT, DATE, TOD. LTOD
DINT DINT BYTE, WORD, DWORD, LWORD, SINT, USINT,
INT, UINT, DINT, UDINT, LINT, ULINT, TIME, LTIME,
LDT, DATE, TOD, LTOD
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1795
Source (IN) Destination (OUT1)
With IEC check Without IEC check
UDINT UDINT, ULINT BYTE, WORD, DWORD, LWORD, SINT, USINT,
INT, UINT, DINT, UDINT, LINT, ULINT, TIME, LTIME,
LDT, DATE, TOD, LTOD
LINT LINT BYTE, WORD, DWORD, LWORD, SINT, USINT,
INT, UINT, DINT, UDINT, LINT, ULINT, TIME, LTIME,
LDT, DATE, TOD, LTOD
ULINT ULINT BYTE, WORD, DWORD, LWORD, SINT, USINT,
INT, UINT, DINT, UDINT, LINT, ULINT, TIME, LTIME,
LDT, DATE, TOD, LTOD
REAL REAL DWORD, REAL
LREAL LREAL LWORD, LREAL
S5TIME S5TIME WORD, S5TIME
TIME TIME BYTE, WORD, DWORD, LWORD, SINT, USINT,
INT, UINT, DINT, UDINT, LINT, ULINT, TIME
LTIME LTIME BYTE, WORD, DWORD, LWORD, SINT, USINT,
INT, UINT, DINT, UDINT, LINT, ULINT, LTIME
DATE DATE BYTE, WORD, DWORD, LWORD, SINT, USINT,
INT, UINT, DINT, UDINT, LINT, ULINT, DATE
DT DT DT
LDT LDT BYTE, WORD, DWORD, LWORD, SINT, USINT,
INT, UINT, DINT, UDINT, LINT, ULINT, LDT
TOD TOD BYTE, WORD, DWORD, LWORD, SINT, USINT,
INT, UINT, DINT, UDINT, LINT, ULINT, TOD
LTOD LTOD BYTE, WORD, DWORD, LWORD, SINT, USINT,
INT, UINT, DINT, UDINT, LINT, ULINT, LTOD
DTL DTL DTL
CHAR CHAR BYTE, WORD, DWORD, LWORD, CHAR, Character
of a string
1)
Character of a
string
1)
Character of a string Character of a string CHAR
ARRAY
2)
ARRAY ARRAY
STRUCT STRUCT STRUCT
COUNTER COUNTER, WORD, INT WORD, DWORD, INT, UINT, DINT, UDINT
TIMER TIMER, WORD, INT WORD, DWORD, INT, UINT, DINT, UDINT
PLC data type
(UDT)
PLC data type (UDT) PLC data type (UDT)
IEC_TIMER IEC_TIMER IEC_TIMER
IEC_LTIMER IEC_LTIMER IEC_LTIMER
IEC_SCOUNTE
R
IEC_SCOUNTER IEC_SCOUNTER
IEC_USCOUNT
ER
IEC_USCOUNTER IEC_USCOUNTER
IEC_COUNTER IEC_COUNTER IEC_COUNTER
IEC_UCOUNTE
R
IEC_UCOUNTER IEC_UCOUNTER
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1796 System Manual, 01/2013,
Source (IN) Destination (OUT1)
With IEC check Without IEC check
IEC_DCOUNTE
R
IEC_DCOUNTER IEC_DCOUNTER
IEC_UDCOUN
TER
IEC_UDCOUNTER IEC_UDCOUNTER
IEC_LCOUNTE
R
IEC_LCOUNTER IEC_LCOUNTER
IEC_ULCOUNT
ER
IEC_ULCOUNTER IEC_ULCOUNTER
1)
You can also use the "Move value" instruction to transfer individual characters of a string
(STRING) to operands of CHAR data type. The number of the character to be transferred is
specified in square brackets beside the operand name. "MyString[2]", for example, transfers
the second character of the "MyString" string. It is also possible to transfer from operands of
the data type CHAR to the individual characters of a string. You can also replace a specific
character of a string with a character of another string.
2)
Transferring entire arrays (ARRAY) is possible only when the array components of the
operands at input IN and at output OUT1 are of the same data type.
If the bit length of the data type at input IN exceeds the bit length of the data type at output
OUT1, the higher-order bits of the source value are lost. If the bit length of the data type at
input IN is less than the bit length of the data type at output OUT1, the higher-order bits of the
destination value will be overwritten with zeros.
In its initial state the instruction box contains 1 output (OUT1). The number of outputs can be
extended. The added outputs are numbered in ascending order on the box. During the
execution of the instruction the content of the operand at the input IN is transferred to all
available outputs. The instruction box cannot be extended if structured data types (DTL,
STRUCT, ARRAY) or characters of a string (STRING) are transferred.
You can also use the "Move block" (MOVE_BLK) and "Move block uninterruptible"
(UMOVE_BLK) instructions to move operands of the ARRAY data type. You can move
operands of the STRING data type with the instruction "Move character string" (S_MOVE).
Parameters
The following table shows the parameters of the "Move value" instruction:
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500 S7-1200 S7-1500
EN Input BOOL BOOL I, Q, M, D, L I, Q, M, D, L,
T, C
Enable input
ENO Output BOOL BOOL I, Q, M, D, L I, Q, M, D, L Enable
output
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1797
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500 S7-1200 S7-1500
IN Input Bit strings,
integers,
floating-
point
numbers,
DATE,
TIME, TOD,
DTL, CHAR,
STRUCT,
ARRAY,
IEC data
types, PLC
data type
(UDT)
Bit strings,
integers,
floating-
point
numbers,
DATE, DT,
LDT,
S5TIME,
TIME,
LTIME,
TOD,
LTOD, DTL,
CHAR,
STRUCT,
ARRAY,
TIMER,
COUNTER,
IEC data
types, PLC
data type
(UDT)
I, Q, M, D, L
or constant
I, Q, M, D, L
or constant
Element
used to
overwrite
the
destination
address.
OUT1 Output Bit strings,
integers,
floating-
point
numbers,
DATE,
TIME, TOD,
DTL, CHAR,
STRUCT,
ARRAY,
IEC data
types, PLC
data type
(UDT)
Bit strings,
integers,
floating-
point
numbers,
DATE, DT,
LDT,
S5TIME,
TIME,
LTIME,
TOD,
LTOD, DTL,
CHAR,
STRUCT,
ARRAY,
TIMER,
COUNTER,
IEC data
types, PLC
data type
(UDT)
I, Q, M, D, L I, Q, M, D, L Destination
address
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1798 System Manual, 01/2013,
Example
The following example shows how the instruction works:
MOVE
EN OUT1
= lN ENO
"TagOut"
"Tagln"
"Tagln_Value"
"TagOut_Value"
The following table shows how the instruction works using specific operand values:
Parameters Operand Value
IN TagIn_Value 0011 1111 1010 1111
OUT1 TagOut_Value 0011 1111 1010 1111
If the operand "TagIn" has the signal state "1", the "Move value" instruction is executed. The
instruction copies the content of the operand "TagIn_Value" to the operand "TagOut_Value"
and set output "TagOut" to signal state "1".
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
Removing instruction inputs and outputs (Page 1145)
MOVE_BLK: Move block (Page 1803)
UMOVE_BLK: Move block uninterruptible (Page 1806)
S_MOVE: Move character string (Page 2088)
Adding additional inputs and outputs to FBD elements (Page 1144)
FieldRead: Read field
Description
You can use the "Read field" instruction to read out a specific component from the field
specified in the MEMBER parameter and transfer its content to the tag in the VALUE
parameter. You use the parameter INDEX to define the index of the field components that are
to be read. At the parameter MEMBER you specify the first component of the field to be read.
The data types of the field component at parameter MEMBER and the tags at parameter
VALUE must correspond to the data type of the instruction "Read field".
Enable output ENO has the signal state "0" if one of the following conditions applies:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1799
Enable input EN has the signal state "0".
The field component specified at the parameter INDEX is not defined in the field specified
at the parameter MEMBER.
Errors, such as an overflow, occur during execution.
Parameters
The following table shows the parameters of the instruction "Read field":
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500 S7-1200 S7-1500
EN Input BOOL BOOL I, Q, M, D, L I, Q, M, D, L,
T, C
Enable input
ENO Output BOOL BOOL I, Q, M, D, L I, Q, M, D, L Enable
output
INDEX Input DINT DINT I, Q, M, D, L,
P or
constant
I, Q, M, D, L,
P or
constant
Index of field
components
whose
content is
read out
MEMBER Input Binary
numbers,
integers,
floating-
point
numbers,
TIME,
DATE, TOD
and CHAR
as
components
of an
ARRAY tag
Binary
numbers,
integers,
floating-
point
numbers,
timers,
DATE,
TOD, LTOD
and CHAR
as
components
of an
ARRAY tag
D, L D, L First
component
of the field
from which
will be read
VALUE Output Bit strings,
integers,
floating-
point
numbers,
TIME,
DATE, TOD
and CHAR
Bit strings,
integers,
floating-
point
numbers,
timers,
DATE,
TOD, LTOD
and CHAR
I, Q, M, D, L,
P
I, Q, M, D, L,
P
Operand to
which the
contents of
the field
component
are
transferred.
You can select the data type of the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1800 System Manual, 01/2013,
Example
The following example shows how the instruction works:
EN
FieldRead
ENO
lNDEX VALUE
REAL
MEMBER
#a_index #a_real
"DB_1".
Main_Field[-10]
"TagOut"
"Tagln"
The following table shows how the instruction works using specific operand values:
Parameters Tag Value
INDEX a_index 4
MEMBER "DB_1".Main_Field[-10] First component of the field
"Main_Field[-10..10] of REAL" in the data
block "DB_1"
VALUE a_real Component with Index 4 of the field
"Main_Field[-10..10] of REAL"
The field component with index 4 is read out from the field "Main_Field[-10...10] of REAL" and
written to the tag "a_real". The field component to be read is defined by the value at the
parameter INDEX.
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
FieldWrite: Write field
Description
The "Write field" instruction is used to transfer the content of the tag at the VALUE input to a
specific component of the field at the MEMBER output. You use the value at the INDEX input
to specify the index of the field component that is described. At the MEMBER output, enter the
first component of the field which is to be written to.
The data types of the field component specified at the MEMBER output and the tags at the
VALUE input have to match the data type of the "Write field" instruction.
Enable output ENO has the signal state "0" if one of the following conditions applies:
Enable input EN has the signal state "0".
The field component specified at the input INDEX is not defined in the field specified at the
output MEMBER.
Errors, such as an overflow, occur during execution.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1801
Parameters
The following table shows the parameters of the instruction "Write field":
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500 S7-1200 S7-1500
EN Input BOOL BOOL I, Q, M, D, L I, Q, M, D, L,
T, C
Enable input
ENO Output BOOL BOOL I, Q, M, D, L I, Q, M, D, L Enable
output
INDEX Input DINT DINT I, Q, M, D, L,
P or
constant
I, Q, M, D, L,
P or
constant
Index of field
component
that is
written with
the content
of VALUE
VALUE Input Bit strings,
integers,
floating-
point
numbers,
TIME,
DATE, TOD
and CHAR
Bit strings,
integers,
floating-
point
numbers,
timers,
DATE,
TOD, LTOD
and CHAR
I, Q, M, D, L,
P or
constant
I, Q, M, D, L,
P or
constant
Operand
whose
contents are
copied
MEMBER Output Binary
numbers,
integers,
floating-
point
numbers,
TIME,
DATE, TOD
and CHAR
as
components
of an
ARRAY tag
Binary
numbers,
integers,
floating-
point
numbers,
timers,
DATE,
TOD, LTOD
and CHAR
as
components
of an
ARRAY tag
D, L D, L First
component
of the field to
which the
content of
VALUE is
written.
You can select the data type of the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1802 System Manual, 01/2013,
Example
The following example shows how the instruction works:
EN
FieldWrite
ENO
lNDEX
VALUE
REAL
MEMBER
#a_index
#a_real
"DB_1".
Main_Field[-10]
"TagOut"
"Tagln"
The following table shows how the instruction works using specific operand values:
Parameters Operand Value
INDEX a_index 4
VALUE a_real 10.54
MEMBER "DB_1".Main_Field[-10] First component of the field
"Main_Field[-10..10] of REAL" in the data
block "DB_1"
The value "10.54" of the "a_real" tag is written to the field component with index 4 of the
"Main_Field[-10 ... 10] of REAL" field. The index of the field component to which the content
of the tag "a_real" is transferred is specified by the value at the input INDEX.
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
MOVE_BLK: Move block
Description
You can use the "Move block" instruction to move the content of a memory area (source area)
to another memory area (destination area). The number of elements to be moved to the
destination area is specified with the COUNT parameter. The width of the elements to be
moved is defined by the width of the element at input IN.
Enable output ENO has the signal state "0" if one of the following conditions applies:
Enable input EN has the signal state "0".
More data is moved than is made available at input IN or output OUT.
If the last BOOL element of an ARRAY structure is not at a byte limit (for example, bit 16 of 2
bytes) and an overflow occurs, the ENO enable output remains at "1" until the byte limit of the
ARRAY structure is exceeded. If the byte limit of the ARRAY structure is exceeded by the
value at the COUNT input, the ENO enable output is reset to "0".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1803
Parameters
The following table shows the parameters of the "Move block" instruction:
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500 S7-1200 S7-1500
EN Input BOOL BOOL I, Q, M, D, L I, Q, M, D, L,
T, C
Enable input
ENO Output BOOL BOOL I, Q, M, D, L I, Q, M, D, L Enable
output
IN Input Binary
numbers,
integers,
floating-
point
numbers,
TIME,
DATE,
CHAR,
TOD, DATE
and CHAR
as
components
of an
ARRAY
structure
Binary
numbers,
integers,
floating-
point
numbers,
S5TIME,
TIME,
LTIME,
DATE,
CHAR,
TOD,
LTOD,
DATE and
CHAR as a
component
of an
ARRAY
structure
D, L D, L The first
element of
the source
area to be
moved.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1804 System Manual, 01/2013,
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500 S7-1200 S7-1500
COUNT Input USINT,
UINT,
UDINT
USINT,
UINT,
UDINT,
ULINT
I, Q, M, D, L,
P or
constant
I, Q, M, D, L,
P or
constant
Number of
elements to
be moved
from the
source area
to the
destination
area.
OUT Output Binary
numbers,
integers,
floating-
point
numbers,
TIME,
DATE,
CHAR,
TOD, DATE
and CHAR
as
components
of an
ARRAY
structure
Binary
numbers,
integers,
floating-
point
numbers,
S5TIME,
TIME,
LTIME,
DATE,
CHAR,
TOD,
LTOD,
DATE and
CHAR as a
component
of an
ARRAY
structure
D, L D, L The first
element of
the
destination
area to
which the
content of
the source
area is
moved.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
=
&
EN
ENO COUNT
OUT lN
MOVE_BLK
#b_array[1] #a_array[2]
"TagOut"
"Tagln_1"
"Tagln_2"
"Tag_Count"
The following table shows how the instruction works using specific operand values:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1805
Parameters Operand Value
IN a_array[2] Operand "a_array" is of the
ARRAY data type and consists
of 5 elements of the INT data
type.
COUNT Tag_Count 3
OUT b_array[1] Operand "b_array" is of the
ARRAY data type and consists
of 6 elements of the INT data
type.
If the operands "TagIn_1" and "TagIn_2" have signal state "1", the "Move block" instruction is
executed. The instruction selects three INT elements from the tag "a_array" (a_array[2..4]) and
moves their content to the output tag "b_array" (b_array[1..3]). If the instruction is executed
without errors, the ENO enable output has the signal state "1" and the "TagOut" output is set.
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
UMOVE_BLK: Move block uninterruptible
Description
You can use the "Move block uninterruptible" instruction to move the content of a memory area
(source area) to another memory area (destination area). The number of elements to be moved
to the destination area is specified with the COUNT parameter. The width of the elements to
be moved is defined by the width of the element at input IN.
Note
The move operation cannot be interrupted by other operating system activities. This is why
the alarm reaction times of the CPU increase during the execution of the "Move block
uninterruptible" instruction.
Enable output ENO has the signal state "0" if one of the following conditions applies:
Enable input EN has the signal state "0".
More data is moved than is made available at input IN or output OUT.
If the last BOOL element of an ARRAY structure is not at a byte limit (for example, bit 16 of 2
bytes) and an overflow occurs, the ENO enable output remains at "1" until the byte limit of the
ARRAY structure is exceeded. If the byte limit of the ARRAY structure is exceeded by the
value at the COUNT input, the ENO enable output is reset to "0".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1806 System Manual, 01/2013,
Parameters
The following table shows the parameters of the "Move block uninterruptible" instruction:
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500 S7-1200 S7-1500
EN Input BOOL BOOL I, Q, M, D, L I, Q, M, D, L,
T, C
Enable input
ENO Output BOOL BOOL I, Q, M, D, L I, Q, M, D, L Enable
output
IN Input Binary
numbers,
integers,
floating-
point
numbers,
TIME,
DATE,
CHAR,
TOD, DATE
and CHAR
as
components
of an
ARRAY
structure
Binary
numbers,
integers,
floating-
point
numbers,
S5TIME,
TIME,
LTIME,
DATE,
CHAR,
TOD,
LTOD,
DATE and
CHAR as a
component
of an
ARRAY
structure
D, L D, L The first
element of
the source
area to be
moved.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1807
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500 S7-1200 S7-1500
COUNT Input USINT,
UINT,
UDINT
USINT,
UINT,
UDINT,
ULINT
I, Q, M, D, L,
P or
constant
I, Q, M, D, L,
P or
constant
Number of
elements to
be moved
from the
source area
to the
destination
area.
OUT Output Binary
numbers,
integers,
floating-
point
numbers,
TIME,
DATE,
CHAR,
TOD, DATE
and CHAR
as
components
of an
ARRAY
structure
Binary
numbers,
integers,
floating-
point
numbers,
S5TIME,
TIME,
LTIME,
DATE,
CHAR,
TOD,
LTOD,
DATE and
CHAR as a
component
of an
ARRAY
structure
D, L D, L The first
element of
the
destination
area to
which the
content of
the source
area is
moved.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
=
&
EN
ENO COUNT
OUT lN
UMOVE_BLK
#b_array[1] #a_array[2]
"TagOut"
"Tagln_1"
"Tagln_2"
"Tag_Count"
The following table shows how the instruction works using specific operand values:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1808 System Manual, 01/2013,
Parameters Operand Value
IN a_array[2] Operand "a_array" is of the
ARRAY data type and consists
of 5 elements of the INT data
type.
COUNT Tag_Count 3
OUT b_array[1] Tag "b_array" is of the ARRAY
data type and consists of 6
elements of the INT data type.
If the operands "TagIn_1" and "TagIn_2" have signal state "1", the "Move block uninterruptible"
instruction is executed. The instruction selects three INT elements from the tag "a_array"
(a_array[2..4]) and moves their content to the output tag "b_array" (b_array[1..3]). The move
operation cannot be interrupted by other operating system activities. If the instruction is
executed without errors, the ENO enable output has the signal state "1" and the "TagOut"
output is set.
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
FILL_BLK: Fill block
Description
You can use the "Fill block" instruction to fill a memory area (destination area) with the value
of input IN. The destination area is filled beginning with the address specified at the OUT output.
The number of repeated move operations is specified with the COUNT parameter. When the
instruction is executed, the value at the input IN is selected and moved to the destination area
as often as specified by the value of the COUNT parameter.
Enable output ENO has the signal state "0" if one of the following conditions applies:
Enable input EN has the signal state "0".
More data is moved than is made available at input IN or output OUT.
If the last BOOL element of an ARRAY structure is not at a byte limit (for example, bit 16 of 2
bytes) and an overflow occurs, the ENO enable output remains at "1" until the byte limit of the
ARRAY structure is exceeded. If the byte limit of the ARRAY structure is exceeded by the
value at the COUNT input, the ENO enable output is reset to "0".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1809
Parameters
The following table shows the parameters of the "Fill block" instruction:
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500 S7-1200 S7-1500
EN Input BOOL BOOL I, Q, M, D, L I, Q, M, D, L,
T, C
Enable input
ENO Output BOOL BOOL I, Q, M, D, L I, Q, M, D, L Enable
output
IN Input Binary
numbers,
integers,
floating-
point
numbers,
TIME,
DATE,
TOD,
CHAR,
DATE and
CHAR as
components
of an
ARRAY
structure
Binary
numbers,
integers,
floating-
point
numbers,
S5TIME,
TIME,
LTIME,
DATE,
CHAR,
TOD,
LTOD,
DATE and
CHAR as a
component
of an
ARRAY
structure
I, Q, M, D, L,
P or
constant
I, Q, M, D, L,
P or
constant
Element
used to fill
the
destination
area.
COUNT Input USINT,
UINT,
UDINT
USINT,
UINT,
UDINT,
ULINT
I, Q, M, D, L,
P or
constant
I, Q, M, D, L,
P or
constant
Number of
repeated
move
operations
OUT Output Binary
numbers,
integers,
floating-
point
numbers,
TIME,
DATE,
TOD,
CHAR,
DATE and
CHAR as
components
of an
ARRAY
structure
Binary
numbers,
integers,
floating-
point
numbers,
S5TIME,
TIME,
LTIME,
DATE,
CHAR,
TOD,
LTOD,
DATE and
CHAR as a
component
of an
ARRAY
structure
D, L D, L Address in
destination
area where
filling
begins.
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1810 System Manual, 01/2013,
Example
The following example shows how the instruction works:
=
&
EN
ENO COUNT
OUT lN
FlLL_BLK
#b_array[1] #a_array[2]
"TagOut"
"Tagln_1"
"Tagln_2"
"Tag_Count"
The following table shows how the instruction works using specific operand values:
Parameters Operand Value
IN A_array[2] Operand "a_array" is of the
ARRAY data type and consists
of 4 elements of the WORD
(ARRAY[1..4] of WORD) data
type.
COUNT Tag_Count 3
OUT b_array[1] Operand "b_array" is of the
ARRAY data type and consists
of 5 elements of the WORD
(ARRAY[1..5] of WORD) data
type.
If the operands "TagIn_1" and "TagIn_2" have signal state "1", the "Fill block" instruction is
executed. The instruction moves the second element (a_array[2]) of the tag "a_array" three
times to the output tag "b_array" (b_array[1..3]). If no errors occur during the execution of the
instruction, the outputs ENO and "TagOut" are set to signal state "1".
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
UFILL_BLK: Fill block uninterruptible
Description
You can use the instruction "Fill block uninterruptible" to fill a memory area (destination area)
with the value of input IN uninterruptibly. The destination area is filled beginning with the
address specified at the OUT output. The number of repeated move operations is specified
with the COUNT parameter. When the instruction is executed, the value at the input IN is
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1811
selected and moved to the destination area as often as specified by the value of the COUNT
parameter.
Note
The move operation cannot be interrupted by other operating system activities. This is why
the alarm reaction times of the CPU increase during the execution of the "Fill block
uninterruptible" instruction.
Enable output ENO has the signal state "0" if one of the following conditions applies:
Enable input EN has the signal state "0".
More data is moved than is made available at input IN or output OUT.
If the last BOOL element of an ARRAY structure is not at a byte limit (for example, bit 16 of 2
bytes) and an overflow occurs, the ENO enable output remains at "1" until the byte limit of the
ARRAY structure is exceeded. If the byte limit of the ARRAY structure is exceeded by the
value at the COUNT input, the ENO enable output is reset to "0".
Parameters
The following table shows the parameters of the "Fill block uninterruptible" instruction:
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500 S7-1200 S7-1500
EN Input BOOL BOOL I, Q, M, D, L I, Q, M, D, L,
T, C
Enable input
ENO Output BOOL BOOL I, Q, M, D, L I, Q, M, D, L Enable
output
IN Input Binary
numbers,
integers,
floating-
point
numbers,
TIME,
DATE,
CHAR,
TOD, DATE
and CHAR
as
components
of an
ARRAY
structure
Binary
numbers,
integers,
floating-
point
numbers,
S5TIME,
TIME,
LTIME,
DATE,
CHAR,
TOD,
LTOD,
DATE and
CHAR as a
component
of an
ARRAY
structure
I, Q, M, D, L,
P or
constant
I, Q, M, D, L,
P or
constant
Element
used to fill
the
destination
area.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1812 System Manual, 01/2013,
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500 S7-1200 S7-1500
COUNT Input USINT,
UINT,
UDINT
USINT,
UINT,
UDINT,
ULINT
I, Q, M, D, L,
P or
constant
I, Q, M, D, L,
P or
constant
Number of
repeated
move
operations
OUT Output Binary
numbers,
integers,
floating-
point
numbers,
TIME,
DATE,
CHAR,
TOD, DATE
and CHAR
as
components
of an
ARRAY
structure
Binary
numbers,
integers,
floating-
point
numbers,
S5TIME,
TIME,
LTIME,
DATE,
CHAR,
TOD,
LTOD,
DATE and
CHAR as a
component
of an
ARRAY
structure
D, L D, L Address in
destination
area where
filling
begins.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
=
&
EN
ENO COUNT
OUT lN
UFlLL_BLK
#b_array[1] #a_array[2]
"TagOut"
"Tagln_1"
"Tagln_2"
"Tag_Count"
The following table shows how the instruction works using specific operand values:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1813
Parameters Operand Value
IN a_array[2] Operand "a_array" is of the
ARRAY data type and consists
of 4 elements of the WORD
(ARRAY[1..4] of WORD) data
type.
COUNT Tag_Count 3
OUT b_array[1] Operand "b_array" is of the
ARRAY data type and consists
of 5 elements of the WORD
(ARRAY[1..5] of WORD) data
type.
If the operands "TagIn_1" and "TagIn_2" have signal state "1", the "Fill block uninterruptible"
instruction is executed. The instruction moves the second element (a_array[2]) of the tag
"a_array" three times to the output tag "b_array" (b_array[1..3]). The move operation cannot
be interrupted by other operating system activities. If no errors occur during the execution of
the instruction, the outputs ENO and "TagOut" are set to signal state "1".
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
SWAP: Swap
Description
You can use the instruction "Swap" to change the order of the bytes within the tag at input IN
and query the result at output OUT.
The following figure shows how the bytes of a DWORD data type operand are swapped using
the "Swap" instruction:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1814 System Manual, 01/2013,
15... ...8 7... ...0
0 1 1 0 1 0 1 0 0 1 0 1 1 1 0 0 0 0 0 1 1 1 1 0 1 1 0 0 0 1 0 1
16 23... ...24 31...
15... ...8 7... ...0
1 1 0 0 0 1 0 1 0 0 0 1 1 1 1 0 0 1 0 1 1 1 0 0 0 1 1 0 1 0 1 0
16 23... ...24 31...
OUT
lN
1 2 3 4
1
2
3 4
Parameters
The following table shows the parameters of the "Swap" instruction:
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500 S7-1200 S7-1500
EN Input BOOL BOOL I, Q, M, D, L I, Q, M, D, L,
T, C
Enable input
ENO Output BOOL BOOL I, Q, M, D, L I, Q, M, D, L Enable
output
IN Input WORD,
DWORD
WORD,
DWORD,
LWORD
I, Q, M, D, L,
P or
constant
I, Q, M, D, L,
P or
constant
Operand
whose bytes
are
swapped.
OUT Output WORD,
DWORD
WORD,
DWORD,
LWORD
I, Q, M, D, L,
P
I, Q, M, D, L,
P
Result
You can select the data type of the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1815
Example
The following example shows how the instruction works:
S
SWAP
lN
EN
ENO
OUT
WORD
"Tagln"
"Tagln_Value"
"TagOut_Value"
"TagOut"
The following table shows how the instruction works using specific operand values:
Parameters Operand Value
IN TagIn_Value 0000 1111 0101 0101
OUT TagOut_Value 0101 0101 0000 1111
If the operand "TagIn" has the signal state "1", the "Swap" instruction is executed. The
arrangement of the bytes is changed and stored in the operand "TagOut_Value".
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
BLKMOV: Move block
Description
You can use the "Move block" instruction to move the content of a memory area (source area)
to another memory area (destination area). The move operation takes place in the direction
of ascending addresses. Use VARIANT to define the source and destination area.
Note
You can only use the tags of the instruction in the data blocks with the block property
"Standard access" or, if the tag was declared with retentivity setting "Set in IDB", also "with
optimized access".
The following figure shows the principle of the move operation:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1816 System Manual, 01/2013,
The move takes place in
the direction of ascending
addresses
Memory area
Move
A DB10.DBW4
DB10.DBW6
DB10.DBW8
DB10.DBW10
MW10
MW12
MW14
MW16
B
C D
E F
G H
A B
C D
E F
G H
Consistency of the source data and the target data
Make sure that the source data remain unchanged during the execution of the instruction "Move
block". Otherwise the consistency of the target data cannot be ensured.
Interruptibility
As long as the source area is not part of a data block that only exists in the load memory, there
is no limit to the nesting depth.
If, however, BLKMOV is interrupted while copying from a DB that is not relevant to program
execution, the execution of BLKMOV can no longer be nested.
Memory areas
You can use the "Move block" instruction to move the following memory areas:
Areas of a data block
Bit memory
Process image input table
Process image output table
Data blocks not relevant for program execution
General rules for moving
The source and destination area must not overlap. If the source and destination area have
different lengths, only the length of the smaller area will be moved.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1817
If the source area is less than the destination area, the entire source area will be written to the
destination area. The remaining bytes of the destination area remain unchanged.
If the destination area is less than the source area, the entire destination area will be written.
The remaining bytes of the source area are ignored.
If a block of data type BOOL is moved, the specified length of the area must be dividable by
8, otherwise it will not be possible to execute the instruction.
Rules for moving character strings
You can use the "Move block" instruction to also move source and destination areas of the
STRING data type. If only the source area is of data type STRING, the characters will be moved
that are actually contained in the character string. Information on the actual and maximum
length is also written to the destination area. If the source and destination area are each
STRING data type, the current length of the character string in the destination area is set to
the number of actually moved characters.
If you want to move the information on the maximum and actual length of a character string,
specify the areas in bytes to the SRCBLK and DSTBLK parameters.
Rules for moving data blocks that are not relevant to the program execution
The source area is in a data block in load memory that is not relevant for program execution.
Data blocks that are not relevant for program execution are marked with the key word
UNLINKED.
If an unlinked data block is copied to the work memory with the "Move block" instruction and
loaded at the same time, for example, by the programming device, the execution of the
instruction can be delayed for several milliseconds. This results in a longer OB cycle and may
trip the cycle monitoring.
If an unlinked data block is moved with the "Move block" instruction and the move operation
is interrupted, the execution of the instruction can no longer be continued.
If the instruction Read from data block in the load memory is available on your CPU, you must
use this instruction to read data blocks that are not runtime-relevant from load memory. If you
use the "Move block" instruction, error W#16#8092 is output.
Parameters
The following table shows the parameters of the "Move block" instruction:
Param
eters
Declar
ation
Data
type
Memory area Description
S7-1200 S7-1500
EN Input BOOL I, Q, M, D, L I, Q, M, D, L, T, C Enable input
ENO Output BOOL I, Q, M, D, L I, Q, M, D, L Enable output
SRCB
LK
Input ANY I, Q, M, D, L, P I, Q, M, D, L, P Specifies the memory area to
be moved
(source area).
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1818 System Manual, 01/2013,
Param
eters
Declar
ation
Data
type
Memory area Description
S7-1200 S7-1500
RET_
VAL
Output INT I, Q, M, D, L, P I, Q, M, D, L, P Error information:
If an error occurs during the
execution of the instruction, an
error code is output on the
RET_VAL parameter.
DSTB
LK
Output ANY I, Q, M, D, L, P I, Q, M, D, L, P Specifies the memory area to
which the block is to be moved
(destination area).
Parameters RET_VAL
The following table shows the meaning of the values of the RET_VAL parameter:
Error code*
(W#16#...)
Explanation
0000 No error
8091 The permitted nesting depth was exceeded
8092 The instruction cannot be executed because a specified data block is write protection, non-executable or
unloaded.
8xyy For more information on errors, refer to "See also".
*The error codes can be displayed as integer or hexadecimal value in the program editor. For additional information on
toggling display formats, refer to "See also".
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
UBLKMOV: Move block uninterruptible
Description
You can use the "Move block uninterruptible" instruction to move the content of a memory area
(source area) to another memory area (destination area). The move operation takes place in
the direction of ascending addresses. You use ANY pointer to define the source and destination
area.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1819
The move operation cannot be interrupted by other operating system activities. As a result the
alarm reaction time of the CPU can increase during the execution of the "Move block
uninterruptible" instruction.
Note
You can only use the tags of the instruction in the data blocks with the block property
"Standard access" or, if the tag was declared with retentivity setting "Set in IDB", also "with
optimized access".
Memory areas
You can use the "Move block uninterruptible" instruction to move the following memory areas:
Areas of a data block
Bit memory
Process image input table
Process image output table
General rules for moving
The source and destination area must not overlap during the execution of the "Move block
uninterruptible" instruction. If the source area is less than the destination area, the entire source
area will be written to the destination area. The remaining bytes of the destination area remain
unchanged.
If the destination area is less than the source area, the entire destination area will be written.
The remaining bytes of the source area are ignored.
If a source or destination area defined as a formal parameter is less than a destination or
source area specified on the SRCBLK or DSTBLK parameter, no data will be transferred.
If a block of data type BOOL is moved, the specified length of the area must be dividable by
8, otherwise it will not be possible to execute the instruction.
You can use the "Move block uninterruptible" instruction to move a maximum of 512 bytes.
Note the CPU specific restrictions for this.
Rules for moving character strings
You can use the "Move block uninterruptible" instruction to also move source and destination
areas of the STRING data type. If only the source area is of data type STRING, the characters
will be moved that are actually contained in the character string. Information on the actual and
maximum length are not written in the destination area. If the source and destination area are
each STRING data type, the current length of the character string in the destination area is
set to the number of actually moved characters. If areas of the data type STRING are moved,
you have to specify "1" as area length.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1820 System Manual, 01/2013,
Parameters
The following table shows the parameters of the "Move block uninterruptible" instruction:
Param
eters
Declarat
ion
Data
type
Memory area Description
S7-1200 S7-1500
EN Input BOOL I, Q, M, D, L I, Q, M, D, L, T,
C
Enable input
ENO Output BOOL I, Q, M, D, L I, Q, M, D, L Enable output
SRCBL
K
Input ANY I, Q, M, D, L, P I, Q, M, D, L, P Specifies the memory area to be
moved
(source area).
RET_V
AL
Output INT I, Q, M, D, L, P I, Q, M, D, L, P Error information:
If an error occurs during the
execution of the instruction, an error
code is output on the RET_VAL
parameter.
DSTBL
K
Output ANY I, Q, M, D, L, P I, Q, M, D, L, P Specifies the memory area to which
the block is to be moved (destination
area).
Parameters RET_VAL
The following table shows the meaning of the values of the RET_VAL parameter:
Error code
(W#16#...)
Explanation
0000 No error
8091 The source area is in a data block that is not relevant for program execution.
8xyy For more information on errors, refer to "See also".
*The error codes can be displayed as integer or hexadecimal value in the program editor. For additional information on
toggling display formats, refer to "See also".
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
FILL: Fill block
Description
You can use the "Fill block" instruction to fill a memory area (destination area) with the content
of another memory area (source area). The "Fill block" instruction moves the content of the
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1821
source area to the destination area until the destination area is completely written. The move
operation takes place in the direction of ascending addresses.
Note
You can only use the tags of the instruction in the data blocks with the block property
"Standard access" or, if the tag was declared with retentivity setting "Set in IDB", also "with
optimized access".
The following figure shows the principle of the move operation:
BVAL
BLK
FlLL
MW14
MW16
MW18
MW20
MW100
MW102
MW104
MW106
A B
C D
E F
G H
A B
C D
E F
G H
A B
C D
MW108
MW110
MW112
MW114
MW116
MW118
A B
C D
E F
G H
Consistency of the source data and the target data
Please note that during execution of the instruction "Fill block" that the source data remain
unchanged, otherwise the consistency of the target data is not ensured.
Memory areas
You can use the "Fill block" instruction to move the following memory areas:
Areas of a data block
Bit memory
Process image input table
Process image output table
Data blocks not relevant for program execution
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1822 System Manual, 01/2013,
General rules for moving
The source and destination area must not overlap. If the destination block to be preset is not
an integer multiple of the length of the input parameter BVAL, the destination block is
nevertheless written up to the last byte.
If the destination area to be preset is smaller than the source area, the function only copies as
much data as can be written to the destination area.
If the destination or source block actually present is smaller than the assigned memory area
for the source or destination block (BVAL, BLK parameters), no data is transferred.
If the ANY pointer (source or destination) is of the data type BOOL, the length specified must
be divisible by 8; otherwise the instruction is not executed.
If the destination block is of data type STRING, the instruction describes the entire string
including the administration information.
Parameters
The following table shows the parameters of the "Fill block" instruction:
Param
eters
Declar
ation
Data
type
Memory area Description
S7-1200 S7-1500
EN Input BOOL I, Q, M, D, L I, Q, M, D, L Enable input
ENO Output BOOL I, Q, M, D, L I, Q, M, D, L Enable output
BVAL Input ANY I, Q, M, D, P I, Q, M, D, P Specification of the memory area
(source area) with whose content
the destination area on the BLK
parameter is filled.
RET_
VAL
Output INT I, Q, M, D, L, P I, Q, M, D, L, P Error information:
If an error occurs during the
execution of the instruction, an error
code is output on the RET_VAL
parameter.
BLK Output ANY I, Q, M, D, P I, Q, M, D, P Specification of the memory area
that is filled with the content of the
source area.
Parameters RET_VAL
The following table shows the meaning of the values of the RET_VAL parameter:
Error code*
(W#16#...)
Explanation
0000 No error
8xyy For more information on errors, refer to "See also".
*The error codes can be displayed as integer or hexadecimal value in the program editor. For additional information on
toggling display formats, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1823
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
Conversion operations
CONVERT: Convert value
Description
The "Convert value" instruction reads the content of the IN parameter and converts it according
to the data types configured in the instruction box. The converted value is provided at output
OUT.
For information on possible conversions, refer to the "Explicit conversion" section at "See also".
Enable output ENO has the signal state "0" if one of the following conditions applies:
Enable input EN has the signal state "0".
Errors, such as an overflow, occur during execution.
For the input IN, an operand of data type BYTE, WORD, DWORD or LWORDis configured,
whose highest value bit is set. A signed integer of data type (SINT, INT DINT, LINT) is
configured in the instruction box for the output OUT, which has the same bit length as the
operand at input IN.
Parameters
The following table shows the parameters of the "Convert value" instruction:
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500
EN Input BOOL I, Q, M, D, L I, Q, M, D, L, T,
C
Enable input
ENO Output BOOL I, Q, M, D, L I, Q, M, D, L Enable output
IN Input Bit strings,
integers,
floating-point
numbers,
CHAR,
BCD16,
BCD32
I, Q, M, D, L, P
or constant
I, Q, M, D, L, P
or constant
Value to be
converted.
OUT Output Bit strings,
integers,
floating-point
numbers,
CHAR,
BCD16,
BCD32
I, Q, M, D, L, P I, Q, M, D, L, P Result of the
conversion
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1824 System Manual, 01/2013,
You can select the data type of the instruction from the "<???>" drop-down list of the instruction
box.
Bit strings (BYTE, WORD, DWORD, LWORD) cannot be selected in the instruction box. If you
have specified an operand of data type BYTE, WORD, or DWORD or LWORD at a parameter
of the instruction, the value of the operand is interpreted as an unsigned integer with the same
bit length. In this case the data type BYTE is interpreted as USINT, WORD as UINT, and
DWORD as UDINT and LWORD as LINT.
Note
For S7-1500 CPU applies: As data types DWORD and LWORD can be selected if REAL or
LREAL were selected as IN data type.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
=
OUT EN
CONV
lNT to
lN ENO
DlNT
"TagOut"
"Tagln"
"Tagln_Value"
"TagOut_Value"
If the operand "TagIn" has the signal state "1", the content of the operand "TagIn_Value" is
read and converted to an integer (16 bits). The result is stored in the operand "TagOut_Value".
The output "TagOut" is set to "1" if the instruction was executed without errors.
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
ROUND: Round numerical value
Description
You can use the "Round numerical value" instruction to round the value at input IN to the
nearest integer. The instruction interprets the value at input IN as a floating-point number and
converts this to the nearest integer. If the input value is exactly between an even and odd
number, then the even number is converted. The result of the instruction is provided at output
OUT and can be queried there.
Enable output ENO has the signal state "0" if one of the following conditions applies:
Enable input EN has the signal state "0".
Errors, such as an overflow, occur during execution.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1825
Parameters
The following table shows the parameters of the "Round numerical value" instruction:
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500
EN Input BOOL I, Q, M, D, L I, Q, M, D, L, T,
C
Enable input
ENO Output BOOL I, Q, M, D, L I, Q, M, D, L Enable output
IN Input Floating-point
numbers
I, Q, M, D, L, P
or constant
I, Q, M, D, L, P
or constant
Input value to
be rounded.
OUT Output Integers,
floating-point
numbers
I, Q, M, D, L, P I, Q, M, D, L, P Result of the
rounding
You can select the data type of the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
ROUND
EN OUT
= lN ENO
REAL
to
DlNT
"TagOut"
"Tagln"
"Tagln_Value"
"TagOut_Value"
The following table shows how the instruction works using specific operand values:
Parameters Operand Value
IN TagIn_Value 1.50000000 -1.50000000
OUT TagOut_Value 2 -2
If the operand "TagIn" has the signal state "1", the "Round numerical value" instruction is
executed. The floating-point number at input "TagIn_Value" is rounded to the nearest even
integer and sent to output "TagOut_Value". If no errors occur during the execution of the
instruction, the output "TagOut" is set.
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1826 System Manual, 01/2013,
CEIL: Generate next higher integer from floating-point number
Description
You can use the "Generate next higher integer from floating-point number" instruction to round
the value at input IN to the next higher integer. The instruction interprets the value at input IN
as a floating-point number and converts this to the next higher integer. The result of the
instruction is provided at output OUT and can be queried there. The output value can be greater
than or equal to the input value.
Enable output ENO has the signal state "0" if one of the following conditions applies:
Enable input EN has the signal state "0".
Errors, such as an overflow, occur during execution.
Parameters
The following table shows the parameters of the instruction "Generate next higher integer from
floating-point number":
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500
EN Input BOOL I, Q, M, D, L I, Q, M, D, L, T,
C
Enable input
ENO Output BOOL I, Q, M, D, L I, Q, M, D, L Enable output
IN Input Floating-point
numbers
I, Q, M, D, L, P
or constant
I, Q, M, D, L, P
or constant
Input value as
floating-point
number
OUT Output Integers,
floating-point
numbers
I, Q, M, D, L, P I, Q, M, D, L, P Result with the
next higher
integer
You can select the data type of the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
CElL
EN OUT
= lN ENO
REAL
to
DlNT
"TagOut"
"Tagln"
"Tagln_Value"
"TagOut_Value"
The following table shows how the instruction works using specific operand values:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1827
Parameters Operand Value
IN TagIn_Value 0.50000000 -0.50000000
OUT TagOut_Value 1 0
If the operand "TagIn" has the signal state "1", the instruction "Generate next higher integer
from floating-point number" is executed. The floating-point number at input "TagIn_Value" is
rounded to the next higher integer and sent to output "TagOut_Value". If no errors occur during
the execution of the instruction, the output "TagOut" is set.
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
FLOOR: Generate next lower integer from floating-point number
Description
You can use the "Generate next lower integer from floating-point number" instruction to round
the value at input IN to the next lower integer. The instruction interprets the value at input IN
as a floating-point number and converts this to the next lower integer. The result of the
instruction is provided at output OUT and can be queried there. The output value can be less
than or equal to the input value.
Enable output ENO has the signal state "0" if one of the following conditions applies:
Enable input EN has the signal state "0".
Errors, such as an overflow, occur during execution.
Parameters
The following table shows the parameters of the instruction "Generate next lower integer from
floating-point number":
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500
EN Input BOOL I, Q, M, D, L I, Q, M, D, L, T,
C
Enable input
ENO Output BOOL I, Q, M, D, L I, Q, M, D, L Enable output
IN Input Floating-point
numbers
I, Q, M, D, L, P
or constant
I, Q, M, D, L, P
or constant
Input value as
floating-point
number
OUT Output Integers,
floating-point
numbers
I, Q, M, D, L, P I, Q, M, D, L, P Result with the
next lower
integer
You can select the data type of the instruction from the "<???>" drop-down list of the instruction
box.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1828 System Manual, 01/2013,
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
FLOOR
EN OUT
= lN ENO
REAL
to
DlNT
"TagOut"
"Tagln"
"Tagln_Value"
"TagOut_Value"
The following table shows how the instruction works using specific operand values:
Parameters Operand Value
IN TagIn_Value 0.50000000 -0.50000000
OUT TagOut_Value 0 -1
If the operand "TagIn" has the signal state "1", the instruction "Generate next lower integer
from floating-point number" is executed. The floating-point number at input "TagIn_Value" is
rounded to the next lower integer and displayed at output "TagOut_Value". If no errors occur
during the execution of the instruction, the output "TagOut" is set.
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
TRUNC: Truncate numerical value
Description
You can use the "Truncate numerical value" instruction to form an integer from the value at
input IN. The value at input IN is interpreted as a floating-point number. The instruction selects
only the integer part of the floating-point number and sends this to output OUT without decimal
places.
Enable output ENO has the signal state "0" if one of the following conditions applies:
Enable input EN has the signal state "0".
Errors, such as an overflow, occur during execution.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1829
Parameters
The following table shows the parameters of the instruction "Truncate numerical value":
Parameters Declaration Data type Memory area Description
EN Input BOOL I, Q, M, D, L Enable input
ENO Output BOOL I, Q, M, D, L Enable output
IN Input Floating-point
numbers
I, Q, M, D, L or
constant
Input value as
floating-point
number
OUT Output Integers, floating-
point numbers
I, Q, M, D, L Result with integer
part of the floating-
point number
You can select the data type of the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
TRUNC
EN OUT
= lN ENO
REAL
to
DlNT
"TagOut"
"Tagln"
"Tagln_Value"
"TagOut_Value"
The following table shows how the instruction works using specific operand values:
Parameters Operand Value
IN TagIn_Value 1.50000000 -1.50000000
OUT TagOut_Value 1 -1
If the operand "TagIn" has the signal state "1", the "Truncate numerical value" instruction is
executed. The integer part of the floating-point number at input "TagIn_Value" is converted to
an integer and sent to output "TagOut_Value". If no errors occur during the execution of the
instruction, the output "TagOut" is set.
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1830 System Manual, 01/2013,
SCALE_X: Scale
Description
You can use the "Scale" instruction to scale the value at the VALUE input by mapping it to a
specified value range. When the instruction "Scale" is executed, the floating-point value at
input VALUE is scaled to the value range, which is defined by the parameters MIN and MAX.
The result of the scaling is an integer, which is stored at output OUT.
The following figure shows an example of how values can be scaled:
MlN
MAX
1.0 0.0
OUT
VALUE
The "Scale" instruction works with the following equation:
OUT = [VALUE (MAX MIN)] + MIN
Enable output ENO has the signal state "0" if one of the following conditions applies:
Enable input EN has the signal state "0".
The value at input MIN is greater than or equal to the value at input MAX.
The value of a specified floating-point number is outside the range of the normalized
numbers according to IEEE-754.
An overflow occurs.
The value at input VALUE is NaN (Not a number = result of an invalid arithmetic operation).
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1831
Parameters
The following table shows the parameters of the "Scale" instruction:
Parameters Declaration Data type Memory area Description
EN Input BOOL I, Q, M, D, L Enable input
ENO Output BOOL I, Q, M, D, L Enable output
MIN Input Integers, floating-
point numbers
I, Q, M, D, L or
constant
Low limit of the
value range
VALUE Input Floating-point
numbers
I, Q, M, D, L or
constant
Value to be scaled.
MAX Input Integers, floating-
point numbers
I, Q, M, D, L or
constant
High limit of the
value range
OUT Output Integers, floating-
point numbers
I, Q, M, D, L Result of scaling
You can select the data type of the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
S
SCALE_X
EN
ENO
MlN
OUT
VALUE
MAX
REAL
to
DlNT
"TagOut"
"Tagln"
"Tag_MlN"
"Tag_Value"
"Tag_Result"
"Tag_MAX"
The following table shows how the instruction works using specific operand values:
Parameters Operand Value
MIN Tag_MIN 10
VALUE Tag_Value 0.5
MAX Tag_MAX 30
OUT Tag_Result 20
If the operand "TagIn" has the signal state "1", the "Scale" instruction is executed. The value
at input "Tag_Value" is scaled to the range of values defined by the values at inputs "Tag_MIN"
and "Tag_MAX". The result is stored at output "Tag_Result". If the instruction is executed
without errors, the ENO enable output has the signal state "1" and the "TagOut" output is set.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1832 System Manual, 01/2013,
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
NORM_X: Normalize (Page 1833)
NORM_X: Normalize
Description
You can use the instruction "Normalize" to normalize the value of the tag at the VALUE input
by mapping it to a linear scale. You can use the parameters MIN and MAX to define the limits
of a value range that is applied to the scale. Depending on the location of the normalized value
in this value range, the result at output OUT is calculated and stored as a floating-point number.
If the value to be normalized is equal to the value at input MIN, output OUT returns the value
"0.0". If the value to be normalized is equal to the value at input MAX, output OUT returns the
value "1.0".
The following figure shows an example of how values can be normalized:
MlN MAX
1.0
0.0
OUT
VALUE
The "Normalize" instruction works with the following equation:
OUT = (VALUE MIN) / (MAX MIN)
Enable output ENO has the signal state "0" if one of the following conditions applies:
Enable input EN has the signal state "0".
The value at input MIN is greater than or equal to the value at input MAX.
The value of a specified floating-point number is outside the range of the normalized
numbers according to IEEE-754.
The value at input VALUE is NaN (result of an invalid arithmetic operation).
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1833
Parameters
The following table shows the parameters of the instruction "Normalize":
Parameters Declaration Data type Memory area Description
EN Input BOOL I, Q, M, D, L Enable input
ENO Output BOOL I, Q, M, D, L Enable output
MIN Input Integers, floating-
point numbers
I, Q, M, D, L or
constant
Low limit of the
value range
VALUE Input Integers, floating-
point numbers
I, Q, M, D, L or
constant
Value to be
normalized.
MAX Input Integers, floating-
point numbers
I, Q, M, D, L or
constant
High limit of the
value range
OUT Output Floating-point
numbers
I, Q, M, D, L Result of the
normalization
You can select the data type of the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
S
NORM_X
EN
ENO
MlN
OUT
VALUE
MAX
REAL to DlNT
"TagOut"
"Tagln"
"Tag_MlN"
"Tag_Value"
"Tag_Result"
"Tag_MAX"
The following table shows how the instruction works using specific operand values:
Parameters Operand Value
MIN Tag_MIN 10
VALUE Tag_Value 20
MAX Tag_MAX 30
OUT Tag_Result 0.5
If the operand "TagIn" has the signal state "1", the "Normalize" instruction is executed. The
value at input "Tag_Value" is assigned to the range of values defined by the values at inputs
"Tag_MIN" and "Tag_MAX". The tag value at input "Tag_Value" is normalized corresponding
to the defined value range. The result is stored as a floating-point number at output
"Tag_Result". If the instruction is executed without errors, the ENO enable output has the signal
state "1" and the "TagOut" output is set.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1834 System Manual, 01/2013,
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
SCALE_X: Scale (Page 1831)
SCALE: Scale
Description
Use the Scale instruction to convert the integer at the IN parameter into a floating-point number,
which can be scaled in physical units between a low limit value and a high limit value. You use
the LO_LIM and HI_LIM parameters to specify the low limit and high limit of the value range
to which the input value is scaled. The result of the instruction is output at the OUT parameter.
The "Scale" instruction works with the following equation:
OUT = [((FLOAT (IN) K1)/(K2K1)) (HI_LIMLO_LIM)] + LO_LIM
The values of the constants "K1" and "K2" are determined by the signal state on the BIPOLAR
parameter. The following signal states are possible on the BIPOLAR parameter:
Signal state "1": It is assumed that the value at the IN parameter is bipolar and in a value
range between -27648 and 27648. In this case the "K1" constant has the value "-27648.0"
and the "K2" constant the value "+27648.0".
Signal state "0": It is assumed that the value at the IN parameter is unipolar and in a value
range between 0 and 27648. In this case the "K1" constant has the value "0.0" and the "K2"
constant the value "+27648.0".
When the value at the IN parameter is greater than the value of the constant "K2", the result
of the instruction is set to the value of the high limit (HI_LIM) and an error is output.
When the value at the IN parameter is less than the value of the constant "K1", the result of
the instruction is set to the value of the low limit value (LO_LIM) and an error is output.
When the indicated low limit value is greater than the high limit value (LO_LIM > HI_LIM), the
result is scaled in reverse proportion to the input value.
Parameters
The following table shows the parameters of the "Scale" instruction:
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500
EN Input BOOL I, Q, M, D, L I, Q, M, D, L, T,
C
Enable input
ENO Output BOOL I, Q, M, D, L I, Q, M, D, L Enable output
IN Input INT I, Q, M, D, L, P
or constant
I, Q, M, D, L, P
or constant
Input value to
be scaled.
HI_LIM Input REAL I, Q, M, D, L, P
or constant
I, Q, M, D, L, P
or constant
High limit
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1835
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500
LO_LIM Input REAL I, Q, M, D, L, P
or constant
I, Q, M, D, L, P
or constant
Low limit
BIPOLAR Input BOOL I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
Indicates if the
value at IN
parameter is to
be interpreted
as bipolar or
unipolar. The
parameter can
assume the
following
values:
1: Bipolar
0: Unipolar
OUT Output REAL I, Q, M, D, L, P I, Q, M, D, L, P Result of the
instruction
RET_VAL Output WORD I, Q, M, D, L, P I, Q, M, D, L, P Error
information
Parameters RET_VAL
The following table shows the meaning of the values of the RET_VAL parameter:
Error code*
(W#16#...)
Explanation
0000 No error
0008 The value of the IN parameter is greater than the value of the "K2" constant or less than the value of the
"K1" constant.
8xyy For more information on errors, refer to "See also".
*The error codes can be displayed as integer or hexadecimal value in the program editor. For additional information on
toggling display formats, refer to "See also".
Example
The following example shows how the instruction works:
SCALE
EN
ENO
lN
RET_VAL
OUT
Hl_LlM
LO_LlM
BlPOLAR
"Tag_lnputValue"
"Tag_OutputValue"
"Tag_ErrorCode" "Tag_HighLimit"
"Tag_LowLimit"
"Tagln"
"TagOut"
"Tag_Bipolar"
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1836 System Manual, 01/2013,
The following table shows how the instruction works using specific operand values:
Parameters Operand Value
IN Tag_InputValue 22
HI_LIM Tag_HighLimit 100.0
LO_LIM Tag_LowLimit 0.0
BIPOLAR Tag_Bipolar 1
OUT Tag_OutputValue 50.03978588
RET_VAL Tag_ErrorCode W#16#0000
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
UNSCALE: Unscale
Description
The "Unscale" instruction unscales the floating-point number at the IN parameter into physical
units between a low limit value and a high limit and converts them into integers. You use the
LO_LIM and HI_LIM parameters to specify the low limit and high limit of the value range to
which the input value is unscaled. The result of the instruction is output at the OUT parameter.
The "Unscale" instruction works with the following equation:
OUT = [ ((INLO_LIM)/(HI_LIMLO_LIM)) (K2K1) ] + K1
The values of the constants "K1" and "K2" are determined by the signal state on the BIPOLAR
parameter. The following signal states are possible on the BIPOLAR parameter:
Signal state "1": It is assumed that the value at the IN parameter is bipolar and in a value
range between -27648 and 27648. In this case the "K1" constant has the value "-27648.0"
and the "K2" constant the value "+27648.0".
Signal state "0": It is assumed that the value at the IN parameter is unipolar and in a value
range between 0 and 27648. In this case the "K1" constant has the value "0.0" and the "K2"
constant the value "+27648.0".
When the value at the IN parameter is greater than the value of the constant "HI_LIM", the
result of the instruction is set to the value of the constant (K2) and an error is output.
When the value at the IN parameter is less than the value of the constant of the low limit
(LO_LIM), the result of the instruction is set to the value of the constant (K1) and an error is
output.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1837
Parameters
The following table shows the parameters of the "Unscale" instruction:
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500
EN Input BOOL I, Q, M, D, L I, Q, M, D, L, T,
C
Enable input
ENO Input BOOL I, Q, M, D, L I, Q, M, D, L Enable output
IN Input REAL I, Q, M, D, L, P
or constant
I, Q, M, D, L, P
or constant
Input value to
be unscaled to
an integer
value.
HI_LIM Input REAL I, Q, M, D, L, P
or constant
I, Q, M, D, L, P
or constant
High limit
LO_LIM Input REAL I, Q, M, D, L, P
or constant
I, Q, M, D, L, P
or constant
Low limit
BIPOLAR Input BOOL I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
Indicates if the
value at the IN
parameter is to
be interpreted
as bipolar or
unipolar. The
parameter can
assume the
following
values:
1: Bipolar
0: Unipolar
OUT Output INT I, Q, M, D, L, P I, Q, M, D, L, P Result of the
instruction
RET_VAL Output WORD I, Q, M, D, L, P I, Q, M, D, L, P Error
information
Parameters RET_VAL
The following table shows the meaning of the values of the RET_VAL parameter:
Error code*
(W#16#...)
Explanation
0000 No error
0008 The value of the IN parameter is greater than the value of the high limit (HI_LIM) or less than the value
of the low limit (LO_LIM).
8xyy For more information on errors, refer to "See also".
*The error codes can be displayed as integer or hexadecimal value in the program editor. For additional information on
toggling display formats, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1838 System Manual, 01/2013,
Example
The following example shows how the instruction works:
UNSCALE
EN
ENO
lN
RET_VAL
OUT
Hl_LlM
LO_LlM
BlPOLAR
"Tag_lnputValue"
"Tag_OutputValue"
"Tag_ErrorCode" "Tag_HighLimit"
"Tag_LowLimit"
"Tagln"
"TagOut"
"Tag_Bipolar"
The following table shows how the instruction works using specific operand values:
Parameters Operand Value
IN Tag_InputValue 50.03978588
HI_LIM Tag_HighLimit 100.0
LO_LIM Tag_LowLimit 0.0
BIPOLAR Tag_Bipolar 1
OUT Tag_OutputValue 22
RET_VAL Tag_ErrorCode W#16#0000
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
Program control operations
JMP: Jump if RLO = 1
Description
You can use the "Jump if RLO = 1" instruction to interrupt the linear execution of the program
and resume it in another network. The target network must be identified by a jump label
(LABEL). The jump label description is entered in the placeholder above the instruction box.
The specified jump label must be in the same block in which the instruction is executed. The
name you specify can only occur once in the block. Only one jumping coil can occur in a
network.
If the result of logic operation (RLO) at the input of the instruction is "1", the jump to the network
identified by the jump label is executed. The jump direction can be towards higher or lower
network numbers.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1839
If the condition at the input of the instruction is not fulfilled (RLO = 0), execution of the program
continues in the next network.
Example
The following example shows how the instruction works:
Network 1
Network 2
Network 3
JMP
CAS1
R
CAS1
R
"TagOut_2"
"TagOut_3"
"Tagln_1"
"Tagln_2"
"Tagln_3"
If the operand "TagIn_1" has the signal state "1", the instruction "Jump if RLO = 1" is executed.
The linear execution of the program is interrupted and continues in Network 3, which is
identified by the jump label CAS1. If input "TagIn_3" has the signal state "1", output "TagOut_3"
is reset.
See also
Overview of the valid data types (Page 899)
JMPN: Jump if RLO = 0
Description
You can use the instruction "Jump if RLO = 0" to interrupt the linear execution of the program
and resume it in another network, when the result of logic operation at the input of the
instruction is "0". The target network must be identified by a jump label (LABEL). The jump
label description is entered in the placeholder above the instruction box.
The specified jump label must be in the same block in which the instruction is executed. The
name you specify can only occur once in the block. Only one jumping coil can occur in a
network.
If the result of logic operation (RLO) at the input of the instruction is "0", the jump to the network
identified by the jump label is executed. The jump direction can be towards higher or lower
network numbers.
If the result of the logic operation RLO at the input of the instruction is "1", execution of the
program continues in the next network.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1840 System Manual, 01/2013,
Example
The following example shows how the instruction works:
Network 1
Network 2
Network 3
JMPN
CAS1
R
CAS1
R
"TagOut_2"
"TagOut_3"
"Tagln_1"
"Tagln_2"
"Tagln_3"
If the operand "TagIn_1" has the signal state "0", the instruction "Jump if RLO = 0" is executed.
The linear execution of the program is interrupted and continues in Network 3, which is
identified by the jump label CAS1. If input "TagIn_3" has the signal state "1", output "TagOut_3"
is reset.
See also
Overview of the valid data types (Page 899)
LABEL: Jump label
Description
The jump label identifies a destination network in which the execution of the program can be
resumed after the execution of a jump instruction.
The jump label and the instruction in which the jump label is specified must be located in the
same block. The name of a jump label can only be assigned once in a block. You can declare
up to 32 jump labels when you use a CPU S7-1200 and a maximum of 256 jump labels when
you use a CPU S7-1500.
Only one jump label can be placed in a network. Each jump label can jump to several locations.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1841
Example
The following example shows how the instruction works:
Network 1
Network 2
Network 3
JMP
CAS1
R
CAS1
R
"TagOut_2"
"TagOut_3"
"Tagln_1"
"Tagln_2"
"Tagln_3"
If the operand "TagIn_1" has the signal state "1", the instruction "Jump if RLO = 1" is executed.
The linear execution of the program is interrupted and continues in Network 3, which is
identified by the jump label CAS1. If input "TagIn_3" has the signal state "1", output "TagOut_3"
is reset.
See also
Overview of the valid data types (Page 899)
Adding additional inputs and outputs to FBD elements (Page 1144)
Removing instruction inputs and outputs (Page 1145)
JMP_LIST: Define jump list
Description
The instruction "Define jump list" is used to define several conditional jumps and to resume
the program execution in a defined network depending on the value of the parameter K.
You define the jumps with jump labels (LABEL), which you specify at the outputs of the
instruction box. In its initial state the instruction box contains at least 2 outputs (DEST0 and
DEST1). The number of outputs can be extended. You can declare up to 32 outputs when you
use a CPU S7-1200 and a maximum of 256 outputs when you use a CPU S7-1500.
The numbering of the outputs begins with the value "0" and is continued in ascending order
with each new output. Only jump labels can be specified at the outputs of the instruction. It is
not permitted to specify instructions or operands.
You use the value of the parameter K to specify the number of the output and, accordingly,
the jump label at which the program execution is continued. If the value at the parameter K is
greater than the number of available outputs, the linear execution of the program is not
interrupted but instead continued in the next network.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1842 System Manual, 01/2013,
Parameters
The following table shows the parameters of the "Define jump list" instruction:
Parameter Declaration Data type Memory area Description
EN Input BOOL I, Q, M, L, D Enable input
K Input UINT I, Q, M, L, D or
constant
Specifies the
number of the
output and thus
the jump that is
executed.
DEST0 - - - First jump label
DEST1 - - - Second jump label
DESTn - - - Optional jump
labels
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
DEST0
EN
K
JMP_LlST
DEST1
DEST2
LABEL0
LABEL1
LABEL2
"Tag_Value"
"Tag_lnput"
The following table shows how the instruction works using specific operand values:
Parameters Operand/Jump label Value
K Tag_Value 1
DEST0 LABEL0 Jump in the network that is
identified with the jump label
"LABEL0".
DEST1 LABEL1 Jump in the network that is
identified with the jump label
"LABEL1".
DEST2 LABEL2 Jump in the network that is
identified with the jump label
"LABEL2".
If the operand "Tag_Input" has the signal state "1", the instruction "Define jump list" is executed.
The execution of the program is continued according to the value of the operand "Tag_Value"
in the network that is identified with the jump label "LABEL1".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1843
See also
Overview of the valid data types (Page 899)
Adding additional inputs and outputs to FBD elements (Page 1144)
Removing instruction inputs and outputs (Page 1145)
SWITCH: Jump distributor
Description
You can use the "Jump distributor" instruction to define multiple program jumps to be executed
depending on the result of one or more comparison instructions.
At the parameter K, you specify the value to be compared. This value is compared with the
values that the individual inputs return. You select the type of comparison for each input. The
availability of various comparison instructions depends on the data type of the instruction.
The following table shows the comparison instructions that are available depending on the
selected data type:
Data type Instruction Syntax
S7-1200 S7-1500
Bit strings Bit strings Equal ==
Not equal <>
Integers, floating-point
numbers, TIME,
DATE, TOD
Integers, floating-point
numbers, TIME,
LTIME, DATE, TOD,
LTOD, LDT
Equal ==
Not equal <>
Greater or equal >=
Less or equal <=
Greater than >
Less than <
You can select the data type of the instruction from the "<???>" drop-down list of the instruction
box. If you select a comparison instruction and the data type of the instruction is not yet defined,
then the "<???>" drop-down list will only list those data types that are permitted for the selected
comparison instruction.
The execution of the instruction begins with the first comparison and is executed until a
comparison condition is fulfilled. When a comparison condition is fulfilled the subsequent
comparison conditions are not considered. If none of the specified comparison conditions are
fulfilled, the jump is executed at output ELSE. If not jump label is defined at output ELSE, the
linear execution of the program is not interrupted but instead continued in the next network.
In its initial state the instruction box contains at least 2 outputs (DEST0 and DEST1). The
number of outputs can be extended. The numbering of the outputs begins with the value "0"
and is continued in ascending order with each new output. Specify jump labels (LABEL) at the
outputs of the instruction. It is not permitted to specify instructions or operands at the outputs
of the instruction.
An input is automatically inserted to each additional output. The jump programmed at an output
is executed when the comparison condition of the corresponding is fulfilled.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1844 System Manual, 01/2013,
Parameters
The following table shows the parameters of the instruction "Jump distributor":
Parameters Declarat
ion
Data type Memory area Description
S7-1200 S7-1500
EN Input BOOL BOOL I, Q, M, D, L Enable input
K Input UINT UINT I, Q, M, D, L or
constant
Specifies the value to
be compared.
<Comparison
values>
Input Bit strings,
integers,
floating-
point
numbers,
TIME,
DATE,
TOD
Bit strings,
integers,
floating-
point
numbers,
TIME,
LTIME,
DATE,
TOD,
LTOD, LDT
I, Q, M, D, L or
constant
Input values with
which the value of the
parameter K is
compared.
DEST0 - - - - First jump label
DEST1 - - - - Second jump label
DEST(n) - - - - Optional jump labels
(n = 2 to 99)
ELSE - - - - Program jump which
is executed if none of
the comparison
conditions are fulfilled.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
DEST0
UlNT
K
EN
==
>
<
SWlTCH
DEST1
DEST2
LABEL0
LABEL1
LABEL2
LABEL3
"Tag_Value"
"Tag_Value_1"
"Tag_Value_2"
"Tag_Value_3"
ELSE
"Tag_lnput"
The following table shows how the instruction works using specific operand values:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1845
Parameters Operand/Jump label Value
K Tag_Value 23
== Tag_Value_1 20
> Tag_Value_2 21
< Tag_Value_3 19
DEST0 LABEL0 Jump to jump label "LABEL0", if
the value of parameter K is equal
to 20.
DEST1 LABEL1 Jump to jump label "LABEL1", if
the value of parameter K is
greater than 21.
DEST2 LABEL2 Jump to jump label "LABEL2", if
the value of parameter K is less
than 19.
ELSE LABEL 3 Jump to jump label "LABEL3", if
none of the comparison
conditions are fulfilled.
If the operand "Tag_Input" changes to signal state "1", the instruction "Jump distributor" is
executed. The execution of the program is continued in the network that is identified with the
jump label "LABEL1".
See also
Overview of the valid data types (Page 899)
Adding additional inputs and outputs to FBD elements (Page 1144)
Removing instruction inputs and outputs (Page 1145)
RET: Return
Description
You can use the instruction "Return" to stop the execution of a block. This results in three
types, in which the block processing can be completed:
Without call of the "Return" instruction
The block is exited after the execution of the last network. The ENO of the call function is
set to the signal state "1".
Call of the "Return" instruction with logic operation (see example)
If the left connector has the signal state "1", then the block is exited. The ENO of the function
call corresponds to the operand.
Call of the "Return" instruction without logic operation
The block is exited. The ENO of the function call corresponds to the operand.
Note
Only one jumping coil may be used in a network ("Return", "Jump if RLO = 1", "Jump if
RLO = 0").
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1846 System Manual, 01/2013,
If the result of logic operation (RLO) at the input of the instruction "Return" is "1", the execution
of the program is terminated in the currently called block and continued after the call function
in the calling block (for example, in the calling OB). The status (ENO) of the call function is
determined by the parameter of the instruction. This can assume the following values:
RLO
TRUE/FALSE
<Operand>
To set the parameter values, double-click the instruction and select the corresponding value
in the drop-down list.
The following table shows the status of the call function when the instruction "Return" is
programmed in a network within the called block:
RLO Parameter value ENO of the call function
1 RLO 1
TRUE 1
FALSE 0
<Operand> <Operand>
0 RLO In this case, the execution of the program
continues in the next network of the called
block.
TRUE
FALSE
<Operand>
If an OB is completed, another block is selected by the priority class system and started or re-
executed.
If the OB program cycle was completed, it is restarted.
If an OB, which interrupted another block (e.g. an Alarm OB), is completed, then the
interrupted block (e.g. OB program cycle) is executed.
Parameters
The following table shows the parameters of the instruction "Return":
Parameters Declaration Data type Memory area Description
Status of the
calling function
when RLO = 1:
RLO - - - Is set to the signal
state of the RLO.
TRUE - - - 1
FALSE - - - 0
<Operand> Input BOOL I, Q, M, D, L Signal state of the
specified operand
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1847
Example
The following example shows how the instruction works:
RET
>=1
FALSE
"Tagln_1"
"Tagln_2"
If the operands "TagIn_1" or "TagIn_2" have signal state "1", the instruction "Return" is
executed. Program execution in the called block is terminated and continues in the calling
block. The enable output ENO of the call function is reset to signal state "0".
See also
Overview of the valid data types (Page 899)
Runtime control
RE_TRIGR: Restart cycle monitoring time
Description
You can use the "Restart cycle monitoring time" instruction to restart the cycle time monitoring
of the CPU. The cycle monitoring time then starts over for the duration you have set in the
CPU configuration.
The instruction "Restart cycle monitoring time" can be called regardless of the priority in all
blocks.
If the instruction is called in a block with a higher priority, such as a hardware interrupt, a
diagnostics interrupt or a cyclic interrupt, the instruction is not executed and the ENO enable
output is set to signal state "0".
The instruction "Restart cycle monitoring time" can be called a maximum of 10 times in a
program cycle.
Note
Make sure that you do not create an infinite loop in the cyclical program execution, i.e. in
OB1, when you use the "Restart cycle monitoring time" instruction. Otherwise, the CPU will
not reach the cycle check point. As a result, it may not be possible to execute certain CPU
functions (e.g. process image update).
Parameters
The instruction "Restart cycle monitoring time" has no parameters.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1848 System Manual, 01/2013,
See also
Overview of the valid data types (Page 899)
Basics of error handling (Page 1193)
Principles of local error handling (Page 1195)
Error output priorities (Page 1196)
Enabling local error handling for a block (Page 1197)
STP: Exit program
Description
The instruction "Exit program" instruction is used to set the CPU to STOP mode and therefore
to terminate the execution of the program. The effects of changing from RUN to STOP depend
on the CPU configuration.
When the (RLO) at the input of the instruction is "1", the CPU changes to STOP mode and the
execution of the program is terminated. The signal state at the output of the instruction is not
evaluated.
If the RLO at the input of the instruction is "0", then the instruction will not be executed.
Parameters
The instruction "Exit program" has no parameters.
See also
Overview of the valid data types (Page 899)
GetError: Get error locally
Description
The "Get error locally" instruction is used to query the occurrence of errors within a block. If
the system signals errors during block execution, detailed information about the first error that
occurred is saved in the operand at output ERROR.
Only operands of the system data type "ErrorStruct" can be specified at output ERROR. The
system data type "ErrorStruct" specifies the exact structure in which the information about the
error is stored. Using additional instructions, you can evaluate this structure and program an
appropriate response. When the first error has been eliminated, the instruction outputs
information about the next error that occurred.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1849
Parameters
The following table shows the parameters of the "Get error locally" instruction:
Parameters Declaration Data type Memory area Description
ERROR Output ErrorStruct D, L Error information
Data type "ErrorStuct"
The following table shows the structure of the data type ErrorStruct:
Structure components Data type Description
ERROR_ID WORD Error ID
FLAGS BYTE Shows if an error occurred during a block call.
16#01: Error during a block call.
16#00: No error during a block call.
REACTION BYTE Default reaction:
0: Ignore (write error),
1: Continue with substitute value "0" (read error),
2: Skip instruction (system error)
CODE_ADDRESS CREF Information on address and type of block
BLOCK_TYPE BYTE Type of block where the error occurred:
1: OB
2: FC
3: FB
CB_NUMBER UINT Number of the code block
OFFSET UDINT Reference to the internal memory
MODE BYTE Access mode: Depending on the type of access, the
following information can be output:
Mode (A) (B) (C) (D) (E)
0
1 Offset
2 Area
3 Location Scope Numb
er
4 Area Offset
5 Area DB no. Offset
6 PtrNo./
Acc
Area DB no. Offset
7 PtrNo./
Acc
Slot
No. /
Scope
Area DB no. Offset
OPERAND_NUMBER UINT Operand number of the machine command
POINTER_NUMBER_LOCATION UINT (A) Internal pointer
SLOT_NUMBER_SCOPE UINT (B) Storage area in internal memory
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1850 System Manual, 01/2013,
Structure components Data type Description
DATA_ADDRESS NREF Information about the address of an operand
AREA BYTE (C) Memory area:
L: 16#40 4E, 86, 87, 8E, 8F, C0 CE
I: 16#81
Q: 16#82
M: 16#83
DB: 16#84, 85, 8A, 8B
DB_NUMBER UINT (D) Number of the data block
OFFSET UDINT (E) Relative address of the operand
Structure components "ERROR_ID"
The following table shows the values that can be output on the structure components
"ERROR_ID":
ID*
(hexadecimal)
ID*
(decimal)
Description
0 0 No error
2503 9475 Invalid pointer
2505 9477 Calling the instruction "Stop" (SFC46) in the user program
2520 9504 Invalid STRING
2522 9506 Read errors: Operand outside the valid range
2523 9507 Write errors: Operand outside the valid range
2524 9508 Read errors: Invalid operand
2525 9509 Write errors: Invalid operand
2528 9512 Read errors: Data alignment
2529 9513 Write errors: Data alignment
252C 9516 Invalid pointer
2530 9520 Write errors: Data block
2533 9523 Invalid pointer used
2534 9524 Block number error FC
2535 9525 Block number error FB
2538 9528 Access error: DB does not exist
2539 9529 Access error: Wrong DB used
253A 9530 Global data block does not exist
253C 9532 Faulty information or the function does not exist
253D 9533 System function does not exist
253E 9534 Faulty information or the function block does not exist
253F 9535 System block does not exist
2550 9552 Access error: DB does not exist
2551 9553 Access error: Wrong DB used
2575 9589 Error in the program nesting depth
2576 9590 Error in the local data distribution
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1851
ID*
(hexadecimal)
ID*
(decimal)
Description
2942 10562 Read errors: Input
2943 10563 Write errors: Output
*The error codes can be displayed as integer or hexadecimal value in the program editor. For additional
information on toggling display formats, refer to "See also".
The enable output ENO of the instruction "Get error locally" instruction is set only if the enable
input EN returns signal state "1" and error information is present. If one of these conditions
does not apply, the remaining program execution is not affected by the instruction "Get error
locally".
The instruction "Get error locally" can also be used to forward an alarm about the error status
to the calling block. To do this, the instruction must be positioned in the last network of the
called block.
Note
The instruction "Get error locally" enables local error handling within a block. When "Get error
locally" is inserted in the program code of a block, any predefined system responses are
ignored if an error occurs.
Example
The following example shows how the instruction works:
&
=
#index
"Tag_lnput"
=
#out
&
R R
= =
#out
#error
GET_ERROR
ERROR
ENO
EN
CONV
ENO
EN
lN
OUT
BYTE UlNT to
#error.
reaction
#err_reaction
#conv
#err_reaction
"substitute"
#conv
"OK"
UlNT
If an error occurs, the instruction "Get error locally" returns the error information to the locally
created structure "#error" at output ERROR. The error information is converted and evaluated
with the comparison instruction "Equal to". Information about the type of error is the first
comparison value assigned to the instruction. For the second comparison value, a value of "1"
is specified in the operand "substitute". If the error is a read error, the condition of the
comparison instruction is satisfied. In this case the outputs "#out" and "OK" are reset.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1852 System Manual, 01/2013,
See also
Overview of the valid data types (Page 899)
Basics of error handling (Page 1193)
Principles of local error handling (Page 1195)
Error output priorities (Page 1196)
Enabling local error handling for a block (Page 1197)
GetErrorID: Get error ID locally
Description
The "Get error ID locally" instruction is used to query the occurrence of errors within a block.
If the system signals errors during block execution, the error ID of the first error that occurred
is saved in the tag at output ID. Only tags of the WORD data type can be specified at the ID
output. When the first error has been eliminated, the instruction outputs the error ID of the next
error that occurred.
The output of the instruction "Get error ID locally" is only set if the input of the instruction returns
signal state "1" and error information is present. If one of these conditions does not apply, the
remaining program execution is not affected by the instruction "Get error ID locally".
The instruction "Get error ID locally" can also be used to forward an alarm about the error
status to the calling block. To do this, the instruction must be positioned in the last network of
the called block.
Note
The instruction "Get error ID locally" enables local error handling within a block. When the
instruction "Get error ID locally" is inserted in the program code of a block, any predefined
system responses are ignored if an error occurs.
Parameters
The following table shows the parameters of the instruction "Get error ID locally":
Parameters Declaration Data type Memory area Description
ID Output WORD I, Q, M, D, L Error ID
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1853
Parameters ID
The following table shows the values that can be output at the parameter ID:
ID*
(hexadecimal)
ID*
(decimal)
Description
0 0 No error
2503 9475 Invalid pointer
2505 9477 Calling the instruction "Stop" (SFC46) in the user program
2520 9504 Invalid STRING
2522 9506 Read errors: Operand outside the valid range
2523 9507 Write errors: Operand outside the valid range
2524 9508 Read errors: Invalid operand
2525 9509 Write errors: Invalid operand
2528 9512 Read errors: Data alignment
2529 9513 Write errors: Data alignment
252C 9516 Invalid pointer
2530 9520 Write errors: Data block
2533 9523 Invalid pointer used
2534 9524 Block number error FC
2535 9525 Block number error FB
2538 9528 Access error: DB does not exist
2539 9529 Access error: Wrong DB used
253A 9530 Global data block does not exist
253C 9532 Faulty information or the function does not exist
253D 9533 System function does not exist
253E 9534 Faulty information or the function block does not exist
253F 9535 System block does not exist
2550 9552 Access error: DB does not exist
2551 9553 Access error: Wrong DB used
2575 9589 Error in the program nesting depth
2576 9590 Error in the local data distribution
2942 10562 Read errors: Input
2943 10563 Write errors: Output
*The error codes can be displayed as integer or hexadecimal value in the program editor. For additional
information on toggling display formats, refer to "See also".
See also
Overview of the valid data types (Page 899)
Basics of error handling (Page 1193)
Principles of local error handling (Page 1195)
Error output priorities (Page 1196)
Enabling local error handling for a block (Page 1197)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1854 System Manual, 01/2013,
INIT_RD: Initialize all retain data
Description
The "Initialize all retain data" instruction is used to reset the retentive data of all data blocks,
bit memories and SIMATIC Timers and counters at the same time. The instruction can only
be executed within a startup OB because the execution exceeds the program cycle duration.
Parameters
The following table shows the parameters of the "Initialize all retain data" instruction:
Parameters Declaration Data type Memory area Description
EN Input BOOL I, Q, M, D, L, T, C Enable input
ENO Output BOOL I, Q, M, D, L Enable output
REQ Input BOOL I, Q, M, D, L, T, C
or constant
If the input "REQ"
has the signal
state "1", all
retentive data are
reset.
RET_VAL Output INT I, Q, M, D, L Error information:
If an error occurs
during the
execution of the
instruction, an
error code is
output on the
RET_VAL
parameter.
For additional information on valid data types, refer to "See also".
Parameters RET_VAL
The following table shows the meaning of the values of the RET_VAL parameter:
Error code*
(W#16#...)
Explanation
0000 No error
80B5 The instruction cannot be executed because it was not programmed within a startup OB.
8xyy For more information on errors, refer to "See also".
*The error codes can be displayed as integer or hexadecimal value in the program editor. For additional information on
toggling display formats, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1855
Example
The following example shows how the instruction works:
lNlT_RD
RET_VAL REQ
EN ENO
"Tag_REQ" "Tag_Result"
"TagOut"
"Tagln_1"
If the operands "TagIn_1" and "Tag_REQ" have signal state "1", the instruction is executed.
All retentive data of all data blocks, bit memories and SIMATIC Timers and counters are reset.
If the instruction is executed without errors, the ENO enable output has the signal state "1".
See also
Overview of the valid data types (Page 899)
Basics of error handling (Page 1193)
Principles of local error handling (Page 1195)
Error output priorities (Page 1196)
Enabling local error handling for a block (Page 1197)
Basics of the EN/ENO mechanism (Page 987)
WAIT: Configure time delay
Description
The "Configure time delay" instruction is used to halt the execution of the program for a set
period of time. You indicate the period of time in microseconds on the WT parameter of the
instruction.
You can configure time delays of up to 32767 microseconds (s). The smallest possible delay
time depends on the respective CPU and corresponds to the execution time of the "Configure
time delay" instruction.
The execution of the instruction can be interrupted by higher priority events.
The "Configure time delay" instruction supplies no error information.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1856 System Manual, 01/2013,
Parameters
The following table shows the parameters of the "Configure time delay" instruction:
Parameters Declaration Data type Memory area Description
EN Input BOOL I, Q, M, D, L, T, C Enable input
ENO Output BOOL I, Q, M, D, L Enable output
WT Input INT I, Q, M, D, L, P or
constant
Time delay in
microseconds (s)
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
Word logic operations
AND: AND logic operation
Description
You can use the instruction "AND logic operation" to link the value at input IN1 to the value at
input IN2 bit-by-bit by AND logic and query the result at the output OUT.
When the instruction is executed, bit 0 of the value at input IN1 is linked by AND logic to bit 0
of the value at input IN2. The result is stored in bit 0 of output OUT. The same logic operation
is executed for all other bits of the specified values.
In its initial state the instruction box contains at least 2 inputs (IN1 and IN2). The number of
inputs can be extended. The inserted inputs are numbered in ascending order in the box.
During the execution of the instruction, the values of all available input parameters are linked
by AND logic. The result is stored at output "OUT".
The result bit has the signal state "1" only when both of the bits in the logic operation also have
signal state "1". If one of the two bits of the logic operation has signal state "0", the
corresponding result bit is reset.
Parameters
The following table shows the parameters of the instruction "AND logic operation":
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500
EN Input BOOL I, Q, M, D, L I, Q, M, D, L, T,
C
Enable input
ENO Output BOOL I, Q, M, D, L I, Q, M, D, L Enable output
IN1 Input Bit strings I, Q, M, D, L, P
or constant
I, Q, M, D, L, P
or constant
First value for
logic operation
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1857
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500
IN2 Input Bit strings I, Q, M, D, L, P
or constant
I, Q, M, D, L, P
or constant
Second value
for logic
operation
INn Input Bit strings I, Q, M, D, L, P
or constant
I, Q, M, D, L, P
or constant
Optional input
values
OUT Output Bit strings I, Q, M, D, L, P I, Q, M, D, L, P Result of the
instruction
You can select the data type of the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
AND
=
ENO
EN
lN2
lN1 OUT
WORD
"TagOut"
"Tagln"
"Tag_Value1"
"Tag_Value2"
"Tag_Result"
The following table shows how the instruction works using specific operand values:
Parameters Operand Value
IN1 Tag_Value1 0101 0101 0101 0101
IN2 Tag_Value2 0000 0000 0000 1111
OUT Tag_Result 0000 0000 0000 0101
If the operand "TagIn" has the signal state "1", the instruction "AND logic operation" is
executed. The value of operand "Tag_Value1" is linked by AND to the value of the operand
"Tag_Value2". The result is mapped bit-for-bit and sent to the operand "Tag_Result". The
enable output ENO and the output "TagOut" are set to signal state "1".
See also
Overview of the valid data types (Page 899)
Adding additional inputs and outputs to FBD elements (Page 1144)
Removing instruction inputs and outputs (Page 1145)
Basics of the EN/ENO mechanism (Page 987)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1858 System Manual, 01/2013,
OR: OR logic operation
Description
You can use the instruction "OR logic operation" to link the value at input IN1 to the value at
input IN2 bit-by-bit by OR logic and query the result at the output OUT.
When the instruction is executed, bit 0 of the value at input IN1 is linked by OR logic to bit 0
of the value at input IN2. The result is stored in bit 0 of output OUT. The same logic operation
is executed for all bits of the specified tags.
In its initial state the instruction box contains at least 2 inputs (IN1 and IN2). The number of
inputs can be extended in the instruction box. The inserted inputs are numbered in ascending
order in the box. During the execution of the instruction, the values of all available input
parameters are linked by OR logic. The result is stored at output "OUT".
The result bit has the signal state "1" when at least one of the two bits in the logic operation
has the signal state "1". If both of the bits of the logic operation have signal state "0", the
corresponding result bit is reset.
Parameters
The following table shows the parameters of the instruction "OR logic operation":
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500
EN Input BOOL I, Q, M, D, L I, Q, M, D, L, T,
C
Enable input
ENO Output BOOL I, Q, M, D, L I, Q, M, D, L Enable output
IN1 Input Bit strings I, Q, M, D, L, P
or constant
I, Q, M, D, L, P
or constant
First value for
logic operation
IN2 Input Bit strings I, Q, M, D, L, P
or constant
I, Q, M, D, L, P
or constant
Second value
for logic
operation
INn Input Bit strings I, Q, M, D, L, P
or constant
I, Q, M, D, L, P
or constant
Optional input
values
OUT Output Bit strings I, Q, M, D, L, P I, Q, M, D, L, P Result of the
instruction
You can select the data type of the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1859
Example
The following example shows how the instruction works:
OR
=
ENO
EN
lN2
lN1 OUT
WORD
"TagOut"
"Tagln"
"Tag_Value1"
"Tag_Value2"
"Tag_Result"
The following table shows how the instruction works using specific operand values:
Parameters Operand Value
IN1 Tag_Value1 0101 0101 0101 0101
IN2 Tag_Value2 0000 0000 0000 1111
OUT Tag_Result 0101 0101 0101 1111
If the operand "TagIn" has the signal state "1", the instruction "OR logic operation" is executed.
The value of operand "Tag_Value1" is linked by OR to the value of the operand "Tag_Value2".
The result is mapped bit-for-bit and sent to the operand "Tag_Result". The enable output ENO
and the output "TagOut" are set to signal state "1".
See also
Overview of the valid data types (Page 899)
Adding additional inputs and outputs to FBD elements (Page 1144)
Removing instruction inputs and outputs (Page 1145)
Basics of the EN/ENO mechanism (Page 987)
XOR: EXCLUSIVE OR logic operation
Description
You can use the instruction "EXCLUSIVE OR logic operation" to link the value at input IN1 to
the value at input IN2 bit-by-bit by EXCLUSIVE OR logic and query the result at the output
OUT.
When the instruction is executed, bit 0 of the value at input IN1 is linked by EXCLUSIVE OR
logic to bit 0 of the value at input IN2. The result is stored in bit 0 of output OUT. The same
logic operation is executed for all other bits of the specified value.
In its initial state the instruction box contains at least 2 inputs (IN1 and IN2). The number of
inputs can be extended in the instruction box. The inserted inputs are numbered in ascending
order in the box. During the execution of the instruction, the values of all available input
parameters are linked by EXCLUSIVE OR logic. The result is stored at output "OUT".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1860 System Manual, 01/2013,
The result bit has the signal state "1" when one of the two bits in the logic operation has the
signal state "1". If both of the bits of the logic operation have signal state "1" or "0", the
corresponding result bit is reset.
Parameters
The following table shows the parameters of the instruction "EXCLUSIVE OR logic operation":
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500
EN Input BOOL I, Q, M, D, L I, Q, M, D, L, T,
C
Enable input
ENO Output BOOL I, Q, M, D, L I, Q, M, D, L Enable output
IN1 Input Bit strings I, Q, M, D, L, P
or constant
I, Q, M, D, L, P
or constant
First value for
logic operation
IN2 Input Bit strings I, Q, M, D, L, P
or constant
I, Q, M, D, L, P
or constant
Second value
for logic
operation
INn Input Bit strings I, Q, M, D, L, P
or constant
I, Q, M, D, L, P
or constant
Optional input
values
OUT Output Bit strings I, Q, M, D, L, P I, Q, M, D, L, P Result of the
instruction
You can select the data type of the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
XOR
=
ENO
EN
lN2
lN1 OUT
WORD
"TagOut"
"Tagln"
"Tag_Value1"
"Tag_Value2"
"Tag_Result"
The following table shows how the instruction works using specific operand values:
Parameters Operand Value
IN1 Tag_Value1 0101 0101 0101 0101
IN2 Tag_Value2 0000 0000 0000 1111
OUT Tag_Result 0101 0101 0101 1010
If the operand "TagIn" has the signal state "1", the instruction "EXCLUSIVE OR logic operation"
is executed. The value of operand "Tag_Value1" is linked by EXCLUSIVE OR to the value of
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1861
the operand "Tag_Value2". The result is mapped bit-for-bit and sent to the operand
"Tag_Result". The enable output ENO and the output "TagOut" are set to signal state "1".
See also
Overview of the valid data types (Page 899)
Adding additional inputs and outputs to FBD elements (Page 1144)
Removing instruction inputs and outputs (Page 1145)
Basics of the EN/ENO mechanism (Page 987)
INV: Create ones complement
Description
You can use the instruction "Create ones complement" to invert the signal status of the bits at
input IN. When the instruction is processed, the value at input IN is linked to EXCLUSIVE OR
by a hexadecimal mask (W#16#FFFF for 16-bit numbers or DW#16#FFFF FFFF for 32-bit
number). This inverts the signal state of the individual bits that are then stored at output OUT.
Parameters
The following table shows the parameters of the instruction "Create ones complement":
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500
EN Input BOOL I, Q, M, D, L I, Q, M, D, L, T,
C
Enable input
ENO Output BOOL I, Q, M, D, L I, Q, M, D, L Enable output
IN Input Bit strings,
integers
I, Q, M, D, L, P
or constant
I, Q, M, D, L, P
or constant
Input value
OUT Output Bit strings,
integers
I, Q, M, D, L, P I, Q, M, D, L, P Ones
complement of
the value at
input IN
You can select the data type of the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1862 System Manual, 01/2013,
Example
The following example shows how the instruction works:
lNV
EN OUT
= lN ENO
WORD
"TagOut"
"Tagln"
"Tagln_Value"
"TagOut_Value"
The following table shows how the instruction works using specific operand values:
Parameters Operand Value
IN TagIn_Value W#16#000F W#16#7E
OUT TagOut_Value W#16#FFF0 W#16#81
If the operand "TagIn" has the signal state "1", the "Create ones complement" instruction is
executed. The instruction inverts the signal state of the individual bits at input "TagIn_Value"
and writes the result to output "TagOut_Value". The enable output ENO and the output
"TagOut" are set to signal state "1".
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
DECO: Decode
Description
You can use the "Decode" instruction to set a bit in the output value specified by the input
value.
The "Decode" instruction reads the value at the IN input and sets the bit in the output value
whose bit position corresponds to the read value. The other bits in the output value are filled
with zeroes. If the value at input IN is greater than 31, a modulo 32 instruction is executed.
Parameters
The following table shows the parameters of the "Decode" instruction:
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500
EN Input BOOL I, Q, M, D, L I, Q, M, D, L, T,
C
Enable input
ENO Output BOOL I, Q, M, D, L I, Q, M, D, L Enable output
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1863
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500
IN Input UINT I, Q, M, D, L, P
or constant
I, Q, M, D, L, P
or constant
Position of the
bit in the output
value which is
set.
OUT Output Bit strings I, Q, M, D, L, P I, Q, M, D, L, P Output value
You can select the data type of the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
=
OUT EN
DECO
UlNT to
lN ENO
DWORD
"TagOut"
"Tagln"
"Tagln_Value"
"TagOut_Value"
The following figure shows how the instruction works using specific operand values:
0000 0000 0000 0000 0000 0000 0000 1000
3 ... 0 15 ... ... 16 31 ...
3 "Tagln_Value"
"TagOut_Value"
If the operand "TagIn" has the signal state "1", the "Decode" instruction is executed. The
instruction reads bit number "3" from the value of the operand "TagIn_Value" and sets the third
bit to the value of the operand "TagOut_Value".
If no errors occur during the execution of the instruction, the output ENO has the signal state
"1" and the output "TagOut" is set.
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
ENCO: Encode
Description
The instruction "Encode" is used to read the bit number of the lowest bit in the input value and
output it to the output OUT.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1864 System Manual, 01/2013,
The instruction "Encode" selects the least significant bit of the value at the IN input and writes
its bit number to the tag in the output OUT.
Parameters
The following table shows the parameters of the instruction "Encode":
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500
EN Input BOOL I, Q, M, D, L I, Q, M, D, L, T,
C
Enable input
ENO Output BOOL I, Q, M, D, L I, Q, M, D, L Enable output
IN Input Bit strings I, Q, M, D, L, P
or constant
I, Q, M, D, L, P
or constant
Input value
OUT Output INT I, Q, M, D, L, P I, Q, M, D, L, P Output value
You can select the data type of the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
ENCO
OUT
lN
EN
ENO
DWORD
"TagOut" "Tagln_Value"
"TagOut_Value" "Tagln"
The following figure shows how the instruction works using specific operand values:
0000 1111 0000 0101 0000 1001 0000 1000
3 ... 0 15 ... ... 16 31 ...
3
"Tagln_Value"
"TagOut_Value"
If the operand "TagIn" has the signal state "1", the "Encode" instruction is executed. The
instruction selects bit position "3" as the least significant bit at input "TagIn_Value" and writes
the value "3" to the tag at the output "TagOut_Value.
If the instruction is executed without errors, the ENO enable output has the signal state "1"
and the "TagOut" output is set.
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1865
SEL: Select
Description
Depending on the signal state at switch (input G), the "Select" instruction selects one of the
inputs IN0 or IN1 and moves its content to the output OUT. When the input G has the signal
state "0", the value at the input IN0 is moved. When the input G has the signal state "1", the
value at the input IN1 is moved to the output OUT.
The instruction can only be executed if the enable input EN has the signal state "1" and the
tags at all parameters are of the same data type.
Parameters
The following table shows the parameters of the "Select" instruction:
Parameter
s
Declaration Data type Memory area Description
S7-1200 S7-1500 S7-1200 S7-1500
EN Input BOOL BOOL I, Q, M, D,
L
I, Q, M, D, L Enable input
ENO Output BOOL BOOL I, Q, M, D,
L
I, Q, M, D, L Enable output
G Input BOOL BOOL I, Q, M, D,
L
I, Q, M, D, L,
T, C
Switch
IN0 Input Bit strings,
integers,
floating-
point
numbers,
TIME,
TOD,
DATE,
CHAR
Bit strings,
integers,
floating-
point
numbers,
timers,
TOD,
LTOD,
DATE,
CHAR
I, Q, M, D,
L, P or
constant
I, Q, M, D, L,
P or constant
First input value
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1866 System Manual, 01/2013,
Parameter
s
Declaration Data type Memory area Description
S7-1200 S7-1500 S7-1200 S7-1500
IN1 Input Bit strings,
integers,
floating-
point
numbers,
TIME,
TOD,
DATE,
CHAR
Bit strings,
integers,
floating-
point
numbers,
timers,
TOD,
LTOD,
DATE,
CHAR
I, Q, M, D,
L, P or
constant
I, Q, M, D, L,
P or constant
Second input value
OUT Output Bit strings,
integers,
floating-
point
numbers,
TIME,
TOD,
DATE,
CHAR
Bit strings,
integers,
floating-
point
numbers,
timers,
TOD,
LTOD,
DATE,
CHAR
I, Q, M, D,
L, P
I, Q, M, D, L,
P
Result
You can select the data type of the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
SEL
OUT
G
EN
ENO
WORD
lN0
lN1
"TagOut"
"Tagln_G"
"TagOut_Value"
"Tagln_Value0"
"Tagln_Value1"
"Tagln"
The following table shows how the instruction works using specific operand values:
Parameters Operand Value
G TagIn_G 0 1
IN0 TagIn_Value0 W#16#0000 W#16#4C
IN1 TagIn_Value1 W#16#FFFF W#16#5E
OUT TagOut_Value W#16#0000 W#16#5E
If the operand "TagIn" has the signal state "1", the instruction "Select" is executed. Based on
the signal state at the input "TagIn_G", the value at input "TagIn_Value0" or "TagIn_Value1"
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1867
is selected and copied to output "TagOut_Value". If the instruction is executed without errors,
the enable output ENO has the signal state "1" and the output "TagOut" is set.
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
MUX: Multiplex
Description
You can use the instruction "Multiplex" to copy the content of a selected input to output OUT.
In its initial state the instruction box contains at least 2 inputs (IN0 and IN1). The number of
selectable inputs of the instruction box can be expanded. You can declare up to 32 input
parameters when you use a CPU S7-1200 and a maximum of 256 input parameters when you
use a CPU S7-1500.
The inputs are numbered automatically in the box. Numbering starts at IN0 and is incremented
continuously with each new input. You can use the parameter K to determine the input whose
content should be copied to output OUT. If the value of the parameter K is greater than the
number of available inputs, the content of the parameter ELSE is copied to output OUT and
enable output ENO is assigned the signal state "0".
The "Multiplex" instruction can only be executed if the tags have the same data type in all
inputs and in the OUT output. The exception here is the parameter K, which can only be
specified as an integer.
The enable output ENO is reset if one of the following conditions applies:
Enable input EN has the signal state "0".
The value of the parameter K is greater than the number of available inputs.
Errors occurred during the execution of the instruction.
Parameters
The following table shows the parameters of the "Multiplex" instruction:
Parameters Declaring Data type Memory area Description
S7-1200 S7-1500 S7-1200 S7-1500
EN Input BOOL BOOL I, Q, M, D, L I, Q, M, D, L,
T, C
Enable input
ENO Output BOOL BOOL I, Q, M, D, L I, Q, M, D, L Enable
output
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1868 System Manual, 01/2013,
Parameters Declaring Data type Memory area Description
S7-1200 S7-1500 S7-1200 S7-1500
K Input Integers Integers I, Q, M, D, L,
P or
constant
I, Q, M, D, L,
P or
constant
Specifies
the input
whose
content is to
be copied.
If K = 0
=>
Paramet
er IN0
If K = 1
=>
Paramet
er IN1,
etc.
IN0 Input Binary
numbers,
integers,
floating-
point
numbers,
strings,
TIME, TOD,
DATE
Binary
numbers,
integers,
floating-
point
numbers,
strings,
timers,
TOD,
LTOD,
DATE, LDT
I, Q, M, D, L,
P or
constant
I, Q, M, D, L,
P or
constant
First input
value
IN1 Input Binary
numbers,
integers,
floating-
point
numbers,
strings,
TIME, TOD,
DATE
Binary
numbers,
integers,
floating-
point
numbers,
strings,
timers,
TOD,
LTOD,
DATE, LDT
I, Q, M, D, L,
P or
constant
I, Q, M, D, L,
P or
constant
Second
input value
INn Input Binary
numbers,
integers,
floating-
point
numbers,
strings,
TIME, TOD,
DATE
Binary
numbers,
integers,
floating-
point
numbers,
strings,
timers,
TOD,
LTOD,
DATE, LDT
I, Q, M, D, L,
P or
constant
I, Q, M, D, L,
P or
constant
Optional
input values
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1869
Parameters Declaring Data type Memory area Description
S7-1200 S7-1500 S7-1200 S7-1500
ELSE Input Binary
numbers,
integers,
floating-
point
numbers,
strings,
TIME, TOD,
DATE
Binary
numbers,
integers,
floating-
point
numbers,
strings,
timers,
TOD,
LTOD,
DATE, LDT
I, Q, M, D, L,
P or
constant
I, Q, M, D, L,
P or
constant
Specifies
the value to
be copied
when K > n.
OUT Output Binary
numbers,
integers,
floating-
point
numbers,
strings,
TIME, TOD,
DATE
Binary
numbers,
integers,
floating-
point
numbers,
strings,
timers,
TOD,
LTOD,
DATE, LDT
I, Q, M, D, L,
P
I, Q, M, D, L,
P
Output to
which the
value is to
be copied.
You can select the data type of the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
S
MUX
EN
ENO K
OUT
lN0
lN1
ELSE
DWORD
"Tag_Result" "Tag_lnput"
"Tag_Number"
"Tag_Value_0"
"Tag_Value_1"
"Tag_Value_2"
"Tag_Output"
The following table shows how the instruction works using specific operand values:
Parameters Operand Value
K Tag_Number 1
IN0 Tag_ValueI_0 DW#16#00000000
IN1 Tag_Value_1 DW#16#003E4A7D
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1870 System Manual, 01/2013,
Parameters Operand Value
ELSE Tag_Value_2 DW#16#FFFF0000
OUT Tag_Result DW#16#003E4A7D
If the operand "Tag_Input" has the signal state "1", the "Multiplex" instruction is executed.
Depending on the value of the operand "Tag_Number", the value at input "Tag_Value_1" is
copied and assigned to the operand at output "Tag_Result". If no errors occur during the
execution of the instruction, the outputs ENO and "Tag_Output" are set.
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
DEMUX: Demultiplex
Description
You can use the instruction "Demultiplex" to copy the content of the input IN to a selected
output. In its initial state the instruction box contains at least 2 outputs (OUT0 and OUT1). The
number of selectable outputs can be extended in the instruction box. The outputs are numbered
automatically in the box. Numbering starts at OUT0 and is incremented continuously with each
new input. You can use the parameter K to define the output to which the content of input IN
will be copied. The other outputs will not be changed. If the value of the parameter K is greater
than the number of available outputs, then the content of input IN in the parameter ELSE and
the enable output ENO will be assigned to the signal state "0".
The instruction "Demultiplex" can only be executed if the tags at the input IN and at all outputs
are of the same data type. The exception here is the parameter K, which can only be specified
as an integer.
The enable output ENO is reset if one of the following conditions applies:
Enable input EN has the signal state "0".
The value of the parameter K is greater than the number of available outputs.
Errors occurred during the execution of the instruction.
Parameters
The following table shows the parameters of the instruction "Demultiplex":
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500 S7-1200 S7-1500
EN Input BOOL BOOL I, Q, M, D, L I, Q, M, D, L,
T, C
Enable input
ENO Output BOOL BOOL I, Q, M, D, L I, Q, M, D, L Enable
output
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1871
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500 S7-1200 S7-1500
K Input Integers Integers I, Q, M, D, L,
P or
constant
I, Q, M, D, L,
P or
constant
Specifies
the output to
which the
input value
(IN) will be
copied.
If K = 0
=>
Paramet
er OUT0
If K = 1
=>
Paramet
er
OUT1,
etc.
IN Input Binary
numbers,
integers,
floating-
point
numbers,
strings,
TIME, TOD,
DATE, DT
Binary
numbers,
integers,
floating-
point
numbers,
strings,
timers,
TOD,
LTOD,
DATE, DT,
LDT
I, Q, M, D, L,
P or
constant
I, Q, M, D, L,
P or
constant
Input value
OUT0 Output Binary
numbers,
integers,
floating-
point
numbers,
strings,
TIME, TOD,
DATE, DT
Binary
numbers,
integers,
floating-
point
numbers,
strings,
timers,
TOD,
LTOD,
DATE, DT,
LDT
I, Q, M, D, L,
P
I, Q, M, D, L,
P
First output
OUT1 Output Binary
numbers,
integers,
floating-
point
numbers,
strings,
TIME, TOD,
DATE, DT
Binary
numbers,
integers,
floating-
point
numbers,
strings,
timers,
TOD,
LTOD,
DATE, DT,
LDT
I, Q, M, D, L,
P
I, Q, M, D, L,
P
Second
output
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1872 System Manual, 01/2013,
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500 S7-1200 S7-1500
OUTn Output Binary
numbers,
integers,
floating-
point
numbers,
strings,
TIME, TOD,
DATE, DT
Binary
numbers,
integers,
floating-
point
numbers,
strings,
timers,
TOD,
LTOD,
DATE, DT,
LDT
I, Q, M, D, L,
P
I, Q, M, D, L,
P
Optional
outputs
ELSE Output Binary
numbers,
integers,
floating-
point
numbers,
strings,
TIME, TOD,
DATE, DT
Binary
numbers,
integers,
floating-
point
numbers,
strings,
timers,
TOD,
LTOD,
DATE, DT,
LDT
I, Q, M, D, L,
P
I, Q, M, D, L,
P
Output to
which the
input value
(IN) at K > n
is copied.
You can select the data type of the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on available data types, refer to "See also".
Example
The following example shows how the instruction works:
S
K
OUT0
OUT1
ELSE
lN
EN
ENO
DWORD
DEMUX
"Tag_lnput"
"Tag_Value"
"Tag_Number" "Tag_Output_1"
"Tag_Output_0"
"Tag_Output_2"
"Tag_Output"
The following tables show how the instruction works using specific operand values:
Table 9-26 Input values of the "Demultiplex" instruction before network execution
Parameters Operand Values
K Tag_Number 1 4
IN Tag_Value DW#16#FFFFFFFF DW#16#003E4A7D
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1873
Table 9-27 Output values of the "Demultiplex" instruction after network execution
Parameters Operand Values
OUT0 Tag_Output_0 Unchanged Unchanged
OUT1 Tag_Output_1 DW#16#FFFFFFFF Unchanged
ELSE Tag_Output_2 Unchanged DW#16#003E4A7D
The "Demultiplex" instruction is executed when input "Tag_Input" has the signal state "1".
Depending on the value of the operand "Tag_Number", the value at input "IN" is copied to the
corresponding output.
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
Shift and rotate
SHR: Shift right
Description
You can use the "Shift right" instruction to shift the content of the operand at the input IN bit-
by-bit to the right and query the result at the OUT output. The input N is used to specify the
number of bit positions by which the specified value should be moved.
If the value at the input N is "0", the value at input IN is copied unchanged to the operand at
output OUT.
If the value at the input N is greater than the number of available bit positions, the operand
value at input IN is shifted to the right by the available number of bit positions.
The freed bit positions in the left area of the operand are filled by zeroes when values without
signs are shifted. If the specified value has a sign, the free bit positions are filled with the signal
state of the sign bit.
The following figure show how the content of an integer data type operand is shifted four bit
positions to the right:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1874 System Manual, 01/2013,
OUT
4 places Sign
bit
These four bits
are lost.
The freed bit positions are
filled with the signal state
of the sign bit.
lN
N
1 1 1 1 1 0 1 0 1 1 1 1 0 0 0 0 1 0 1 0
15... ...8 7... ...0
1 0 1 0 1 1 1 1 0 0 0 0 1 0 1 0
Parameters
The following table shows the parameters of the instruction "Shift right":
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500
EN Input BOOL I, Q, M, D, L I, Q, M, D, L, T,
C
Enable input
ENO Output BOOL I, Q, M, D, L I, Q, M, D, L Enable output
IN Input Bit strings,
integers
I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
Value to be
shifted.
N Input UINT I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
Number of bit
positions by
which the
value is shifted.
OUT Output Bit strings,
integers
I, Q, M, D, L I, Q, M, D, L Result of the
instruction
You can select the data type of the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1875
Example
The following example shows how the instruction works:
SHR
EN
OUT lN
N ENO
WORD
S
"TagOut"
"Tagln"
"TagOut_Value"
"Tag_Number"
"Tagln_Value"
The following table shows how the instruction works using specific operand values:
Parameters Operand Value
IN TagIn_Value 0011 1111 1010 1111
N Tag_Number 3
OUT TagOut_Value 0000 0111 1111 0101
If the operand "TagIn" has the signal state "1", the instruction "Shift right" is executed. The
content of the operand "TagIn_Value" is shifted three bit positions to the right. The result is
sent at output "TagOut_Value". If the instruction is executed without errors, the ENO enable
output has the signal state "1" and the "TagOut" output is set.
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
SHL: Shift left
Description
You can use the "Shift left" instruction to shift the content of the operand at the input IN bit-by-
bit to the left and query the result at the OUT output. The input N is used to specify the number
of bit positions by which the specified value should be moved.
If the value at the input N is "0", the value at input IN is copied unchanged to the operand at
output OUT.
If the value at the input N is greater than the number of available bit positions, the operand
value at input IN is shifted to the left by the available number of bit positions.
The bit positions in the right part of the operand freed by shifting are filled with zeros.
The following figure show how the content of an operand of the data type WORD is shifted six
bit positions to the left:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1876 System Manual, 01/2013,
OUT
6 places
The freed bit positions
are filled with zeros
.
These six bits
are lost.
lN
N
0 1 1 0 1 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 1 1
15... ...8 7... ...0
0 0 0 0 1 1 1 1 0 1 0 1 0 1 0 1
Parameters
The following table shows the parameters of the instruction "Shift left":
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500
EN Input BOOL I, Q, M, D, L I, Q, M, D, L, T,
C
Enable input
ENO Output BOOL I, Q, M, D, L I, Q, M, D, L Enable output
IN Input Bit strings,
integers
I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
Value to be
shifted.
N Input UINT I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
Number of bit
positions by
which the
value is shifted.
OUT Output Bit strings,
integers
I, Q, M, D, L I, Q, M, D, L Result of the
instruction
You can select the data type of the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1877
Example
The following example shows how the instruction works:
SHL
EN
OUT lN
N ENO
WORD
S
"TagOut"
"Tagln"
"TagOut_Value"
"Tag_Number"
"Tagln_Value"
The following table shows how the instruction works using specific operand values:
Parameters Operand Value
IN TagIn_Value 0011 1111 1010 1111
N Tag_Number 4
OUT TagOut_Value 1111 1010 1111 0000
If the operand "TagIn" has the signal state "1", the instruction "Shift left" is executed. The
content of the operand "TagIn_Value" is shifted four bit positions to the left. The result is sent
at output "TagOut_Value". If the instruction is executed without errors, the ENO enable output
has the signal state "1" and the "TagOut" output is set.
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
ROR: Rotate right
Description
You can use the "Rotate right" instruction to rotate the content of the operand at the input IN
bit-by-bit to the right and query the result at the OUT output. The input N is used to specify the
number of bit positions by which the specified value should be rotated. The bit positions freed
by rotating on the left-hand side are filled true-to-position with the bit positions that are pushed
out from the left-hand side.
If the value at the input N is "0", the value at input IN is copied unchanged to the operand at
output OUT.
If the value at the parameter N is greater than the number of available bit positions, the operand
value at input IN is nevertheless rotated by the specified number of bit positions.
The following figure shows how the content of an operand of the data type DWORD is rotated
three bit positions to the right:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1878 System Manual, 01/2013,
OUT
3 places
The signal state of the three
shifted bits is inserted in the
freed places.
lN
N
1 0 1 1 0 1 0 1 0 1 0 0 1 1 1 0 0 0 0 1 0 0 0 1 1 1 1 0 1 0 1 0 1 0 1
31... ...16 15... ...0
1 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 0 1 0 1 0 1 0 1
Parameters
The following table shows the parameters of the instruction "Rotate right":
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500
EN Input BOOL I, Q, M, D, L I, Q, M, D, L, T,
C
Enable input
ENO Output BOOL I, Q, M, D, L I, Q, M, D, L Enable output
IN Input Bit strings I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
Value to be
rotated.
N Input UINT I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
Number of bit
positions by
which the
value is
rotated.
OUT Output Bit strings I, Q, M, D, L I, Q, M, D, L Result of the
instruction
You can select the data type of the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1879
Example
The following example shows how the instruction works:
ROR
EN
OUT lN
N ENO
WORD
S
"TagOut"
"Tagln"
"TagOut_Value"
"Tag_Number"
"Tagln_Value"
The following table shows how the instruction works using specific operand values:
Parameters Operand Value
IN TagIn_Value 0000 1111 1001 0101
N Tag_Number 5
OUT TagOut_Value 1010 1000 0111 1100
If the operand "TagIn" has the signal state "1", the instruction "Rotate right" is executed. The
content of the operand "TagIn_Value" is rotated five bit positions to the right. The result is sent
at output "TagOut_Value". If the instruction is executed without errors, the ENO enable output
has the signal state "1" and the "TagOut" output is set.
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
ROL: Rotate left
Description
You can use the "Rotate left" instruction to rotate the content of the operand at the input IN bit-
by-bit to the left and query the result at the OUT output. The input N is used to specify the
number of bit positions by which the specified value should be rotated. The bit positions freed
by rotating on the right-hand side are filled true-to-position with the bit positions that are pushed
out from the left-hand side.
If the value at the input N is "0", the value at input IN is copied to the operand at output OUT.
If the value at the parameter N is greater than the number of available bit positions, the operand
value at input IN is nevertheless rotated by the specified number of bit positions.
The following figure shows how the content of an operand of the data type DWORD is rotated
three bit positions to the left:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1880 System Manual, 01/2013,
OUT
3 places
The signal state of the three
shifted bits will be inserted in the
free places.
lN
N
1 0 0 0 0 1 0 1 0 1 0 1 0 1 1 1 0 0 0 0 1 0 0 0 0 1 1 1 1 1 1 1 1 1 1
31... ...16 15... ...0
1 1 1 1 0 0 0 0 1 0 1 0 0 0 0 0 1 0 1 0 1 1 1 1 0 0 0 0 1 1 1 1
Parameters
The following table shows the parameters of the instruction "Rotate left":
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500
EN Input BOOL I, Q, M, D, L I, Q, M, D, L, T,
C
Enable input
ENO Output BOOL I, Q, M, D, L I, Q, M, D, L Enable output
IN Input Bit strings I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
Value to be
rotated.
N Input UINT I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
Number of bit
positions by
which the
value is
rotated.
OUT Output Bit strings I, Q, M, D, L I, Q, M, D, L Result of the
instruction
You can select the data type of the instruction from the "<???>" drop-down list of the instruction
box.
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1881
Example
The following example shows how the instruction works:
ROR
EN
OUT lN
N ENO
WORD
S
"TagOut"
"Tagln"
"TagOut_Value"
"Tag_Number"
"Tagln_Value"
The following table shows how the instruction works using specific operand values:
Parameters Operand Value
IN TagIn_Value 1010 1000 1111 0110
N Tag_Number 5
OUT TagOut_Value 0001 1110 1101 0101
If input "TagIn" has the signal state "1", the instruction "Rotate left" is executed. The content
of the operand "TagIn_Value" is rotated five bit positions to the left. The result is sent at output
"TagOut_Value". If the instruction is executed without errors, the ENO enable output has the
signal state "1" and the "TagOut" output is set.
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
Additional instructions
DRUM: Implement sequencer
Description
The "Implement sequencer" instruction is used to assign the programmed output bits (OUT1
to OUT16) and the output word (OUT_WORD) to the programmed values of the OUT_VAL
parameter of the corresponding step. The specific step must thereby satisfy the conditions of
the programmed enable mask on the S_MASK parameter while the instruction remains at this
step. The instruction advances to the next step if the event for the step is true and the
programmed time for the current step elapses, or if the value at the JOG parameter changes
from "0" to "1". The instruction is reset if the signal state on the RESET parameter changes to
"1". The current step is hereby equated to the preset step (DSP).
The amount of time spent on a step is determined by the product of the preset timebase (DTBP)
and the preset counter value (S_PRESET) for each step. At the start of a new step, this
calculated value is loaded into the DCC parameter, which contains the time remaining for the
current step. If, for example the value at the DTBP parameter is "2" and the preset value for
the first step is "100" (100 ms), the DCC parameter has the value "200" (200 ms).
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1882 System Manual, 01/2013,
A step can be programmed with a timer value, an event, or both. Steps that have an event bit
and the timer value "0" advance to the next step as soon as the signal state of the event bit is
"1". Steps that are programmed only with a timer value start the time immediately. Steps that
are programmed with an event bit and a timer value greater than "0" start the time when the
signal state of the event bit is "1". The event bits are initialized with a signal state of "1".
When the sequencer is on the last programmed step (LST_STEP) and the time for this step
has expired, the signal state on the Q parameter is set to "1"; otherwise it is set to "0". When
the parameter Q is set, the instruction remains on the step until it is reset.
In the configurable mask (S_MASK) you can select the separate bits in the output word
(OUT_WORD) and set or reset the output bits (OUT1 to OUT16) by means of the output values
(OUT_VAL). If a bit of the configurable mask is in the signal state "1", the value OUT_VAL sets
or resets the corresponding bit. If the signal state of a bit of the configurable mask is "0", the
corresponding bit is left unchanged. All the bits of the configurable mask for all 16 steps are
initialized with a signal state of "1".
The output bit on the OUT1 parameter corresponds to the least significant bit of the output
word (OUT_WORD). The output bit on the OUT16 parameter corresponds to the most
significant bit of the output word (OUT_WORD).
When you insert the instruction in the program, the "Call options" dialog opens in which you
can specify whether the IEC Counter is stored in its own data block (single instance) or as a
local tag (multiple instance) in the block interface. If you create a separate data block, you will
find this in the project tree in the "Program resources" folder under "Program blocks > System
blocks". For additional information on this topic, refer to "See also".
Parameters
The following table shows the parameters of the "Implement sequencer" instruction:
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500
EN Input BOOL I, Q, M, D, L I, Q, M, D, L, T,
C
Enable input
ENO Output BOOL I, Q, M, D, L I, Q, M, D, L Enable output
RESET Input BOOL I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
A signal state
of "1" indicates
a reset
condition.
JOG Input BOOL I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
When the
signal state
changes from
"0" to "1", the
instruction
advances to
the next step.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1883
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500
DRUM_EN Input BOOL I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
A signal state
of "1" allows
the sequencer
to advance
based on the
event and time
criteria.
LST_STEP Input BYTE I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
Number of the
last
programmed
step
EVENT1 Input BOOL I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
Event bit 1;
initial signal
state is "1".
EVENT2 Input BOOL I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
Event bit 2;
initial signal
state is "1".
EVENT3 Input BOOL I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
Event bit 3;
initial signal
state is "1".
EVENT4 Input BOOL I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
Event bit 4;
initial signal
state is "1".
EVENT5 Input BOOL I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
Event bit 5;
initial signal
state is "1".
EVENT6 Input BOOL I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
Event bit 6;
initial signal
state is "1".
EVENT7 Input BOOL I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
Event bit 7;
initial signal
state is "1".
EVENT8 Input BOOL I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
Event bit 8;
initial signal
state is "1".
EVENT9 Input BOOL I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
Event bit 9;
initial signal
state is "1".
EVENT10 Input BOOL I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
Event bit 10;
initial signal
state is "1".
EVENT11 Input BOOL I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
Event bit 11;
initial signal
state is "1".
EVENT12 Input BOOL I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
Event bit 12;
initial signal
state is "1".
EVENT13 Input BOOL I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
Event bit 13;
initial signal
state is "1".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1884 System Manual, 01/2013,
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500
EVENT14 Input BOOL I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
Event bit 14;
initial signal
state is "1".
EVENT15 Input BOOL I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
Event bit 15;
initial signal
state is "1".
EVENT16 Input BOOL I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
Event bit 16;
initial signal
state is "1".
OUT1 Output BOOL I, Q, M, D, L I, Q, M, D, L Output bit 1
OUT2 Output BOOL I, Q, M, D, L I, Q, M, D, L Output bit 2
OUT3 Output BOOL I, Q, M, D, L I, Q, M, D, L Output bit 3
OUT4 Output BOOL I, Q, M, D, L I, Q, M, D, L Output bit 4
OUT5 Output BOOL I, Q, M, D, L I, Q, M, D, L Output bit 5
OUT6 Output BOOL I, Q, M, D, L I, Q, M, D, L Output bit 6
OUT7 Output BOOL I, Q, M, D, L I, Q, M, D, L Output bit 7
OUT8 Output BOOL I, Q, M, D, L I, Q, M, D, L Output bit 8
OUT9 Output BOOL I, Q, M, D, L I, Q, M, D, L Output bit 9
OUT10 Output BOOL I, Q, M, D, L I, Q, M, D, L Output bit 10
OUT11 Output BOOL I, Q, M, D, L I, Q, M, D, L Output bit 11
OUT12 Output BOOL I, Q, M, D, L I, Q, M, D, L Output bit 12
OUT13 Output BOOL I, Q, M, D, L I, Q, M, D, L Output bit 13
OUT14 Output BOOL I, Q, M, D, L I, Q, M, D, L Output bit 14
OUT15 Output BOOL I, Q, M, D, L I, Q, M, D, L Output bit 15
OUT16 Output BOOL I, Q, M, D, L I, Q, M, D, L Output bit 16
Q Output BOOL I, Q, M, D, L I, Q, M, D, L A signal state
of "1" indicates
that the time
for the last step
has elapsed.
OUT_WORD Output WORD I, Q, M, D, L, P I, Q, M, D, L, P Word address
to which the
sequencer
writes the
output values.
ERR_CODE Output WORD I, Q, M, D, L, P I, Q, M, D, L, P Error
information
JOG_HIS Static BOOL I, Q, M, D, L I, Q, M, D, L JOG
parameter
history bit
EOD Static BOOL I, Q, M, D, L I, Q, M, D, L A signal state
of "1" indicates
that the time
for the last step
has elapsed.
DSP Static BYTE I, Q, M, D, L, P I, Q, M, D, L, P Preset step of
the sequencer
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1885
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500
DSC Static BYTE I, Q, M, D, L, P I, Q, M, D, L, P Current step of
the sequencer
DCC Static DWORD I, Q, M, D, L, P I, Q, M, D, L, P Current
numerical
value of the
sequencer
DTBP Static WORD I, Q, M, D, L, P I, Q, M, D, L, P Preset
timebase of
the sequencer
PREV_TIME Static DWORD I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
Previous
system time
S_PRESET Static ARRAY of
WORD
I, Q, M, D, L I, Q, M, D, L Count preset
for each step
[1 to 16];
whereby 1
count = 1 ms.
OUT_VAL Static ARRAY of
BOOL
I, Q, M, D, L I, Q, M, D, L Output values
for each step
[1 to 16,
0 to 15].
S_MASK Static ARRAY of
BOOL
I, Q, M, D, L I, Q, M, D, L Configurable
mask for each
step [1 to 16,
0 to 15]. Initial
signal states
are "1".
Parameters ERR_CODE
The following table shows the meaning of the values of the ERR_CODE parameter:
ERR_CODE* Explanation
W#16#0000 No error
W#16#000B The value at the LST_STEP parameter is less than 1 or greater than 16.
W#16#000C The value at the DSC parameter is less than 1 or greater than the value at
the LST_STEP parameter.
W#16#000D The value at the DSP parameter is less than 1 or greater than the value at
the LST_STEP parameter.
*The error codes can be displayed as integer or hexadecimal value in the program editor. For additional information on
toggling display formats, refer to "See also".
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1886 System Manual, 01/2013,
DCAT: Discrete control-timer alarm
Description
The "Discrete control-timer alarm" instruction is used to accumulate the time from the point at
which the CMD parameter issued the command to open or close. The time is accumulated
until the preset time (PT) is exceeded or the information is received that the device was opened
or closed (O_FB or C_FB) within the specified time. If the preset time is exceeded before the
information on the opening or closing of the device is received, the corresponding alarm is
activated. If the signal state on the command input changes state before the preset time, the
time is restarted.
When you insert the instruction in the program, the "Call options" dialog opens in which you
can specify whether the IEC Timer is stored in its own data block (single instance) or as a local
tag (multiple instance) in the block interface. If you create a separate data block, you will find
this in the project tree in the "Program resources" folder under "Program blocks > System
blocks". For additional information on this topic, refer to "See also".
The "Discrete control-timer alarm" instruction has the following reactions to the input conditions:
When the signal state of the CMD parameter changes from "0" to "1", the signal states of
the parameters Q, CMD_HIS, ET (only if ET is < PT) OA and CA are influenced as follows:
The parameters Q and CMD_HIS are set to "1".
The parameters ET, OA and CA are reset to "0".
When the signal state on the parameter CMD changes from "1" to "0", the parameters Q,
ET (only if ET is < PT), OA, CA and CMD_HIS are reset to "0".
When the signal state of the CMD and CMD_HIS parameters is "1" and the parameter O_FB
is set to "0", the time difference (ms) since the last execution of the instruction is added to
the value at the parameter ET. If the value of the parameter ET exceeds the value of the
parameter PT, the signal state on the parameter OA is set to "1". If the value of the
parameter ET does not exceed the value of the parameter PT, the signal state on the
parameter OA is reset to "0". The value at the parameter CMD_HIS is reset to the value of
the parameter CMD.
If the signal state of the parameters CMD, CMD_HIS and O_FB are set to "1" and the
parameter C_FB has the value "0", the signal state of the parameter OA is set to "0". The
value of the parameter ET is set to the value of the parameter PT. If the signal state of the
parameter O_FB changes to "0", the alarm is set the next time the instruction is executed.
The value of the parameter CMD_HIS is set to the value of the parameter CMD.
If the CMD, CMD_HIS and C_FB parameters return signal state "0", the time difference
(ms) since the last execution of the instruction is added to the value of the ET parameter.
If the value of the parameter ET exceeds the value of the parameter PT, the signal state
of the parameter CA is reset to "1". If the value at the parameter PT is not exceeded, the
parameter CA has the signal state "0". The value of the parameter CMD_HIS is set to the
value of the parameter CMD.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1887
If the parameters CMD, CMD_HIS and O_FB have the signal state "0" and the parameter
C_FB is set to "1", the parameter CA is set to "0". The value of the parameter ET is set to
the value of the parameter PT. If the signal state of the parameter C_FB changes to "0",
the alarm is set the next time the instruction is executed. The value of the parameter
CMD_HIS is set to the value of the parameter CMD.
If the parameters O_FB and C_FB simultaneously have the signal state "1", the signal states
of both alarm outputs are set to "1".
The "Discrete control-timer alarm" instruction has no error information.
Parameters
The following table shows the parameters of the "Discrete control-timer alarm" instruction:
Paramete
rs
Declarat
ion
Data
type
Memory area Description
S7-1200 S7-1500
EN Input BOOL I, Q, M, D, L I, Q, M, D, L, T, C Enable input
ENO Output BOOL I, Q, M, D, L I, Q, M, D, L Enable output
CMD Input BOOL I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
A signal state of "0"
indicates a "close"
command.
A signal state of "1"
indicates an "open"
command.
O_FB Input BOOL I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
Feedback input
when opening
C_FB Input BOOL I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
Feedback input
when closing
Q Output BOOL I, Q, M, D, L I, Q, M, D, L Shows the status of
the parameter CMD
OA Output BOOL I, Q, M, D, L I, Q, M, D, L Alarm output when
opening
CA Output BOOL I, Q, M, D, L I, Q, M, D, L Alarm output when
closing
ET Static DINT D, L D, L Currently elapsed
time, where one
count = 1 ms.
PT Static DINT D, L D, L Preset timer value,
where one count = 1
ms.
PREV_TI
ME
Static DWOR
D
D, L D, L Previous system time
CMD_HIS Static BOOL D, L D, L CMD history bit
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1888 System Manual, 01/2013,
Example
In the following example the parameter CMD changes from "0" to "1". After the execution of
the instruction the parameter Q is set to "1" and the two alarm outputs OA and CA have the
signal state "0". The parameter CMD_HIS of the instance data block is set to the signal state
"1" and the parameter ET is reset to "0".
Note
You can initialize static parameters in the data block.
"Tag_lnput_CMD"
"Tag_Output_Q"
"Tag_Output_OA"
"Tag_Output_CA" "Tag_lnput_O_FB"
"Tag_lnput_C_FB"
"Tagln"
"TagOut"
"DCAT_DB"
EN
CMD
O_FB
C_FB ENO
Q
OA
CA
DCAT
The following table shows how the instruction works using specific operand values:
Before processing
In this example the following values are used for the input and output parameters:
Parameters Operand Value
CMD Tag_Input_CMD TRUE
O_FB Tag_Input_O_FB FALSE
C_FB Tag_Input_C_FB FALSE
Q Tag_Output_Q FALSE
OA Tag_Output_OA FALSE
CA Tag_Output_CA FALSE
The following values are saved in the instance data block "DCAT_DB" of the instruction:
Parameters Address Value
ET DBD4 L#12
PT DBD8 L#222
CMD_HIS DBX16.0 FALSE
After processing
The following values are written to the output parameters after the instruction has been
executed:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1889
Parameters Operand Value
Q Tag_Output_Q TRUE
OA Tag_Output_OA FALSE
CA Tag_Output_CA FALSE
The following values are saved in the instance data block "DCAT_DB" of the instruction:
Parameters Address Value
ET DBD4 L#0
CMD_HIS DBX16.0 TRUE
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
MCAT: Motor control-timer alarm
Description
The instruction "Motor control-timer alarm" is used to accumulate the time from the point of
time from which the one of the command inputs (opening or closing) is switched on. The time
is accumulated until the preset time is exceeded or the relevant feedback input indicates that
the device has executed the requested operation within the specified time. If the preset time
is exceeded before the feedback is received, the corresponding alarm is triggered.
When you insert the instruction in the program, the "Call options" dialog opens in which you
can specify whether the IEC Timer is stored in its own data block (single instance) or as a local
tag (multiple instance) in the block interface. If you create a separate data block, you will find
this in the project tree in the "Program resources" folder under "Program blocks > System
blocks". For additional information on this topic, refer to "See also".
The "Motor control-timer alarm" instruction returns no error information.
Execution of the "Motor control-timer alarm" instruction
The following table shows the reactions of the instruction "Motor control-timer alarm" to the
various input conditions:
Input parameters Output parameters
ET O_H
IS
C_H
IS
O_C
MD
C_C
MD
S_C
MD
O_F
B
C_F
B
OO CO OA CA ET O_H
IS
C_H
IS
Q Status
X 1 1 X X X X X 0 0 1 1 PT 0 0 0 Alarm
X X X X X X 1 1 0 0 1 1 PT 0 0 0 Alarm
X X X X X 1 X X 0 0 0 0 X 0 0 1 Stop
X X X 1 1 X X X 0 0 0 0 X 0 0 1 Stop
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1890 System Manual, 01/2013,
Input parameters Output parameters
X 0 X 1 0 0 X X 1 0 0 0 0 1 0 1 Start
opening
<PT 1 0 X 0 0 0 X 1 0 0 0 INC 1 0 1 Open
X 1 0 X 0 0 1 0 0 0 0 0 PT 1 0 1 Opened
>=P
T
1 0 X 0 0 0 X 0 0 1 0 PT 1 0 0 Opening
alarm
X X 0 0 1 0 X X 0 1 0 0 0 0 1 1 Start closing
<PT 0 1 0 X 0 X 0 0 1 0 0 INC 0 1 1 Close
X 0 1 0 X 0 0 1 0 0 0 0 PT 0 1 1 Closed
>=P
T
0 1 0 X 0 X 0 0 0 0 1 PT 0 1 0 Closing
alarm
X 0 0 0 0 0 X X 0 0 0 0 X 0 0 1 Stopped
Legend:
INC Add the time difference (ms) since the last processing of the FB to ET
PT PT is set to the same value as ET
X Cannot be used
<PT ET < PT
>=PT ET >= PT
If the input parameters O_HIS and C_HIS both have the signal state "1", they are immediately set to signal state "0". In this
case, the last row of the above-named table (X) is valid. Because it is therefore no longer possible to check whether the
input parameters O_HIS and C_HIS have the signal state "1", the output parameters are set as follows in this case:
OO = FALSE
CO = FALSE
OA = FALSE
CA = FALSE
ET = PT
Q = TRUE
Parameters
The following table shows the parameters of the "Motor control-timer alarm" instruction:
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500
EN Input BOOL I, Q, M, D, L I, Q, M, D, L, T,
C
Enable input
ENO Output BOOL I, Q, M, D, L I, Q, M, D, L Enable output
O_CMD Input BOOL I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
"Open"
command input
C_CMD Input BOOL I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
"Close"
command input
S_CMD Input BOOL I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
"Stop"
command input
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1891
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500
O_FB Input BOOL I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
Feedback
input when
opening
C_FB Input BOOL I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
Feedback
input when
closing
OO Output BOOL I, Q, M, D, L I, Q, M, D, L "Open" output
CO Output BOOL I, Q, M, D, L I, Q, M, D, L "Close" output
OA Output BOOL I, Q, M, D, L I, Q, M, D, L Alarm output
when opening
CA Output BOOL I, Q, M, D, L I, Q, M, D, L Alarm output
when closing
Q Output BOOL I, Q, M, D, L I, Q, M, D, L A signal state
of "0" indicates
an error
condition.
ET Static DINT D, L D, L Currently
elapsed time,
where one
count = 1 ms
PT Static DINT D, L D, L Preset timer
value, where
one count = 1
ms
PREV_TIME Static DWORD D, L D, L Previous
system time
O_HIS Static BOOL D, L D, L "Open" history
bit
C_HIS Static BOOL D, L D, L "Close" history
bit
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
Note
You can initialize static parameters in the data block.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1892 System Manual, 01/2013,
"MCAT_DB"
EN
O_CMD
C_CMD
S_CMD
O_FB
C_FB ENO
OO
CO
OA
CA
Q
MCAT
"Tagln"
"TagOut"
"Tag_lnput_O_CMD"
"Tag_lnput_C_CMD"
"Tag_lnput_S_CMD"
"Tag_lnput_O_FB"
"Tag_lnput_C_FB"
"Tag_OutputOpen"
"Tag_OutputClosed"
"Tag_Output_OA"
"Tag_Output_CA"
"Tag_Output_Q"
The following table shows how the instruction works using specific operand values:
Before processing
In this example the following values are used for the input and output parameters:
Parameters Operand Value
O_CMD Tag_Input_O_CMD TRUE
C_CMD Tag_Input_C_CMD FALSE
S_CMD Tag_Input_S_CMD FALSE
O_FB Tag_Input_O_FB FALSE
C_FB Tag_Input_C_FB FALSE
OO Tag_OutputOpen FALSE
CO Tag_OutputClosed FALSE
OA Tag_Output_OA FALSE
CA Tag_Output_CA FALSE
Q Tag_Output_Q FALSE
The following values are saved in the instance data block "MCAT_DB" of the instruction:
Parameters Address Value
ET DBD4 L#2
PT DBD8 L#22
O_HIS DBX16.0 TRUE
C_HIS DBX16.1 FALSE
After processing
The following values are written to the output parameters after the instruction has been
executed:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1893
Parameters Operand Value
OO Tag_OutputOpen TRUE
CO Tag_OutputClosed FALSE
OA Tag_Output_OA FALSE
CA Tag_Output_CA FALSE
Q Tag_Output_Q TRUE
The following values are saved in the instance data block "MCAT_DB" of the instruction:
Parameters Address Value
ET DBD4 L#0
O_HIS DBX16.0 TRUE
CMD_HIS DBX16.1 FALSE
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
IMC: Compare input bits with the bits of a mask
Description
The instruction "Compare input bits with the bits of a mask" is used to compare the signal state
of up to 16 programmed input bits (IN_BIT0 to IN_BIT15) with the corresponding bits of a mask.
Up to 16 steps with masks can be programmed. The value of the IN_BIT0 parameter is
compared with the value of the mask CMP_VAL[x,0], with "x" indicating the step number. At
the CMP_STEP parameter, specify the step number of the mask that is used for the
comparison. All programmed values are compared in the same manner. Unprogrammed input
bits or unprogrammed bits of the mask have a default signal state of FALSE.
If a match is found in the comparison, the signal state of the OUT parameter is set to "1".
Otherwise the OUT parameter is set to "0".
If the value of CMP_STEP parameter is greater than 15, the instruction is not executed. An
error message is output at the ERR_CODE parameter.
When you insert the instruction in the program, the "Call options" dialog opens in which you
can specify whether the instruction data will be stored in its own data block (single instance)
or as a local tag (multiple instance) in the block interface. If you create a separate data block,
you will find this in the project tree in the "Program resources" folder under "Program blocks
> System blocks". For additional information on this topic, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1894 System Manual, 01/2013,
Parameters
The following table shows the parameters of the "Compare input bits with the bits of a mask"
instruction:
Param
eters
Decla
ration
Data type Memory area Description
S7-1200 S7-1500
EN Input BOOL I, Q, M, D, L I, Q, M, D, L, T, C Enable input
ENO Outpu
t
BOOL I, Q, M, D, L I, Q, M, D, L Enable output
IN_BIT
0
Input BOOL I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
Input bit 0 to be
compared with bit 0 of
the mask.
IN_BIT
1
Input BOOL I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
Input bit 1 to be
compared with bit 1 of
the mask.
IN_BIT
2
Input BOOL I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
Input bit 2 to be
compared with bit 2 of
the mask.
IN_BIT
3
Input BOOL I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
Input bit 3 to be
compared with bit 3 of
the mask.
IN_BIT
4
Input BOOL I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
Input bit 4 to be
compared with bit 4 of
the mask.
IN_BIT
5
Input BOOL I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
Input bit 5 to be
compared with bit 5 of
the mask.
IN_BIT
6
Input BOOL I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
Input bit 6 to be
compared with bit 6 of
the mask.
IN_BIT
7
Input BOOL I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
Input bit 7 to be
compared with bit 7 of
the mask.
IN_BIT
8
Input BOOL I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
Input bit 8 to be
compared with bit 8 of
the mask.
IN_BIT
9
Input BOOL I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
Input bit 9 to be
compared with bit 9 of
the mask.
IN_BIT
10
Input BOOL I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
Input bit 10 to be
compared with bit 10
of the mask.
IN_BIT
11
Input BOOL I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
Input bit 11 to be
compared with bit 11
of the mask.
IN_BIT
12
Input BOOL I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
Input bit 12 to be
compared with bit 12
of the mask.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1895
Param
eters
Decla
ration
Data type Memory area Description
S7-1200 S7-1500
IN_BIT
13
Input BOOL I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
Input bit 13 to be
compared with bit 13
of the mask.
IN_BIT
14
Input BOOL I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
Input bit 14 to be
compared with bit 14
of the mask.
IN_BIT
15
Input BOOL I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
Input bit 15 to be
compared with bit 15
of the mask.
CMP_
STEP
Input BYTE I, Q, M, D, L, P or
constant
I, Q, M, D, L, P or
constant
The step number of
the mask used for the
comparison.
OUT Outpu
t
BOOL I, Q, M, D, L I, Q, M, D, L A signal state of "1"
indicates that a match
was found.
A signal state of "0"
indicates that no
match was found.
ERR_
CODE
Outpu
t
WORD I, Q, M, D, L, P I, Q, M, D, L, P Error information
CMP_
VAL
Static ARRAY
OF
WORD
I, Q, M, D, L I, Q, M, D, L Comparison masks [0
to 15, 0 to 15]: The first
number of the index is
the step number and
the second number is
the bit number of the
mask.
For additional information on valid data types, refer to "See also".
Parameters ERR_CODE
The following table shows the meaning of the values of the ERR_CODE parameter:
Error code*
(W#16#...)
Explanation
0000 No error
000A The value at the CMP_STEP parameter is greater than 15.
*The error codes can be displayed as integer or hexadecimal value in the program editor. For additional information on
toggling display formats, refer to "See also".
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1896 System Manual, 01/2013,
SMC: Compare scan matrix
Description
The instruction "Compare scan matrix" is used to compare the signal state of up to 16
programmed input bits (IN_BIT0 to IN_BIT15) with the corresponding bits of the comparison
masks for each step. Processing starts at step 1 and is continued until the last programmed
step (LAST), or until a match is found. The input bit of the IN_BIT0 parameter is compared
with the value of the mask CMP_VAL[x,0], with "x" indicating the step number. All programmed
values are compared in the same manner. If a match is found, the signal state of the OUT
parameter is set to "1" and the step number with the matching mask is written to the OUT_STEP
parameter. Unprogrammed input bits or unprogrammed bits of the mask have a default signal
state "FALSE". If more than one step has a matching mask, only the first one found is indicated
in the OUT_STEP parameter. If no match is found, the signal state of the OUT parameter is
set to "0". In this case the value at the OUT_STEP parameter is greater by "1" than the value
at the LAST parameter.
When you insert the instruction in the program, the "Call options" dialog opens in which you
can specify whether the instruction data will be stored in its own data block (single instance)
or as a local tag (multiple instance) in the block interface. If you create a separate data block,
you will find this in the project tree in the "Program resources" folder under "Program blocks
> System blocks". For additional information on this topic, refer to "See also".
Parameters
The following table shows the parameters of the "Compare scan matrix" instruction:
Param
eters
Decla
ration
Data type Memory area Description
S7-1200 S7-1500
EN Input BOOL I, Q, M, D, L I, Q, M, D, L, T, C Enable input
ENO Outpu
t
BOOL I, Q, M, D, L I, Q, M, D, L Enable output
IN_BIT
0
Input BOOL I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
Input bit 0 to be
compared with bit 0 of
the mask.
IN_BIT
1
Input BOOL I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
Input bit 1 to be
compared with bit 1 of
the mask.
IN_BIT
2
Input BOOL I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
Input bit 2 to be
compared with bit 2 of
the mask.
IN_BIT
3
Input BOOL I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
Input bit 3 to be
compared with bit 3 of
the mask.
IN_BIT
4
Input BOOL I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
Input bit 4 to be
compared with bit 4 of
the mask.
IN_BIT
5
Input BOOL I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
Input bit 5 to be
compared with bit 5 of
the mask.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1897
Param
eters
Decla
ration
Data type Memory area Description
S7-1200 S7-1500
IN_BIT
6
Input BOOL I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
Input bit 6 to be
compared with bit 6 of
the mask.
IN_BIT
7
Input BOOL I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
Input bit 7 to be
compared with bit 7 of
the mask.
IN_BIT
8
Input BOOL I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
Input bit 8 to be
compared with bit 8 of
the mask.
IN_BIT
9
Input BOOL I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
Input bit 9 to be
compared with bit 9 of
the mask.
IN_BIT
10
Input BOOL I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
Input bit 10 to be
compared with bit 10
of the mask.
IN_BIT
11
Input BOOL I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
Input bit 11 to be
compared with bit 11
of the mask.
IN_BIT
12
Input BOOL I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
Input bit 12 to be
compared with bit 12
of the mask.
IN_BIT
13
Input BOOL I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
Input bit 13 to be
compared with bit 13
of the mask.
IN_BIT
14
Input BOOL I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
Input bit 14 to be
compared with bit 14
of the mask.
IN_BIT
15
Input BOOL I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
Input bit 15 to be
compared with bit 15
of the mask.
OUT Outpu
t
BOOL I, Q, M, D, L I, Q, M, D, L A signal state of "1"
indicates that a match
was found.
A signal state of "0"
indicates that no
match was found.
ERR_
CODE
Outpu
t
WORD I, Q, M, D, L, P I, Q, M, D, L, P Error information
OUT_
STEP
Outpu
t
BYTE I, Q, M, D, L, P I, Q, M, D, L, P Contains the step
number with the
matching mask, or the
step number which is
greater by "1" than the
value at the LAST
parameter, provided
no match is found.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1898 System Manual, 01/2013,
Param
eters
Decla
ration
Data type Memory area Description
S7-1200 S7-1500
LAST Static BYTE I, Q, M, D, L, P I, Q, M, D, L, P Specifies the step
number of the last step
to be scanned for a
matching mask.
CMP_
VAL
Static ARRAY
OF
WORD
I, Q, M, D, L I, Q, M, D, L Comparison masks [0
to 15, 0 to 15]: The first
number of the index is
the step number and
the second number is
the bit number of the
mask.
For additional information on valid data types, refer to "See also".
Parameters ERR_CODE
The following table shows the meaning of the values of the ERR_CODE parameter:
Error code*
(W#16#...)
Explanation
0000 No error
000E The value at the LAST parameter is greater than 15.
*The error codes can be displayed as integer or hexadecimal value in the program editor. For additional information on
toggling display formats, refer to "See also".
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
LEAD_LAG: Lead and lag algorithm
Description
The "Lead and lag algorithm" instruction is used to process signals with an analog tag. The
gain value (GAIN) must be greater than zero. The result of the instruction "Lead and lag
algorithm" is calculated using the following equation:
OUT =
LG_TlME
LG_TlME + SAMPLE_T
LD_TlME + SAMPLE_T
LG_TlME + SAMPLE_T
lN - GAlN PREV_OUT + GAlN
LD_TlME
LG_TlME + SAMPLE_T
When the value of the GAIN parameter is less than or equal to zero, the calculation is not
performed and an error information is output on the ERR_CODE parameter.
You can use the "Lead and lag algorithm" instruction in conjunction with loops as a
compensator in dynamic feed-forward control. The instruction consists of two operations. The
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1899
"Lead" operation shifts the phase of output OUT so that the output leads the input. The "Lag"
operation, on the other hand, shifts the output so that the output lags behind the input. Because
the "Lag" operation is equivalent to an integration, it can be used as a noise suppressor or as
a low-pass filter. The "Lead" operation is equivalent to a differentiation and can therefore be
used as a high-pass filter. The two instructions together (Lead and Lag) result in the output
phase lagging behind the the input at lower frequencies and leading it at higher frequencies.
This means that the "Lead and lag algorithm" instruction can be used as a band pass filter.
When you insert the instruction in the program, the "Call options" dialog opens in which you
can specify whether the instruction data will be stored in its own data block (single instance)
or as a local tag (multiple instance) in the block interface. If you create a separate data block,
you will find this in the project tree in the "Program resources" folder under "Program blocks
> System blocks". For additional information on this topic, refer to "See also".
Parameters
The following table shows the parameters of the "Lead and lag algorithm" instruction:
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500
EN Input BOOL I, Q, M, D, L I, Q, M, D, L, T,
C
Enable input
ENO Output BOOL I, Q, M, D, L I, Q, M, D, L Enable output
IN Input REAL I, Q, M, D, L, P
or constant
I, Q, M, D, L, P
or constant
The input
value of the
current sample
time (cycle
time) to be
processed.
SAMPLE_T Input INT I, Q, M, D, L, P
or constant
I, Q, M, D, L, P
or constant
Sample time
OUT Output REAL I, Q, M, D, L, P I, Q, M, D, L, P Result of the
instruction
ERR_CODE Output WORD I, Q, M, D, L, P I, Q, M, D, L, P Error
information
LD_TIME Static REAL I, Q, M, D, L, P
or constant
I, Q, M, D, L, P
or constant
Lead time in
the same unit
as sample
time.
LG_TIME Static REAL I, Q, M, D, L, P
or constant
I, Q, M, D, L, P
or constant
Lag time in the
same unit as
sample time
GAIN Static REAL I, Q, M, D, L, P
or constant
I, Q, M, D, L, P
or constant
Gain as % / %
(the ratio of the
change in
output to a
change in input
as a steady
state).
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1900 System Manual, 01/2013,
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500
PREV_IN Static REAL I, Q, M, D, L, P
or constant
I, Q, M, D, L, P
or constant
Previous input
PREV_OUT Static REAL I, Q, M, D, L, P
or constant
I, Q, M, D, L, P
or constant
Previous
output
For additional information on valid data types, refer to "See also".
Parameters ERR_CODE
The following table shows the meaning of the values of the ERR_CODE parameter:
Error code*
(W#16#...)
Explanation
0000 No error
0009 The value at the GAIN parameter is less than or equal to zero.
*The error codes can be displayed as integer or hexadecimal value in the program editor. For additional information on
toggling display formats, refer to "See also".
Example
The following example shows how the instruction works:
Note
You can initialize static parameters in the data block.
"LEAD_LAG_DB"
LEAD_LAG
EN
ENO
lN
OUT
ERR_CODE
SAMPLE_T
"Tag_lnput"
"Tag_lnput_SAMPLE_T"
"Tag_ErrorCode"
"Tag_Output_Result" "Tagln"
"TagOut"
The following table shows how the instruction works using specific operand values:
Before processing
In this example the following values are used for the input parameters:
Parameters Operand Value
IN Tag_Input 2.0
SAMPLE_T Tag_InputSampleTime 10
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1901
The following values are saved in the instance data block "LEAD_LAG_DB" of the instruction:
Parameters Address Value
LD_TIME DBD12 2.0
LG_TIME DBD16 2.0
GAIN DBD20 1.0
PREV_IN DBD24 6.0
PREV_OUT DBD28 6.0
After processing
The following values are written to the output parameters after the instruction has been
executed:
Parameters Operand Value
OUT Tag_Output_Result 2.0
The following values are saved in the instance data block "LEAD_LAD_DB" of the instruction:
Parameters Operand Value
PREV_IN DBD24 2.0
PREV_OUT DBD28 2.0
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
SEG: Create bit pattern for seven-segment display
Description
The instruction "Create bit pattern for seven-segment display" is used to convert each of the
four hexadecimal digits of the specified source word (IN) into an equivalent bit pattern for a
seven-segment display. The result of the instruction is output in the double word on the OUT
parameter.
The following relation exists between the hexadecimal digits and the assignment of the 7
segments (a, b, c, d, e, f, g):
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1902 System Manual, 01/2013,
Input digit
(Binary)
Assignment of
the segments
g f e d c b a
Display
(Hexadecimal)
Seven-segment display
0000 00111111 0
0001 00000110 1
0010 01011011 2
0011 01001111 3
0100 01100110 4
0101 01101101 5
0110 01111101 6
0111 00000111 7
1000 01111111 8
1001 01100111 9
1010 01110111 A
1011 01111100 B
1100 00111001 C
1101 01011110 D
1110 01111001 E
1111 01110001 F
Parameters
The following table shows the parameters of the "Create bit pattern for seven-segment display"
instruction:
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500
EN Input BOOL I, Q, M, D, L I, Q, M, D, L, T,
C
Enable input
ENO Output BOOL I, Q, M, D, L I, Q, M, D, L Enable output
IN Input WORD I, Q, M, D, L, P
or constant
I, Q, M, D, L, P
or constant
Source word
with four
hexadecimal
digits
OUT Output DWORD I, Q, M, D, L, P I, Q, M, D, L, P Bit pattern for
the seven-
segment
display
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1903
Example
The following example shows how the instruction works:
SEG
EN
ENO
OUT
lN
"Tagln"
"TagOut" "Tag_lnput"
"Tag_Output"
The following table shows how the instruction functions using specific values:
Parameters Operand Value
Hexadecimal Binary
IN Tag_Input W#16#1234 0001 0010 0011 0100
OUT Tag_Output DW#16065B4F66 00000110 01011011 01001111
01100110
Display: 1234
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
BCDCPL: Create tens complement
Description
The "Create tens complement" instruction is used to create the tens complement of a seven-
digit BCD number specified on the IN parameter. This instruction uses the following
mathematical formula to calculate:
10000000 (as BCD)
7-digit BCD value
----------------------------------------
Tens complement (as BCD)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1904 System Manual, 01/2013,
Parameters
The following table shows the parameters of the "Create tens complement" instruction:
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500
EN Input BOOL I, Q, M, D, L I, Q, M, D, L, T,
C
Enable input
ENO Output BOOL I, Q, M, D, L I, Q, M, D, L Enable output
IN Input DWORD I, Q, M, D, L, P
or constant
I, Q, M, D, L, P
or constant
7-digit BCD
number
ERR_CODE Output DWORD I, Q, M, D, L, P I, Q, M, D, L, P Result of the
instruction
Example
The following example shows how the instruction works:
EN
ENO lN
ERR_CODE
"Tag_lnput"
"Tag_Output" "Tagln"
"TagOut"
BCDCPL
The following table shows how the instruction functions using specific values:
Parameters Operand Value*
IN Tag_Input DW#16#01234567
ERR_CODE Tag_Output DW#16#08765433
*The error codes can be displayed as integer or hexadecimal value in the program editor. For additional
information on toggling display formats, refer to "See also".
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
BITSUM: Count number of set bits
Description
The "Count number of set bits" instruction is used to count the number of bits of an operand
that is set to the signal state "1". The operand whose bits are to be counted is specified on the
IN parameter. The result of the instruction is output at the RET_VAL parameter.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1905
Parameters
The following table shows the parameters of the "Count number of set bits" instruction:
Parameters Declaration Data type Memory area Description
S7-1200 S7-1500
EN Input BOOL I, Q, M, D, L I, Q, M, D, L, T,
C
Enable input
ENO Output BOOL I, Q, M, D, L I, Q, M, D, L Enable output
IN Input DWORD I, Q, M, D, L, P
or constant
I, Q, M, D, L, P
or constant
Operand
whose set bits
are counted.
RET_VAL Output INT I, Q, M, D, L, P I, Q, M, D, L, P Number of bits
to be set
Example
The following example shows how the instruction works:
BlTSUM
EN
ENO lN
RET_VAL
"Tag_lnput"
"Tag_Output" "Tagln"
"TagOut"
The following table shows how the instruction functions using specific values:
Parameters Operand Value*
IN Tag_Input DW#16#12345678
RET_VAL Tag_Output W#16#000D (13 Bits)
*The error codes can be displayed as integer or hexadecimal value in the program editor. For additional
information on toggling display formats, refer to "See also".
See also
Overview of the valid data types (Page 899)
Basics of the EN/ENO mechanism (Page 987)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1906 System Manual, 01/2013,
9.8.2.3 SCL
Bit logic operations
R_TRIG: Set tag on positive signal edge
Description
You can use the "Set tag on positive signal edge" instruction to set a specified tag in the
instance DB when there is a "0" to "1" change in the result of logic operation (RLO). The
instruction compares the current RLO at the input CLK with the RLO from the previous query,
which is saved in the specified instance DB. If the instruction detects a change in the result of
logic operation (RLO) from "0" to "1", there is a positive, rising edge.
If a positive edge is detected, the tag in the instance DB is set to signal state "1" and the output
Q returns the signal state "1" In all other cases, the signal state at the output of the instruction
is "0".
When you insert the instruction in the program, the "Call options" dialog opens automatically.
In this dialog you can specify whether the edge memory bit is stored in its own data block
(single instance) or as a local tag (multiple instance) in the block interface. If you create a
separate data block, you will find it in the project tree in the "Program resources" folder under
"Program blocks > System blocks". For additional information on this topic, refer to "See also".
Syntax
Use the following syntax for the "Set tag on positive signal edge" instruction:
SCL
<Instance_DB>(CLK := <Operand>,
Q => <Operand>)
The syntax of the instruction consists of the following parts:
Parameter Declaration Data type Memory area Description
CLK Input BOOL I, Q, M, D, L Incoming signal
whose edge will
be queried.
Q Output BOOL I, Q, M, D, L Result of edge
evaluation
Example
The following example shows how the instruction works:
SCL
"R_TRIG_DB" := CLK := "TagIn",
Q := "TagOut";
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1907
The RLO of the preceding query is saved in the instance DB "R_TRIG_DB". If a change in the
signal state of the RLO from "0" to "1" is detected in the operand "TagIn", the output "TagOut"
has signal state "1".
See also
Overview of the valid data types (Page 899)
Expressions (Page 1156)
Operators and operator precedence (Page 1161)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
F_TRIG: Set tag on negative signal edge
Description
You can use the "Set tag on negative signal edge" instruction to set a specified tag in the
instance DB when there is a "1" to "0" change in the result of logic operation (RLO). The
instruction compares the current RLO at the input CLK with the RLO from the previous query,
which is saved in the specified instance DB. If the instruction detects a change in the result of
logic operation (RLO) from "1" to "0", there is a negative, falling edge.
If a negative edge is detected, the tag in the instance DB is set to signal state "1" and the output
Q returns the signal state "1" In all other cases, the signal state at the output of the instruction
is "0".
When you insert the instruction in the program, the "Call options" dialog opens automatically.
In this dialog you can specify whether the edge memory bit is stored in its own data block
(single instance) or as a local tag (multiple instance) in the block interface. If you create a
separate data block, you will find it in the project tree in the "Program resources" folder under
"Program blocks > System blocks". For additional information on this topic, refer to "See also".
Syntax
Use the following syntax for the "Set tag on negative signal edge" instruction:
SCL
<Instance_DB>(CLK := <Operand>,
Q => <Operand>)
The syntax of the instruction consists of the following parts:
Parameter Declaration Data type Memory area Description
CLK Input BOOL I, Q, M, D, L Incoming signal
whose edge will
be queried.
Q Output BOOL I, Q, M, D, L Result of edge
evaluation
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1908 System Manual, 01/2013,
Example
The following example shows how the instruction works:
SCL
"F_TRIG_DB" := CLK := "TagIn",
Q := "TagOut";
The RLO of the preceding query is saved in the instance DB "F_TRIG_DB". If a change in the
signal state of the RLO from "1" to "0" is detected in the operand "TagIn", the output "TagOut"
has signal state "1".
See also
Overview of the valid data types (Page 899)
Expressions (Page 1156)
Operators and operator precedence (Page 1161)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
Timer operations
IEC Timers
TP: Generate pulse
Description
You can use the "Generate pulse" instruction to set the Q parameter for the duration PT. The
instruction starts when the result of logic operation (RLO) of the IN parameter changes from
"0" to "1" (positive signal edge). The programmed time PT begins when the instruction starts.
The Q parameter is set for the time PT, regardless of the subsequent changes in the input
signal. Even when a new positive signal edge is detected, the signal state of the Q parameter
is not affected as long as the time duration PT is active.
The current time value can be queried in the ET parameter. The time value starts at T#0s and
ends when the value of the time duration PT is reached. When the time duration PT is reached
and the signal state at the IN parameter is "0", the ET parameter is reset.
Note
If the timer is not called in the program because it is skipped, for example, output ET returns
a constant value as soon as the timer has expired.
Each call of the "Generate pulse" instruction must be assigned to an IEC timer in which the
instruction data is stored.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1909
For S7-1200 CPU
An IEC Timer is a structure of the data type IEC_TIMER or TP_TIME that you can declare as
follows:
Declaration of a data block of system data type IEC_TIMER (for example, "MyIEC_TIMER")
Declaration as a local tag of the TP_TIME type in the "Static" section of a block (for example,
#MyTP_TIMER)
For S7-1500 CPU
An IEC timer is a structure of the data type IEC_TIMER, IEC_LTIMER, TP_TIME or TP_LTIME
that you can declare as follows:
Declaration of a data block of system data type IEC_TIMER or IEC_LTIMER (for example,
"MyIEC_TIMER")
Declaration as a local tag of the type TP_TIME or TP_LTIME in the "Static" section of a
block (for example #MyTP_TIMER)
When you insert the instruction in the program, the "Call options" dialog opens in which you
can specify whether the IEC timer is stored in its own data block (single instance) or as a local
tag (multiple instance) in the block interface. If you create a separate data block, you will find
it in the project tree in the "Program resources" folder under "Program blocks > System blocks".
For additional information on this topic, refer to "See also".
The instruction data is updated both when an instruction is called and also at each access to
the Q or ET outputs.
Syntax
Use the following syntax for the "Generate pulse" instruction:
Data block of system data type IEC_Timer (global DB):
SCL
<IEC_Timer_DB> TP(IN := <Operand>,
PT := <Operand>,
Q => <Operand>,
ET => <Operand>)
Local tag:
SCL
#myLocal_timer(IN := <Operand>,
PT := <Operand>,
Q => <Operand>,
ET => <Operand>)
The syntax of the instruction consists of the following parts:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1910 System Manual, 01/2013,
Parameter Declaration Data type Description
S7-1200 S7-1500
IN Input BOOL BOOL Start input
PT Input TIME TIME, LTIME Duration of the
pulse.
The value of the
PT parameter
must be positive.
Q Output BOOL BOOL Operand that is
set for the PT
duration.
ET Output TIME TIME, LTIME Current time value
For additional information on valid data types, refer to "See also".
Pulse diagram
The following figure shows the pulse diagram of the "Generate pulse" instruction:
Example
The following example shows how the instruction works:
SCL
"TP_DB".TP(IN := "Tag_Start",
PT := "Tag_PresetTime",
Q => "Tag_Status",
ET => "Tag_ElapsedTime");
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1911
When the signal state of the "Tag_Start" operand changes from "0" to "1", the time period
programmed for the PT parameter is started and the "Tag_Status" operand is set to "1". The
current time value is stored in the "Tag_ElapsedTime" operand.
See also
Overview of the valid data types (Page 899)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
TON: Generate on-delay
Description
You can use the "Generate on-delay" instruction to delay the setting of the Q parameter for
the programmed duration PT. The instruction starts when the result of logic operation (RLO)
of the IN parameter changes from "0" to "1" (positive signal edge). The programmed time PT
begins when the instruction starts. When the duration PT has expired, the Q parameter returns
signal state "1". The Q parameter remains set as long as the start input is still "1". If the signal
state of the IN parameter changes from "1" to "0", the parameter Q will be reset. The timer
function is restarted when a new positive signal edge is detected at the IN parameter.
The current time value can be queried in the ET parameter. The time value starts at T#0s and
ends when the value of the time duration PT is reached. The ET parameter is reset as soon
as the signal state of the IN parameter changes to "0".
Note
If the timer is not called in the program because it is skipped, for example, output ET returns
a constant value as soon as the timer has expired.
Each call of the "Generate on-delay" instruction must be assigned to an IEC timer in which the
instruction data is stored.
For S7-1200 CPU
An IEC Timer is a structure of the data type IEC_TIMER or TON_TIME that you can declare
as follows:
Declaration of a data block of system data type IEC_TIMER (for example, "MyIEC_TIMER")
Declaration as a local tag of the TON_TIME type in the "Static" section of a block (for
example, #MyTON_TIMER)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1912 System Manual, 01/2013,
For S7-1500 CPU
An IEC timer is a structure of the data type IEC_TIMER, IEC_LTIMER, TON_TIME or
TON_LTIME that you can declare as follows:
Declaration of a data block of system data type IEC_TIMER or IEC_LTIMER (for example,
"MyIEC_TIMER")
Declaration as a local tag of the type TON_TIME or TON_LTIME in the "Static" section of
a block (for example #MyTON_TIMER)
When you insert the instruction in the program, the "Call options" dialog opens in which you
can specify whether the IEC timer is stored in its own data block (single instance) or as a local
tag (multiple instance) in the block interface. If you create a separate data block, you will find
it in the project tree in the "Program resources" folder under "Program blocks > System blocks".
For additional information on this topic, refer to "See also".
The instruction data is updated both when an instruction is called and also at each access to
the Q or ET outputs.
Syntax
Use the following syntax for the "Generate on-delay" instruction:
Data block of system data type IEC_Timer (global DB):
SCL
<IEC_Timer_DB> TON(IN := <Operand>,
PT := <Operand>,
Q => <Operand>,
ET => <Operand>)
Local tag:
SCL
#myLocal_timer(IN := <Operand>,
PT := <Operand>,
Q => <Operand>,
ET => <Operand>)
The syntax of the instruction consists of the following parts:
Parameter Declaration Data type Description
S7-1200 S7-1500
IN Input BOOL BOOL Start input
PT Input TIME TIME, LTIME Duration of the on
delay.
The value of the
PT parameter
must be positive.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1913
Parameter Declaration Data type Description
S7-1200 S7-1500
Q Output BOOL BOOL Operand that is
set when the timer
PT expires.
ET Output TIME TIME, LTIME Current time value
For additional information on valid data types, refer to "See also".
Pulse diagram
The following figure shows the pulse diagram of the "Generate on-delay" instruction:
Example
The following example shows how the instruction works:
SCL
"TON_DB".TON(IN := "Tag_Start",
PT := "Tag_PresetTime",
Q => "Tag_Status",
ET => "Tag_ElapsedTime");
When the signal state of the "Tag_Start" operand changes from "0" to "1", the time programmed
for the PT parameter is started. After the end of the period the "Tag_Status" operand is set to
the signal state "1". The operand Tag_Status remains set to signal state "1" as long as the
operand Tag_Start has signal state "1". The current time value is stored in the operand
"Tag_ElapsedTime". When the signal state at the operand "Tag_Start" changes from "1" to
"0", the "Tag_Status" operand is reset.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1914 System Manual, 01/2013,
See also
Overview of the valid data types (Page 899)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
TOF: Generate off-delay
Description
You can use the "Generate off-delay" instruction to delay the resetting of the Q parameter for
the programmed duration PT. The Q parameter is set when the result of logic operation (RLO)
of the IN parameter changes from "0" to "1" (positive signal edge). When the signal state of
the IN parameter changes back to "0", the programmed time PT starts. The Q parameter
remains set as long the time duration PT is running. When the time PT expires, the Q parameter
is reset. If the signal state of the IN parameter changes to "1" before the time duration PT has
expired, the timer is reset. The signal state of the Q parameter remains set to "1".
The current time value can be queried in the ET parameter. The time value starts at T#0s and
ends when the value of the time duration PT is reached. When the time duration PT expires,
the ET parameter remains set to the current value until the IN parameter changes back to "1".
If the IN parameter changes to "1" before the time PT has expired, the ET parameter is reset
to the value T#0s.
Note
If the timer is not called in the program because it is skipped, for example, output ET returns
a constant value as soon as the timer has expired.
Each call of the "Generate off-delay" instruction must be assigned to an IEC timer in which the
instruction data is stored.
For S7-1200 CPU
An IEC Timer is a structure of the data type IEC_TIMER or TOF_TIME that you can declare
as follows:
Declaration of a data block of system data type IEC_TIMER (for example, "MyIEC_TIMER")
Declaration as a local tag of the TOF_TIME type in the "Static" section of a block (for
example, #MyTOF_TIMER)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1915
For S7-1500 CPU
An IEC timer is a structure of the data type IEC_TIMER, IEC_LTIMER, TOF_TIME or
TOF_LTIME that you can declare as follows:
Declaration of a data block of system data type IEC_TIMER or IEC_LTIMER (for example,
"MyIEC_TIMER")
Declaration as a local tag of the type TOF_TIME or TOF_LTIME in the "Static" section of
a block (for example #MyTOF_TIMER)
When you insert the instruction in the program, the "Call options" dialog opens in which you
can specify whether the IEC timer is stored in its own data block (single instance) or as a local
tag (multiple instance) in the block interface. If you create a separate data block, you will find
it in the project tree in the "Program resources" folder under "Program blocks > System blocks".
For additional information on this topic, refer to "See also".
The instruction data is updated both when an instruction is called and also at each access to
the Q or ET outputs.
Syntax
Use the following syntax for the "Generate off-delay" instruction:
Data block of system data type IEC_Timer (global DB):
SCL
<IEC_Timer_DB> TOF(IN := <Operand>,
PT := <Operand>,
Q => <Operand>,
ET => <Operand>)
Local tag:
SCL
#myLocal_timer(IN := <Operand>,
PT := <Operand>,
Q => <Operand>,
ET => <Operand>)
The syntax of the instruction consists of the following parts:
Parameter Declaration Data type Description
S7-1200 S7-1500
IN Input BOOL BOOL Start input
PT Input TIME TIME, LTIME Duration of the off
delay.
The value of the
PT parameter
must be positive.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1916 System Manual, 01/2013,
Parameter Declaration Data type Description
S7-1200 S7-1500
Q Output BOOL BOOL Operand that is
reset when the
time PT expires.
ET Output TIME TIME, LTIME Current time value
For additional information on valid data types, refer to "See also".
Pulse diagram
The following figure shows the pulse diagram of the instruction "Generate off-delay":
Example
The following example shows how the instruction works:
SCL
"TOF_DB".TOF(IN := "Tag_Start",
PT := "Tag_PresetTime",
Q => "Tag_Status",
ET => "Tag_ElapsedTime");
With a change in the signal state of the "Tag_Start" operand from "0" to "1", the "Tag_Status"
operand is set. When the signal state of the "Tag_Start" operand changes from "1" to "0", the
time programmed for the PT parameter is started. As long as the time is running, the
"Tag_Status" operand remains set. When the time has expired, the "Tag_Status" operand is
reset. The current time value is stored in the operand "Tag_ElapsedTime".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1917
See also
Overview of the valid data types (Page 899)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
TONR: Time accumulator
Description
The "Time accumulator" instruction is used to accumulate time values within a period set by
the PT parameter. When the signal state of the IN parameter changes to "1", the instruction
executes and the time duration PT starts. While the time duration PT is running, the time values
that are recorded when the IN parameter has signal state "1" are accumulated. The
accumulated time is output in the ET parameter and can be queried there. When the time
duration PT is reached, the Q parameter has signal state "1". The Q parameter remains set
to "1", even when the signal state at the IN parameter changes to "0".
The R parameter resets the ET and Q parameters regardless of the signal state at the IN
parameter.
Each call of the "Time accumulator" instruction must be assigned to an IEC timer in which the
instruction data is stored.
For S7-1200 CPU
An IEC Timer is a structure of the data type IEC_TIMER or TONR_TIME that you can declare
as follows:
Declaration of a data block of system data type IEC_TIMER (for example, "MyIEC_TIMER")
Declaration as a local tag of the TONR_TIME type in the "Static" section of a block (for
example, #MyTONR_TIMER)
For S7-1500 CPU
An IEC timer is a structure of the data type IEC_TIMER, IEC_LTIMER, TONR_TIME or
TONR_LTIME that you can declare as follows:
Declaration of a data block of system data type IEC_TIMER or IEC_LTIMER (for example,
"MyIEC_TIMER")
Declaration as a local tag of the type TONR_TIME or TONR_LTIME in the "Static" section
of a block (for example #MyTONR_TIMER)
When you insert the instruction in the program, the "Call options" dialog opens in which you
can specify whether the IEC timer is stored in its own data block (single instance) or as a local
tag (multiple instance) in the block interface. If you create a separate data block, you will find
it in the project tree in the "Program resources" folder under "Program blocks > System blocks".
For additional information on this topic, refer to "See also".
The instruction data is updated both when an instruction is called and also at each access to
the Q or ET outputs.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1918 System Manual, 01/2013,
Syntax
Use the following syntax for the "Time accumulator" instruction:
Data block of system data type IEC_Timer (global DB):
SCL
<IEC_Timer_DB> TONR(IN := <Operand>,
R := <Operand>,
PT := <Operand>,
Q => <Operand>,
ET => <Operand>)
Local tag:
SCL
#myLocal_timer(IN := <Operand>,
R := <Operand>,
PT := <Operand>,
Q => <Operand>,
ET => <Operand>)
The syntax of the instruction consists of the following parts:
Parameter Declaration Data type Description
S7-1200 S7-1500
IN Input BOOL BOOL Start input
R Input BOOL BOOL Reset of the ET
and Q parameters
PT Input TIME TIME, LTIME Maximum
duration of time
recording.
The value of the
PT parameter
must be positive.
Q Output BOOL BOOL Operand that
remains set when
the timer PT has
expired.
ET Output TIME TIME, LTIME Accumulated time
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1919
Pulse diagram
The following figure shows the pulse diagram of the "Time accumulator" instruction:
Example
The following example shows how the instruction works:
SCL
"TONR_DB".TONR(IN := "Tag_Start",
R := "Tag_Reset",
PT := "Tag_PresetTime",
Q => "Tag_Status",
ET => "Tag_Time");
When the signal state of the "Tag_Start" operand changes from "0" to "1", the time programmed
for the PT parameter is started. While the timer is running, the timer values that are recorded
at signal state "1" of the operand "Tag_Start" is accumulated. The accumulated times is stored
in the "Tag_Time" operand. When the timer value displayed at the PT parameter is reached,
the "Tag_Status" operand is set to the signal state "1". The current time value is stored in the
operand "Tag_Time".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1920 System Manual, 01/2013,
See also
Overview of the valid data types (Page 899)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
RESET_TIMER: Reset timer
Description
You can use the "Reset timer" instruction to reset an IEC timer to "0". The instruction is only
executed if the result of logic operation (RLO) at the input of the coil is "1". If current is flowing
to the coil (RLO is "1"), the structure components of the timer in the specified data block are
reset to "0". If the RLO at the input of the instruction is "0", the timer remains unchanged.
The instruction does not influence the RLO. The RLO at the input of the coil is sent directly to
the output of the coil.
You assign the "Reset timer" instruction an IEC timer that has been declared in the program.
The instruction data is updated only when the instruction is called and not each time the
assigned IEC timer is accessed. Querying the data is only identical from the call of the
instruction to the next call of the instruction.
Syntax
Use the following syntax for the "Reset timer" instruction:
SCL
<Instance_DB>.RESET_TIMER
Parameters
The following table shows the parameters of the "Reset timer" instruction":
Parameter Declaration Data type Memory area Description
<IEC timer> Output IEC_TIMER,
IEC_LTIMER,
TP_TIME,
TP_LTIME,
TON_TIME,
TON_LTIME,
TOF_TIME,
TOF_LTIME,
TONR_TIME,
TONR_LTIME
D, L IEC timer that is
reset.
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1921
Example
The following example shows how the instruction works:
SCL
"TON_DB".TON(IN := "Tag_Start",
PT := "Tag_PresetTime",
Q => "Tag_Status",
ET => "Tag_ElapsedTime");
"TON_DB".RESET_TIMER (IN := "Tag_Input_1",
IN := "Tag_Input_2");
The instruction "Generate on-delay" is executed on a rising signal edge of the operand
"Tag_Start". The IEC timer stored in the instance data block "TON_DB" is started with the time
duration that is specified by the operand "Tag_PresetTime". The operand "Tag_Status" is set
if the duration PT specified by the operand "Tag_PresetTIME" has expired. The parameter Q
remains set as long as the operand "Tag_Start" has the signal state "1". When the signal state
on the start input changes from "1" to "0", the operand on the parameter Q is reset.
If operands "Tag_Input_2" and "Tag_Input_3" have the signal state "1", the "Reset timer"
instruction is executed and the timer stored in the "TON_DB" instance data block is reset.
See also
Overview of the valid data types (Page 899)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
PRESET_TIMER: Load time duration
Description
You can use the "Load time duration" instruction to set the time for an IEC timer. The instruction
is executed in every cycle when the result of logic operation (RLO) at the input of the instruction
has the signal state "1". The instruction writes the specified time to the structure of the specified
IEC timer.
Note
If the specified IEC timer is running while the instruction executes, the instruction overwrites
the current time of the specified IEC timer. This can change the timer status of the IEC timer.
You assign an IEC timer declared in the program to the "Load time duration" instruction.
The instruction data is updated only when the instruction is called and each time the assigned
IEC timer is accessed. The query on Q or ET (for example, "MyTimer".Q or "MyTimer".ET)
updates the IEC_TIMER structure.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1922 System Manual, 01/2013,
Syntax
Use the following syntax for the "Load time duration" instruction:
SCL
<Instance_DB>.PRESET_TIMER (PT := <Operand>)
Parameter
The following table shows the parameters of the "Load time duration" instruction:
Parameter Declaration Data type Memory area Description
<Time duration> Input TIME, LTIME I, Q, M, D, L or
constant
Duration with
which the IEC
timer runs.
<IEC timer> Output IEC_TIMER,
IEC_LTIMER,
TP_TIME,
TP_LTIME,
TON_TIME,
TON_LTIME,
TOF_TIME,
TOF_LTIME,
TONR_TIME,
TONR_LTIME
D, L IEC timer, the
duration of which
is set.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
SCL
"TON_DB".TON(IN := "Tag_Start",
PT := "Tag_PresetTIME",
Q => "Tag_Status",
ET => "Tag_ElapsedTime");
"TON_DB".PRESET_TIMER (IN := "Tag_Input_1",
IN := "Tag_Input_2",
PT := "Tag_PresetTIME_new");
The instruction "Generate on-delay" is executed on a rising signal edge of the operand
"Tag_Start". The IEC timer stored in the instance data block "TON_DB" is started with the time
duration that is specified by the operand "Tag_PresetTIME". The operand "Tag_Status" is set
if the duration PT specified by the operand "Tag_PresetTIME" has expired. The parameter Q
remains set as long as the operand "Tag_Start" has the signal state "1". When the signal state
on the start input changes from "1" to "0", the operand on the parameter Q is reset.
The "Load time duration" instruction is executed when the operand "Tag_Input_1" and the
operand "Tag_Input_2" have the signal state "1". The instruction writes the time duration
"Tag_PresetTIME_new" in the instance data block "TON_DB", thereby overwriting the time
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1923
value of the operand "Tag_PresetTIME" within the instance data block. The signal state of the
timer status may therefore change at the next query or when "MyTimer".Q or "MyTimer".ET
are accessed.
See also
Overview of the valid data types (Page 899)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
SIMATIC Timers
S_PULSE: Assign pulse timer parameters and start
Description
The "Assign pulse timer parameters and start" instruction starts the time programmed in the
T_NO parameter when a change from "0" to "1" (positive signal edge) is detected in the result
of logic operation (RLO) of the S parameter. The timer runs for the programmed time (TV) as
long as the signal state of the S parameter is "1".
When the signal state of the S parameter changes to "0" before the programmed time has
expired, the timer is stopped and the "Q" parameter is reset to "0".
Internally, the time is made up of a time value and a time base and is programmed in the TV
parameter. When the instruction starts, the programmed time value counts down to zero. The
time base specifies the time increment by which the time value changes. The current time
value is provided at the parameter BI.
If the timer is running and the signal state at input R changes to "1" then the current time value
and the time base are also set to zero. If the timer is not running, the signal state "1" at the R
input has no effect.
Parameter Q returns signal state "1" as long as the timer is running and the signal state at
parameter S is "1". When the signal state of the S parameter changes to "0" before the
programmed time has expired, the Q parameter returns signal state "0". If the timer is reset
by parameter R or if the timer has expired then parameter Q also returns signal state "0".
The instruction data is updated with each access. It is therefore possible that the query of the
data at the start of the cycle returns different values from those at the end of the cycle.
Note
In each case, the instruction decrements a specific value by one unit in an interval that is
defined by its time basis until the time value is equal to "0". The decrementation takes place
asynchronous to the user program. The resulting timer is therefore always up to one time
interval shorter than the time base.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1924 System Manual, 01/2013,
Syntax
Use the following syntax for the "Assign pulse timer parameters and start" instruction:
SCL
S_PULSE(T_NO := <Operand>,
S := <Operand>,
TV := <Operand>,
R := <Operand>,
Q => <Operand>,
BI => <Operand>)
The syntax of the instruction consists of the following parts:
Parameter Declaration Data type Description
T_NO Input TIMER, INT The timer that is started.
The number of timers depends on the CPU.
S Input BOOL Start input
TV Input S5TIME,
WORD
Preset timer value
R Input BOOL Reset input
Q Output BOOL Status of the timer
BI Output WORD Current dual-coded time value
Function value S5TIME Current time value
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1925
Pulse diagram
The following figure shows the pulse diagram of the "Assign pulse timer parameters and start"
instruction:
RLO at input S
Timer running
Query "1"
Query "0"
RLO at input R
t = programmed time
t t t
Example
The following example shows how the instruction works:
SCL
"Tag_Result" := S_PULSE(T_NO := "Timer_1",
S := "Tag_1",
TV := "Tag_Number",
R := "Tag_Reset",
Q := "Tag_Status",
BI := "Tag_Value");
"Timer_1" starts when the signal state of the "Tag_1" operand changes from "0" to "1". The
timer counts down with the time value of the operand "Tag_Number" until operand "Tag_1"
returns signal state "1".
If the signal state at the S parameter changes to "0" before the programmed time has elapsed,
the "Tag_Status" operand is reset to "0". If the timer is reset by the R parameter or if the timer
has expired, the "Tag_Status" operand also returns signal state "0".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1926 System Manual, 01/2013,
The current time value is stored both dual-coded at the "Tag_Value" operand and returned as
a function value.
See also
Overview of the valid data types (Page 899)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
S_PEXT: Assign extended pulse timer parameters and start
Description
The "Assign extended pulse timer parameters and start" instruction starts a programmed timer
when a positive signal edge is detected at the S parameter. The timer runs for the programmed
time (TV) even if the signal state at the S parameter changes to "0". As long as the timer runs,
parameter Q returns the signal state "1".
When the timer has expired, parameter Q is reset to "0". If the signal state at the S parameter
changes from "0" to "1" while the timer is running, the timer is restarted with the time
programmed in the TV parameter.
Internally, the time is made up of a time value and a time base and is programmed in the TV
parameter. When the instruction starts, the programmed time value counts down to zero. The
time base specifies the time increment by which the time value changes. The current time
value is provided at the parameter BI.
If the timer is running and the signal state at parameter R changes to "1" then the current time
value and the time base are also set to zero. If the timer is not running then signal state "1" at
parameter R has no effect.
The instruction data is updated with each access. It is therefore possible that the query of the
data at the start of the cycle returns different values from those at the end of the cycle.
Note
In each case, the instruction decrements a specific value by one unit in an interval that is
defined by its time basis until the time value is equal to "0". The decrementation takes place
asynchronous to the user program. The resulting timer is therefore always up to one time
interval shorter than the time base.
Syntax
Use the following syntax for the "Assign extended pulse timer parameters and start" instruction:
SCL
S_PEXT(T_NO := <Operand>,
S := <Operand>,
TV := <Operand>,
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1927
SCL
R := <Operand>,
Q => <Operand>,
BI => <Operand>)
The syntax of the instruction consists of the following parts:
Parameter Declaration Data type Description
T_NO Input TIMER, INT The timer that is started.
The number of timers depends on the CPU.
S Input BOOL Start input
TV Input S5TIME,
WORD
Preset timer value
R Input BOOL Reset input
Q Output BOOL Status of the timer
BI Output WORD Current dual-coded time value
Function value S5TIME Current time value
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1928 System Manual, 01/2013,
Pulse diagram
The following figure shows the pulse diagram of the "Assign extended pulse timer parameters
and start" instruction:
RLO at input S
Time running
Query "1"
Query "0"
RLO at input R
t = programmed time
t t t t
Example
The following example shows how the instruction works:
SCL
"Tag_Result" := S_PEXT(T_NO := "Timer_1",
S := "Tag_1",
TV := "Tag_Number",
R := "Tag_Reset",
Q := "Tag_Status",
BI := "Tag_Value");
"Timer_1" starts when the signal state of the "Tag_1" operand changes from "0" to "1". As long
as the timer runs, operand "Tag_Status" returns the signal state "1". When the timer has
expired, operand "Tag_Status" is reset to "0". If the signal state at the S input changes from
"0" to "1" while the timer is running, the timer is restarted with the time "Tag_Number".
The current time value is stored both dual-coded at the "Tag_Value" operand and returned as
a function value.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1929
See also
Overview of the valid data types (Page 899)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
S_ODT: Assign on-delay timer parameters and start
Description
The "Assign on-delay timer parameters and start" instruction starts a programmed timer as on-
delay when a positive signal edge is detected at the S parameter. The timer runs for the
programmed time (TV) as long as the signal state of the S parameter is "1".
If the timer has expired correctly and parameter S still has signal state "1" then parameter Q
returns signal state "1". If the signal state at the S parameter changes from "1" to "0" while the
timer is running, the timer is stopped. In this case, output Q is reset to signal state "0".
Internally, the time is made up of a time value and a time base and is programmed in the TV
parameter. When the instruction starts, the programmed time value counts down to zero. The
time base specifies the time increment by which the time value changes. The current time
value is provided at the parameter BI.
If the time is running and the signal state at input R changes from "0" to "1" then the current
time value and the time base are also set to zero. In this case, the signal state at parameter
Q is "0". The timer is reset if the signal state at the R parameter is "1", even if the timer is not
running and the result of logic operation (RLO) at the S parameter is "1".
The instruction data is updated with each access. It is therefore possible that the query of the
data at the start of the cycle returns different values from those at the end of the cycle.
Note
In each case, the instruction decrements a specific value by one unit in an interval that is
defined by its time basis until the time value is equal to "0". The decrementation takes place
asynchronous to the user program. The resulting timer is therefore always up to one time
interval shorter than the time base.
Syntax
Use the following syntax for the "Assign on-delay timer parameters and start" instruction:
SCL
S_ODT(T_NO := <Operand>,
S := <Operand>,
TV := <Operand>,
R := <Operand>,
Q => <Operand>,
BI => <Operand>)
The syntax of the instruction consists of the following parts:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1930 System Manual, 01/2013,
Parameter Declaration Data type Description
T_NO Input TIMER, INT The timer that is started.
The number of timers depends on the CPU.
S Input BOOL Start input
TV Input S5TIME,
WORD
Preset timer value
R Input BOOL Reset input
Q Output BOOL Status of the timer
BI Output WORD Current dual-coded time value
Function value S5TIME Current time value
For additional information on valid data types, refer to "See also".
Pulse diagram
The following figure shows the pulse diagram of the "Assign on-delay timer parameters and
start" instruction:
RLO at input S
Timer running
Query "1"
Query "0"
RLO at input R
t = programmed time
t t t
Example
The following example shows how the instruction works:
SCL
"Tag_Result" := S_ODT(T_NO := "Timer_1",
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1931
SCL
S := "Tag_1",
TV := "Tag_Number",
R := "Tag_Reset",
Q := "Tag_Status",
BI := "Tag_Value");
"Timer_1" starts when the signal state of the "Tag_1" operand changes from "0" to "1". The
timer runs for the duration "Tag_Number" as long as the signal state of operand "Tag_1" is "1".
If the timer has expired correctly and operand "Tag_Status" has signal state "1" then operand
"Tag_Status" is reset to "1". If the signal state of the "Tag_1" operand changes from "1" to "0"
while the timer is running, the timer is stopped. In this case, operand "Tag_Status" returns
signal state "0".
The current time value is stored both dual-coded at the "Tag_Value" operand and returned as
a function value.
See also
Overview of the valid data types (Page 899)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
S_ODTS: Assign retentive on-delay timer parameters and start
Description
The "Assign retentive on-delay timer parameters and start" instruction starts a programmed
timer when a positive signal edge is detected at the S parameter. The timer runs for the
programmed time (TV) even if the signal state at the S parameter changes to "0".
If the timer has expired, the "Q" parameter returns signal state "1" regardless of the signal
state of the "S" parameter. If the signal state at the S parameter changes from "0" to "1" while
the timer is running, the timer is restarted with the programmed time TV.
Internally, the time is made up of a time value and a time base and is programmed in the TV
parameter. When the instruction starts, the programmed time value counts down to zero. The
time base specifies the time increment by which the time value changes. The current time
value is provided at the parameter BI.
Signal state "1" at parameterR resets the current time value and time base to "0", independent
of the signal state at parameter S. In this case, the signal state at parameter Q is "0".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1932 System Manual, 01/2013,
The instruction data is updated with each access. It is therefore possible that the query of the
data at the start of the cycle returns different values from those at the end of the cycle.
Note
In each case, the instruction decrements a specific value by one unit in an interval that is
defined by its time basis until the time value is equal to "0". The decrementation takes place
asynchronous to the user program. The resulting timer is therefore always up to one time
interval shorter than the time base.
Syntax
Use the following syntax for the "Assign retentive on-delay timer parameters and start"
instruction:
SCL
S_ODTS(T_NO := <Operand>,
S := <Operand>,
TV := <Operand>,
R := <Operand>,
Q => <Operand>,
BI =><Operand>)
The syntax of the instruction consists of the following parts:
Parameter Declaration Data type Description
T_NO Input TIMER, INT The timer that is started.
The number of timers depends on the CPU.
S Input BOOL Start input
TV Input S5TIME,
WORD
Preset timer value
R Input BOOL Reset input
Q Output BOOL Status of the timer
BI Output WORD Current dual-coded time value
Function value S5TIME Current time value
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1933
Pulse diagram
The following figure shows the pulse diagram of the "Assign retentive on-delay timer
parameters and start" instruction:
RLO at input S
Timer running
Query "1"
Query "0"
RLO at input R
t = programmed time
t t t t
Example
The following example shows how the instruction works:
SCL
"Tag_Result" := S_ODTS(T_NO := "Timer_1",
S := "Tag_1",
TV := "Tag_Number",
R := "Tag_Reset",
Q := "Tag_Status",
BI := "Tag_Value");
"Timer_1" starts when the signal state of the "Tag_1" operand changes from "0" to "1". The
timer runs for the duration "Tag_Number".
If the timer has expired, operand "Tag_Status" returns signal state "1" independent of the signal
state of operand "Tag_1". If the signal state of the "Tag_1" operand changes from "0" to "1"
while the timer is running, the timer is restarted with the time "Tag_Number".
The current time value is stored both dual-coded at the "Tag_Value" operand and returned as
a function value.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1934 System Manual, 01/2013,
See also
Overview of the valid data types (Page 899)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
S_OFFDT: Assign off-delay timer parameters and start
Description
The "Assign off-delay timer parameters and start" instruction starts a programmed timer when
a negative signal edge is detected at the S parameter. The timer runs for the programmed
time (TV). As long as the timer is running or parameter S returns signal state "1", then
parameter Q has signal state "1".
If the timer has expired and the signal state is "0" then parameter Q is reset to signal state "0".
If the signal state at parameter S changes from "0" to "1" while the timer is running, the timer
is stopped. The timer is only restarted after a falling signal edge is detected at parameter S.
Internally, the time is made up of a time value and a time base and is programmed in the TV
parameter. When the instruction starts, the programmed time value counts down to zero. The
time base specifies the time increment by which the time value changes. The current time
value is provided at the parameter BI.
Signal state "1" at parameter R resets the current time value and time base to "0". In this case,
the signal state at parameter Q is "0".
The instruction data is updated with each access. It is therefore possible that the query of the
data at the start of the cycle returns different values from those at the end of the cycle.
Note
In each case, the instruction decrements a specific value by one unit in an interval that is
defined by its time basis until the time value is equal to "0". The decrementation takes place
asynchronous to the user program. The resulting timer is therefore always up to one time
interval shorter than the time base.
Syntax
Use the following syntax for the "Assign off-delay timer parameters and start" instruction:
SCL
S_OFFDT(T_NO := <Operand>,
S := <Operand>,
TV := <Operand>,
R := <Operand>,
Q => <Operand>,
BI =><Operand>)
The syntax of the instruction consists of the following parts:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1935
Parameter Declaration Data type Description
T_NO Input TIMER, INT The timer that is started.
The number of timers depends on the CPU.
S Input BOOL Start input
TV Input S5TIME,
WORD
Preset timer value
R Input BOOL Reset input
Q Output BOOL Status of the timer
BI Output WORD Current dual-coded time value
Function value S5TIME Current time value
For additional information on valid data types, refer to "See also".
Pulse diagram
The following figure shows the pulse diagram of the "Assign off-delay timer parameters and
start" instruction:
RLO at input S
Time running
Query "1"
Query "0"
RLO at input R
t = programmed time
t t t t
Example
The following example shows how the instruction works:
SCL
"Tag_Result" := S_OFFDT(T_NO := "Timer_1",
S := "Tag_1",
TV := "Tag_Number",
R := "Tag_Reset",
Q := "Tag_Status",
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1936 System Manual, 01/2013,
SCL
BI := "Tag_Value");
"Timer_1" starts when the signal state of the "Tag_1" operand changes from "0" to "1". The
timer runs for the duration "Tag_Number". As long as the timer is running or operand "Tag_1"
returns signal state "1", then operand "Tag_Status" has signal state "1".
If the timer has expired and the signal state of operand "Tag_1" is "0" then operand
"Tag_Status" is reset to signal state "0". If the signal state of the "Tag_1" operand changes
from "0" to "1" while the timer is running, the timer is reset. The timer is only restarted after a
falling edge is detected at parameter S.
The current time value is stored both dual-coded at the "Tag_Value" operand and returned as
a function value.
See also
Overview of the valid data types (Page 899)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
Counter operations
IEC Counters
CTU: Count up
Description
You can use the "Count up" instruction to increment the value at the CV parameter. When the
signal state of the CU parameter changes from "0" to "1" (positive signal edge), the instruction
is executed and the current counter value of the CV parameter is incremented by one. When
the instruction is executed for the first time the the current count of the CV parameter is set to
zero. The counter value is incremented each time a positive signal edge is detected, until it
reaches the high limit of the data type specified for the CV parameter. When the high limit is
reached, the signal state of the CU parameter no longer has an effect on the instruction.
You can query the count status of the Q parameter. The signal state of the Q parameter is
determined by the PV parameter. When the current counter value is greater than or equal to
the value of the PV parameter, the Q parameter is set to signal state "1". In all other cases,
the signal state of the Q parameter is "0". You can also specify a constant for the PV parameter.
The value of the CV parameter is reset to zero when the signal state at the R parameter
changes to "1". As long as the signal state of the R parameter is "1", the signal state of the CU
parameter has no effect on the instruction.
Note
Only use a counter at a single location in the program to avoid risk of counting errors.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1937
Each call of the "Count up" instruction must be assigned an IEC counter in which the instruction
data is stored. An IEC counter is a structure with one of the following data types:
For S7-1200 CPU
Data block of system data type IEC_counter
(global DB)
Local tag
IEC_SCOUNTER / IEC_USCOUNTER
IEC_COUNTER / IEC_UCOUNTER
IEC_DCOUNTER / IEC_UDCOUNTER
CTU_SINT / CTU_USINT
CTU_INT / CTU_UINT
CTU_DINT / CTU_UDINT
For S7-1500 CPU
Data block of system data type IEC_counter
(global DB)
Local tag
IEC_SCOUNTER / IEC_USCOUNTER
IEC_COUNTER / IEC_UCOUNTER
IEC_DCOUNTER / IEC_UDCOUNTER
IEC_LCOUNTER / IEC_ULCOUNTER
CTU_SINT / CTU_USINT
CTU_INT / CTU_UINT
CTU_DINT / CTU_UDINT
CTU_LINT / CTU_ULINT
You can declare an IEC counter as follows:
Declaration of a data block of system data type IEC_COUNTER (for example,
"MyIEC_COUNTER")
Declaration as a local tag of the CTU type in the "Static" section of a block (for example,
#MyCTU_COUNTER)
When you insert the instruction in the program, the "Call options" dialog opens in which you
can specify whether the IEC counter is stored in its own data block (single instance) or as a
local tag (multiple instance) in the block interface. If you create a separate data block, you will
find it in the project tree in the "Program resources" folder under "Program blocks > System
blocks". For additional information on this topic, refer to "See also".
Syntax
The following syntax is used for the "Count up" instruction:
Table 9-28 Data block of system data type IEC_counter (global DB)
SCL
<IEC_Counter_DB>.CTU(CU := <Operand>,
R := <Operand>,
PV := <Operand>,
Q => <Operand>,
CV => <Operand>)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1938 System Manual, 01/2013,
Table 9-29 Local tag
SCL
#myLocal_counter(CU := <Operand>,
R := <Operand>,
PV := <Operand>,
Q => <Operand>,
CV => <Operand>)
The syntax of the instruction consists of the following parts:
Parameter Declaration Data type Description
CU Input BOOL Count input
R Input BOOL Reset input
PV Input Integers Value at which the
output Q is set
Q Output BOOL Counter status
CV Output Integers, CHAR, DATE Current counter value
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
SCL
"IEC_COUNTER_DB".CTU(CU := "Tag_Start",
R := "Tag_Reset",
PV := "Tag_PresetValue",
Q => "Tag_Status",
CV => "Tag_CounterValue");
When the signal state of the "Tag_Start" operand changes from "0" to "1", the "Count up"
instruction executes and the current counter value of the "Tag_CounterValue" operand is
incremented by one. With each additional positive signal edge, the counter value is
incremented until the high limit value of the specified data type (INT = 32767) is reached.
The "Tag_Status" output has signal state "1" as long as the current counter value is greater
than or equal to the value of the "Tag_PresetValue" operand. In all other cases, the
"Tag_Status" output has signal state "0". The current counter value is stored in the
"Tag_CounterValue" operand.
See also
Overview of the valid data types (Page 899)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1939
CTD: Count down
Description
The "Count down" instruction is used to decrement the value at the parameter CV. When the
signal state of the CD parameter changes from "0" to "1" (positive signal edge), the instruction
is executed and the current counter value of the CV parameter is decremented by one. When
the instruction is executed the first time, the counter value of the CV parameter will be set to
the value of the PV parameter. Each time a positive signal edge is detected, the counter is
decremented until it reaches the low limit value of the specified data type. When the low limit
is reached, the signal state of the CD parameter no longer has an effect on the instruction.
You can query the count status of the Q parameter. If the current counter value is less than or
equal to zero, the Q parameter is set to signal state "1". In all other cases, the signal state of
the Q parameter is "0". You can also specify a constant for the PV parameter.
The value of the CV parameter is set to the value of the PV parameter when the signal state
of the LD parameter changes to "1". As long as the signal state of the LD parameter is "1", the
signal state of the CD parameter has no effect on the instruction.
Note
Only use a counter at a single location in the program to avoid risk of counting errors.
Each call of the "Count down" instruction must be assigned an IEC counter in which the
instruction data is stored. An IEC counter is a structure with one of the following data types:
For S7-1200 CPU
Data block of system data type IEC_counter
(global DB)
Local tag
IEC_SCOUNTER / IEC_USCOUNTER
IEC_COUNTER / IEC_UCOUNTER
IEC_DCOUNTER / IEC_UDCOUNTER
CTD_SINT / CTD_USINT
CTD_INT / CTD_UINT
CTD_DINT / CTD_UDINT
For S7-1500 CPU
Data block of system data type IEC_counter
(global DB)
Local tag
IEC_SCOUNTER / IEC_USCOUNTER
IEC_COUNTER / IEC_UCOUNTER
IEC_DCOUNTER / IEC_UDCOUNTER
IEC_LCOUNTER / IEC_ULCOUNTER
CTD_SINT / CTD_USINT
CTD_INT / CTD_UINT
CTD_DINT / CTD_UDINT
CTD_LINT / CTD_ULINT
You can declare an IEC counter as follows:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1940 System Manual, 01/2013,
Declaration of a data block of system data type IEC_COUNTER (for example,
"MyIEC_COUNTER")
Declaration as a local tag of the CTD type in the "Static" section of a block (for example,
#MyCTD_COUNTER)
When you insert the instruction in the program, the "Call options" dialog opens in which you
can specify whether the IEC counter is stored in its own data block (single instance) or as a
local tag (multiple instance) in the block interface. If you create a separate data block, you will
find it in the project tree in the "Program resources" folder under "Program blocks > System
blocks". For additional information on this topic, refer to "See also".
Syntax
The following syntax is used for the "Count down" instruction:
Table 9-30 Data block of system data type IEC_counter (global DB)
SCL
<IEC_Counter_DB>.CTD(CD := <Operand>,
LD := <Operand>,
PV := <Operand>,
Q => <Operand>,
CV => <Operand>)
Table 9-31 Local tag
SCL
#myLocal_counter(CD := <Operand>,
LD := <Operand>,
PV := <Operand>,
Q => <Operand>,
CV => <Operand>)
The syntax of the instruction consists of the following parts:
Parameter Declaration Data type Description
CD Input BOOL Count input
LD Input BOOL Load input
PV Input Integers Value at which the
output Q is set
Q Output BOOL Counter status
CV Output Integers, CHAR, DATE Current counter value
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1941
Example
The following example shows how the instruction works:
SCL
"IEC_SCOUNTER_DB".CTD(CD := "Tag_Start",
LD := "Tag_Load",
PV := "Tag_PresetValue",
Q => "Tag_Status",
CV => "Tag_CounterValue");
When the signal state of the "Tag_Start" changes from "0" to "1", the "Count down" instruction
executes and the value of the "Tag_CounterValue" operand is decremented by one. With each
additional positive signal edge, the counter value is decremented until it reaches the low limit
of the specified data type (-128).
The operand "Tag_Status" has the signal state "1" as long as the current counter value is less
than or equal to zero. In all other cases, the "Tag_Status" output has signal state "0". The
current counter value is stored in the "Tag_CounterValue" operand.
See also
Overview of the valid data types (Page 899)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
CTUD: Count up and down
Description
Use the "Count up and down" instruction to increment or decrement the counter value at the
CV parameter. When the signal state of the CU parameter changes from "0" to "1" (positive
signal edge), the current counter value of the CV parameter is incremented by one. When the
signal state of the CD parameter changes from "0" to "1" (positive signal edge), the counter
value of the CV parameter is decremented by one. If there is a positive signal edge at the CU
and CD inputs in one program cycle, the current counter value of the CV parameter remains
unchanged.
The counter value can be incremented until it reaches the high limit value of the data type
specified for the CV parameter. When the high limit value is reached, the counter value is no
longer incremented on a positive signal edge. When the low limit value of the specified data
type is reached, the counter value is not decremented any further.
When the signal state of the LD parameter changes to "1", the counter value of the CV
parameter is set to the value of the PV parameter. As long as the LD parameter has the signal
state "1", the signal state of the CU and CD parameters has no effect on the instruction.
The counter value is set to zero when the signal state of the parameter R changes to "1". As
long as the parameter R has signal state "1", a change in the the signal state of the parameters
CU, CD and LD has no effect on the "Count up and down" instruction.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1942 System Manual, 01/2013,
You can scan the current status of the up counter based on the value of the QU parameter.
When the current counter value is greater than or equal to the value of the PV parameter, the
QU parameter is set to signal state "1". In all other cases, the signal state of the QU parameter
is "0". You can also specify a constant for the PV parameter.
You can scan the current status of the down counter based on the value of the QD parameter.
If the current counter value is less than or equal to zero, the QD parameter is set to signal state
"1". In all other cases, the signal state of the QD parameter is "0".
Note
Only use a counter at a single location in the program to avoid risk of counting errors.
Each call of the "Count up and down" instruction must be assigned an IEC counter in which
the instruction data is stored. An IEC counter is a structure with one of the following data types:
For S7-1200 CPU
Data block of system data type IEC_counter
(global DB)
Local tag
IEC_SCOUNTER / IEC_USCOUNTER
IEC_COUNTER / IEC_UCOUNTER
IEC_DCOUNTER / IEC_UDCOUNTER
CTUD_SINT / CTUD_USINT
CTUD_INT / CTUD_UINT
CTUD_DINT / CTUD_UDINT
For S7-1500 CPU
Data block of system data type IEC_counter
(global DB)
Local tag
IEC_SCOUNTER / IEC_USCOUNTER
IEC_COUNTER / IEC_UCOUNTER
IEC_DCOUNTER / IEC_UDCOUNTER
IEC_LCOUNTER / IEC_ULCOUNTER
CTUD_SINT / CTUD_USINT
CTUD_INT / CTUD_UINT
CTUD_DINT / CTUD_UDINT
CTUD_LINT / CTUD_ULINT
You can declare an IEC counter as follows:
Declaration of a data block of system data type IEC_COUNTER (for example,
"MyIEC_COUNTER")
Declaration as a local tag of the CTUD type in the "Static" section of a block (for example,
#MyCTUD_COUNTER)
When you insert the instruction in the program, the "Call options" dialog opens in which you
can specify whether the IEC counter is stored in its own data block (single instance) or as a
local tag (multiple instance) in the block interface. If you create a separate data block, you will
find it in the project tree in the "Program resources" folder under "Program blocks > System
blocks". For additional information on this topic, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1943
Syntax
The following syntax is used for the "Count up and down" instruction:
Table 9-32 Data block of system data type IEC_counter (global DB)
SCL
<IEC_Counter_DB>.CTUD(CU := <Operand>,
CD := <Operand>,
R := <Operand>,
LD := <Operand>,
PV := <Operand>,
QU=> <Operand>,
QD := <Operand>,
CV=> <Operand>)
Table 9-33 Local tag
SCL
myLocal_counter(CU := <Operand>,
CD := <Operand>,
R := <Operand>,
LD := <Operand>,
PV := <Operand>,
QU=> <Operand>,
QD := <Operand>,
CV=> <Operand>)
The syntax of the instruction consists of the following parts:
Parameter Declaration Data type Description
CU Input BOOL Count up input
CD Input BOOL Count down input
R Input BOOL Reset input
LD Input BOOL Load input
PV Input Integers Value at which the
output QU is set.
QU Output BOOL Status of the counter up
QD Output BOOL Status of the counter
down
CV Output Integers, CHAR, DATE Current counter value
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
SCL
"IEC_COUNTER_DB".CTUD(CU := "Tag_Start1",
CD := "Tag_Start2",
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1944 System Manual, 01/2013,
SCL
LD := "Tag_Load",
R := "Tag_Reset",
PV := "Tag_PresetValue",
QU => "Tag_CU_Status",
QD => "Tag_CD_Status",
CV => "Tag_CounterValue");
If the "Tag_Start1" operand has a positive signal edge in the signal state, the current counter
value is incremented by one and stored in the "Tag_CounterValue" operand. If the "Tag_Start2"
operand has a positive signal edge in the signal state, the counter value is decremented by
one and is also stored in the "Tag_CounterValue" operand. The counter value is incremented
on the positive signal edge of the CU parameter until it reaches the high limit of the specified
data type (INT). If the CD parameter has a positive signal edge, the counter value is
decremented until it reaches the low limit of the specified data type (INT).
The operand "Tag_CU_Status" has the signal state "1" as long as the current counter value is
greater than or equal to the value of the operand "Tag_PresetValue". In all other cases, the
"Tag_CU_Status" output has signal state "0".
The operand "Tag_CD_Status" has the signal state "1" as long as the current counter value is
less than or equal to zero. In all other cases, the "Tag_CD_Status" output has signal state "0".
See also
Overview of the valid data types (Page 899)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
SIMATIC Counters
S_CU: Assign parameters and count up
Description
You can use the "Assign parameters and count up" instruction to increment the value of a
counter. When the signal state of the parameter CU changes from "0" to "1" (positive signal
edge), the current counter value is incremented by one. The current counter value is provided
at the parameter CV. The counter value is incremented until the limit of "999" is reached. When
the limit value is reached, the counter value is no longer incremented on a positive signal edge.
When the signal state of the parameter S changes from "0" to "1", the counter value is set to
the value of the parameter PV. If the counter is set and if the result of logic operation (RLO)
at the CU input is "1", the counter counts once in the next cycle, even when no signal edge
change is detected.
The counter value is set to zero when the signal state of the parameter R changes to "1". As
long as the parameter R has the signal state "1", a change in the signal state of the parameters
CU and S has no effect on the counter value.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1945
The signal state at parameter Q is "1" if the counter value is greater than zero. When the
counter value equals zero, parameter Q returns signal state "0".
Note
Only use a counter at a single location in the program to avoid risk of counting errors.
Syntax
The following syntax is used for the "Assign parameters and count up" instruction:
SCL
S_CU(C_NO := <Operand>,
CU:= <Operand>,
S := <Operand>,
PV := <Operand>,
R := <Operand>,
Q => <Operand>,
CV=> <Operand>)
The syntax of the instruction consists of the following parts:
Parameter Declaration Data type Description
C_NO Input COUNTER, INT Counters
The number of counters
depends on the CPU.
CU Input BOOL Count up input
S Input BOOL Input for presetting the
counter
PV Input WORD Preset counter value
(C#0 to C#999) in BCD
format
R Input BOOL Reset input
Q Output BOOL Status of the counter
CV Output WORD, S5TIME, DATE Current counter value
Function value WORD, S5TIME, DATE Current counter value in
BCD format
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
SCL
"Tag_Result" := S_CU(C_NO := "Counter_1",
CU := "Tag_Start",
S := "Tag_1",
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1946 System Manual, 01/2013,
SCL
PV := "Tag_PresetValue",
R := "Tag_Reset",
Q => "Tag_Status",
CV => "Tag_Value");
If the signal state of the parameter "Tag_Start" changes from "0" to "1" (positive signal edge)
and the current counter value is less than "999", the counter value is incremented by one. If
the signal state of the input "Tag_1" changes from "0" to "1", the counter value in BCD format
is set to the value of the operand "Tag_PresetValue". The counter value is reset to "0" when
the operand "Tag_Reset" has signal state "1".
The current counter value is stored in hexadecimal form in the operand "Tag_Value".
The output "Tag_Status" has the signal state "1" as long as the current counter value is not
equal to "0". The current counter value is returned in the "Tag_Value" operand and as a function
value.
See also
Overview of the valid data types (Page 899)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
S_CD: Assign parameters and count down
Description
You can use the "Assign parameters and count down" instruction to decrement the value of a
counter. When the signal state of the parameter CD changes from "0" to "1" (positive signal
edge), the current counter value is decreased by one. The current counter value is provided
at the parameter CV. The counter value is decreased until the low limit of "0" is reached. When
the low limit value is reached, the counter value is no longer decreased on a positive signal
edge.
When the signal state of the parameter S changes from "0" to "1", the counter value is set to
the value of the parameter PV. If the counter is set and if the result of logic operation (RLO)
at the parameter CD is "1", the counter counts once in the next cycle, even when no signal
edge change is detected.
The counter value is set to zero when the signal state of the parameter R changes to "1". As
long as the parameter R has the signal state "1", a change in the signal state of the parameters
CD and S has no effect on the counter value.
The signal state at parameter Q is "1" if the counter value is greater than zero. When the
counter value equals zero, parameter Q returns signal state "0".
Note
Only use a counter at a single location in the program to avoid risk of counting errors.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1947
Syntax
The following syntax is used for the "Assign parameters and count down" instruction:
SCL
S_CD(C_NO:= <Operand>,
CD:= <Operand>,
S:= <Operand>,
PV:= <Operand>,
R:= <Operand>,
Q=> <Operand>,
CV=> <Operand>)
The syntax of the instruction consists of the following parts:
Parameter Declaration Data type Description
C_NO Input COUNTER, INT Counters
The number of counters
depends on the CPU.
CD Input BOOL Count down input
S Input BOOL Input for presetting the
counter
PV Input WORD Preset counter value
(C#0 to C#999) in BCD
format
R Input BOOL Reset input
Q Output BOOL Status of the counter
CV Output WORD, S5TIME,
WORD
Current counter value
Function value WORD, S5TIME, DATE Current counter value in
BCD format
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
SCL
"Tag_Result" := S_CD(C_NO := "Counter_1",
CD := "Tag_Start",
S := "Tag_1",
PV := "Tag_PresetValue",
R := "Tag_Reset",
Q => "Tag_Status",
CV => "Tag_Value");
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1948 System Manual, 01/2013,
When the signal state of the operand "Tag_Start" changes from "0" to "1" (positive signal edge)
and the current counter value is greater than "0", the counter value is decreased by one. If the
signal state of the operand "Tag_1" changes from "0" to "1", the counter value is set to the
value of the operand "Tag_PresetValue". The counter value is reset to "0" when the operand
"Tag_Reset" has signal state "1".
The current counter value is stored in the operand "Tag_Value".
The operand "Tag_Status" returns signal state "1" as long as the current counter value is not
equal to "0". The current counter value is returned in the "Tag_Value" operand and as a function
value.
See also
Overview of the valid data types (Page 899)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
S_CUD: Assign parameters and count up / down
Description
You can use the "Assign parameters and count up / down" instruction to increment and
decrement the value of a counter. When the signal state of the parameter CU changes from
"0" to "1" (positive signal edge), the current counter value is incremented by one. When the
signal state of the parameter CD changes from "0" to "1" (positive signal edge), the counter
value is decreased by one. The current counter value is provided at the parameter CV. If there
is a positive signal edge at the parameters CU and CD in one program cycle, the counter
value remains unchanged.
The counter value is incremented until the high limit value of "999" is reached. When the high
limit value is reached, the counter value is no longer incremented on a positive signal edge.
When the low limit value "0" is reached, the counter value is not decremented any further.
When the signal state of the parameter S changes from "0" to "1", the counter value is set to
the value of the parameter PV. If the counter is set and if the result of logic operation (RLO)
of the parameters CU and CD is "1", the counter will count once in the next cycle, even if no
signal edge change was detected.
The counter value is set to zero when the signal state of the parameter R changes to "1". As
long as the parameter R has the signal state "1", processing of the signal state of the
parameters CU, CD and S has no effect on the counter value.
The signal state at parameter Q is "1" if the counter value is greater than zero. When the
counter value equals zero, parameter Q returns signal state "0".
Note
Only use a counter at a single location in the program to avoid risk of counting errors.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1949
Syntax
The following syntax is used for the "Assign parameters and count up / down" instruction:
SCL
S_CUD(C_NO:= <Operand>,
CU:= <Operand>,
CD:= <Operand>,
S:= <Operand>,
PV:= <Operand>,
R:= <Operand>,
Q=> <Operand>,
CV=> <Operand>)
The syntax of the instruction consists of the following parts:
Parameter Declaration Data type Description
C_NO Input COUNTER, INT Counters
The number of counters
depends on the CPU.
CU Input BOOL Count up input
CD Input BOOL Count down input
S Input BOOL Input for presetting the
counter
PV Input WORD Preset counter value
(C#0 to C#999) in BCD
format
R Input BOOL Reset input
Q Output BOOL Status of the counter
CV Output WORD, S5TIME, DATE Current counter value
(hexadecimal)
Function value WORD, S5TIME, DATE Current counter value in
BCD format
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
SCL
"Tag_Result" := S_CD(C_NO := "Counter_1",
CU := "Tag_CU",
CD := "Tag_CD",
S := "Tag_1",
PV := "Tag_PresetValue",
R := "Tag_Reset",
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1950 System Manual, 01/2013,
SCL
Q => "Tag_Status",
CV => "Tag_Value");
When a positive signal edge is detected in the signal state of the operand "Tag_CU" and the
current counter value is less than "999", the counter value is incremented by one. When a
positive signal edge is detected in the signal state of the operand "Tag_CD" and the current
counter value is greater than "0", the counter value is decremented by one.
If the signal state of the operand "Tag_1" changes from "0" to "1", the counter value is set to
the value of the operand "Tag_PresetValue". The counter value is reset to "0" when the
operand "Tag_Reset" has signal state "1".
The current counter value is stored in the operand "Tag_Value".
The operand "Tag_Status" returns signal state "1" as long as the current counter value is not
equal to "0". The current counter value is returned in the "Tag_Value" operand and as a function
value.
See also
Overview of the valid data types (Page 899)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
Math functions
ABS: Form absolute value
Description
Use the "Form absolute value" instruction to calculate the absolute value of an input value and
to save the result in the specified operands.
Syntax
Use the following syntax for the "Form absolute value" instruction:
SCL
ABS(<Expression>)
The syntax of the instruction consists of the following parts:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1951
Parameter Declaration Data type Description
S7-1200 S7-1500
<Expression> Input SINT, INT, DINT,
floating-point
numbers
SINT, INT, DINT,
LINT, floating-
point numbers
Input value
Function value SINT, INT, DINT,
floating-point
numbers
SINT, INT, DINT,
LINT, floating-
point numbers
Absolute value of
the input value
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
SCL
"Tag_Result1" := ABS("Tag_Value");
"Tag_Result2" := ABS("Tag_Value1"*"Tag_Value2");
The absolute value of the input value is returned in the format of the input value as a function
value.
The following table shows how the instruction works using specific operand values:
Operand Value
Tag_Value -2
Tag_Result1 2
Tag_Value1 4
Tag_Value2 -1
Tag_Result2 4
See also
Overview of the valid data types (Page 899)
Expressions (Page 1156)
Operators and operator precedence (Page 1161)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
MIN: Get minimum
Description
The "Get minimum" instruction compares the values of the available inputs and returns the
lowest value as the result. The instruction is only executed if the tags of all inputs are of the
same data type.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1952 System Manual, 01/2013,
A minimum of two and a maximum of 32 inputs can be specified for execution of the instruction.
Syntax
The following syntax is used for the "Get minimum" instruction:
SCL
MIN(IN1:= <Operand>,
IN2:= <Operand>,
INn:= <Operand>)
The syntax of the instruction consists of the following parts:
Parameter Declaration Data type Description
S7-1200 S7-1500
IN1 Input Integers, floating-
point numbers,
TIME, TOD,
DATE, DT
Integers, floating-
point numbers,
timers, TOD,
LTOD, DATE, DT,
LDT
First input value
IN2 Input Integers, floating-
point numbers,
TIME, TOD,
DATE, DT
Integers, floating-
point numbers,
timers, TOD,
LTOD, DATE, DT,
LDT
Second input
value
INn Input Integers, floating-
point numbers,
TIME, TOD,
DATE, DT
Integers, floating-
point numbers,
timers, TOD,
LTOD, DATE, DT,
LDT
Optional input
values (n = 3 to 32)
Function value Integers, floating-
point numbers,
TIME, TOD,
DATE, DT
Integers, floating-
point numbers,
timers, TOD,
LTOD, DATE, DT,
LDT
Result of the
instruction
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
SCL
"Tag_Result" := MIN(IN1 := "Tag_Value1",
IN2 := "Tag_Value2",
IN3 := "Tag_Value3");
The following table shows how the instruction works using specific operand values:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1953
Parameter Operand Value
IN1 Tag_Value1 12222
IN2 Tag_Value2 14444
IN3 Tag_Value3 13333
Function value Tag_Result 12222
The instruction compares the values of the available inputs and copies the lowest value
("Tag_Value1") to operand "Tag_Result".
See also
Overview of the valid data types (Page 899)
Expressions (Page 1156)
Operators and operator precedence (Page 1161)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
MAX: Get maximum
Description
The "Get maximum" instruction compares the values of the available inputs and returns the
greatest value as the result. The instruction is only executed if the tags of all inputs are of the
same data type.
A minimum of two and a maximum of 32 input values can be specified for execution of the
instruction.
Syntax
The following syntax is used for the "Get maximum" instruction:
SCL
MAX(IN1:= <Operand>,
IN2:= <Operand>,
INn:= <Operand>)
The syntax of the instruction consists of the following parts:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1954 System Manual, 01/2013,
Parameter Declaration Data type Description
S7-1200 S7-1500
IN1 Input Integers, floating-
point numbers,
TIME, TOD,
DATE, DT
Integers, floating-
point numbers,
timers, TOD,
LTOD, DATE, DT,
LDT
First input value
IN2 Input Integers, floating-
point numbers,
TIME, TOD,
DATE, DT
Integers, floating-
point numbers,
timers, TOD,
LTOD, DATE, DT,
LDT
Second input
value
INn Input Integers, floating-
point numbers,
TIME, TOD,
DATE, DT
Integers, floating-
point numbers,
timers, TOD,
LTOD, DATE, DT,
LDT
Optional input
values (n = 3 to 32)
Function value Integers, floating-
point numbers,
TIME, TOD,
DATE, DT
Integers, floating-
point numbers,
timers, TOD,
LTOD, DATE, DT,
LDT
Result of the
instruction
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
SCL
"Tag_Result" := MAX(IN1 := "Tag_Value1",
IN2 := "Tag_Value2",
IN3 := "Tag_Value3");
The following table shows how the instruction works using specific operand values:
Parameter Operand Value
IN1 Tag_Value1 12 222
IN2 Tag_Value2 14 444
IN3 Tag_Value3 13 333
Function value Tag_Result 14 444
The instruction compares the values of the specified operands and copies the greatest value
("Tag_Value2") to the operand "Tag_Result".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1955
See also
Overview of the valid data types (Page 899)
Expressions (Page 1156)
Operators and operator precedence (Page 1161)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
LIMIT: Set limit value
Description
The "Set limit value" instruction limits the value of the parameter IN to the values of the
parameters MN and MX. The value of the parameter MN may not be greater than the value of
the parameter MX.
If the value of the parameter IN fulfills the MN condition <=IN <= MX, it is returned as the result
of the instruction. If the condition is not fulfilled and the IN input value is less than the MN low
limit, the value of the MN parameter is returned as the result. If the high limit MX is exceeded,
the value of the MX parameter is returned as the result.
If the value at input MN is greater than that at input MX, the result is undefined and the enable
output ENO is "0".
The instruction is only executed if the operands of all parameters are of the same data type.
Syntax
The following syntax is used for the "Set limit value" instruction:
SCL
LIMIT(MN := <Operand>,
IN := <Operand>,
MX := <Operand>)
The syntax of the instruction consists of the following parts:
Parameter Declaration Data type Description
S7-1200 S7-1500
MN Input Integers, floating-
point numbers,
TIME, TOD,
DATE, DT
Integers, floating-
point numbers,
timers, TOD,
LTOD, DATE, DT,
LDT
Low limit
IN Input Integers, floating-
point numbers,
TIME, TOD,
DATE, DT
Integers, floating-
point numbers,
timers, TOD,
LTOD, DATE, DT,
LDT
Input value
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1956 System Manual, 01/2013,
Parameter Declaration Data type Description
S7-1200 S7-1500
MX Input Integers, floating-
point numbers,
TIME, TOD,
DATE, DT
Integers, floating-
point numbers,
timers, TOD,
LTOD, DATE, DT,
LDT
High limit
Function value Integers, floating-
point numbers,
TIME, TOD,
DATE, DT
Integers, floating-
point numbers,
timers, TOD,
LTOD, DATE, DT,
LDT
Result of the
instruction
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
SCL
"Tag_Result" := LIMIT(MN := "Tag_Minimum",
IN := "Tag_Value",
MX := "Tag_Maximum");
The following table shows how the instruction works using specific operand values:
Parameter Operand Value
MN Tag_Minimum 12 000
IN Tag_Value 8 000
MX Tag_Maximum 16 000
Function value Tag_Result 12 000
The value of operand "Tag_Value" is compared with the values of operands "Tag_Minimum"
and "Tag_Maximum". Because the value of the operand "Tag_Value" is less than the low limit
value, the value of operand "Tag_Minimum" will be copied to operand "Tag_Result".
See also
Overview of the valid data types (Page 899)
Expressions (Page 1156)
Operators and operator precedence (Page 1161)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1957
SQR: Form square
Description
Use the "Form square" instruction to square the input value and save the result in the specified
operand.
Syntax
Use the following syntax for the instruction "Form square":
SCL
SQR(<Expression>)
The syntax of the instruction consists of the following parts:
Parameter Declaration Data type Description
<Expression> Input Floating-point numbers Input value
Function value Floating-point numbers Square of the input
value
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
SCL
"Tag_Result1" := SQR("Tag_Value");
"Tag_Result2" := SQR((SQR("Tag_Value1"))*"Tag_Value2);
The square of the input value is returned in the operand "Tag_Result" as a function value.
The following table shows how the instruction works using specific operand values:
Operand Value
Tag_Value 2.5
Tag_Result1 6.25
Tag_Value1 6.0
Tag_Value2 2.0
Tag_Result2 5184.0
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1958 System Manual, 01/2013,
See also
Overview of the valid data types (Page 899)
Expressions (Page 1156)
Operators and operator precedence (Page 1161)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
SQRT: Form square root
Description
Use the "Form square root" instruction to calculate the square root of the the input value and
save the result in the specified operand. The instruction has a positive result if the input value
is greater than zero. If input values are less than zero, the instruction returns an invalid floating-
point number. If the input value is "-0", the result is also "-0".
Syntax
Use the following syntax for the "Form square root" instruction:
SCL
SQRT(<Expression>)
The syntax of the instruction consists of the following parts:
Parameter Declaration Data type Description
<Expression> Input Floating-point numbers Input value
Function value Floating-point numbers Square root of the input
value
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
SCL
"Tag_Result1" := SQRT("Tag_Value");
"Tag_Result2" := SQRT((SQR("Tag_Value1"))+"Tag_Value2");
The square root of the input value is returned in the operand "Tag_Result" as a function value.
The following table shows how the instruction works using specific operand values:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1959
Operand Value
Tag_Value 4.0
Tag_Result1 2.0
Tag_Value1 3.0
Tag_Value2 16.0
Tag_Result2 5.0
See also
Overview of the valid data types (Page 899)
Expressions (Page 1156)
Operators and operator precedence (Page 1161)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
LN: Form natural logarithm
Description
You can use the "Form natural logarithm" instruction to calculate the natural logarithm to base
e (e=2.718282) of the input value. The instruction has a positive result if the input value is
greater than zero. If input values are less than zero, the instruction returns an invalid floating-
point number.
Syntax
Use the following syntax for the "Form natural logarithm" instruction:
SCL
LN(<Expression>)
The syntax of the instruction consists of the following parts:
Parameter Declaration Data type Description
<Expression> Input Floating-point
numbers
Input value
Function value Floating-point
numbers
Natural logarithm of the input
value
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1960 System Manual, 01/2013,
Example
The following example shows how the instruction works:
SCL
"Tag_Result1" := LN("Tag_Value");
"Tag_Result2" := LN("Tag_Value1"+"Tag_Value2");
The result of the instruction is returned in the operand "Tag_Result" as a function value.
The following table shows how the instruction works using specific operand values:
Operand Value
Tag_Value 2.5
Tag_Result1 0.916
Tag_Value1 1.5
Tag_Value2 3.2
Tag_Result2 1.548
See also
Overview of the valid data types (Page 899)
Expressions (Page 1156)
Operators and operator precedence (Page 1161)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
EXP: Form exponential value
Description
The "Form exponential value" instruction calculates the exponent from the base e (e =
2.718282) and the input value and saves the result in the specified operand.
Syntax
The following syntax is used for the "Form exponential value" instruction:
SCL
EXP(<Expression>)
The syntax of the instruction consists of the following parts:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1961
Parameter Declaration Data type Description
<Expression> Input Floating-point numbers Input value
Function value Floating-point numbers Exponential value of the
input value
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
SCL
"Tag_Result1" := EXP("Tag_Value");
"Tag_Result2" := EXP("Tag_Value1"/"Tag_Value2");
The result of the instruction is returned in the operand "Tag_Result" as a function value.
The following table shows how the instruction works using specific operand values:
Operand Value
Tag_Value 20.5
Tag_Result1 799 902 200
Tag_Value1 15.5
Tag_Value2 30.2
Tag_Result2 1.671
See also
Overview of the valid data types (Page 899)
Expressions (Page 1156)
Operators and operator precedence (Page 1161)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
SIN: Form sine value
Description
Use the "Form sine value" instruction to calculate the sine of the input value. The input value
must be given in the radian measure.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1962 System Manual, 01/2013,
Syntax
Use the following syntax for the "Form sine value" instruction:
SCL
SIN(<Expression>)
The syntax of the instruction consists of the following parts:
Parameter Declaration Data type Description
<Expression> Input Floating-point numbers Input value (size of an
angle in the radian
measure)
Function value Floating-point numbers Result of the instruction
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
SCL
"Tag_Result" := SIN("Tag_Value");
The result of the instruction is returned in the "Tag_Result" operand as a function value.
The following table shows how the instruction works using specific operand values:
Operand Value
Tag_Value +1.570796 (/2)
Tag_Result 1.0
See also
Overview of the valid data types (Page 899)
Expressions (Page 1156)
Operators and operator precedence (Page 1161)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
COS: Form cosine value
Description
Use the "Form cosine value" instruction to calculate the cosine of the input value. The input
value must be given in the radian measure.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1963
Syntax
Use the following syntax for the "Form cosine value" instruction:
SCL
COS(<Expression>)
The syntax of the instruction consists of the following parts:
Parameter Declaration Data type Description
<Expression> Input Floating-point numbers Input value (size of an
angle in the radian
measure)
Function value Floating-point numbers Result of the instruction
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
SCL
"Tag_Result" := COS("Tag_Value");
The result of the instruction is returned in the operand "Tag_Result" as a function value.
The following table shows how the instruction works using specific operand values:
Operand Value
Tag_Value +1.570796 (/2)
Tag_Result 0
See also
Overview of the valid data types (Page 899)
Expressions (Page 1156)
Operators and operator precedence (Page 1161)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
TAN: Form tangent value
Description
Use the "Form tangent value" instruction to calculate the sine of the input value. The input
value must be given in the radian measure.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1964 System Manual, 01/2013,
Syntax
Use the following syntax for the "Form tangent value" instruction:
SCL
TAN(<Expression>)
The syntax of the instruction consists of the following parts:
Parameter Declaration Data type Description
<Expression> Input Floating-point numbers Input value (size of an
angle in the radian
measure)
Function value Floating-point numbers Result of the instruction
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
SCL
"Tag_Result" := TAN("Tag_Value");
The result of the instruction is returned in the operand "Tag_Result" as a function value.
The following table shows how the instruction works using specific operand values:
Operand Value
Tag_Value +3.141593 ()
Tag_Result 0
See also
Overview of the valid data types (Page 899)
Expressions (Page 1156)
Operators and operator precedence (Page 1161)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
ASIN: Form arcsine value
Description
You can use the "Form arcsine value" instruction to calculate the size of the angle from a sine
value, which corresponds to this value. Only valid floating-point numbers within the range -1
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1965
to +1 can be specified as input values. The calculated angle size is given in the radian measure
and can range in value from -/2 to +/2.
Syntax
Use the following syntax for the "Form arcsine value" instruction:
SCL
ASIN(<Expression>)
The syntax of the instruction consists of the following parts:
Parameter Declaration Data type Description
<Expression> Input Floating-point numbers Sine value
Function value Floating-point numbers Size of angle in the
radian measure
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
SCL
"Tag_Result" := ASIN("Tag_Value");
The result of the instruction is returned in the operand "Tag_Result" as a function value.
The following table shows how the instruction works using specific operand values:
Operand Value
Tag_Value 1.0
Tag_Result +1.570796 (/2)
See also
Overview of the valid data types (Page 899)
Expressions (Page 1156)
Operators and operator precedence (Page 1161)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1966 System Manual, 01/2013,
ACOS: Form arccosine value
Description
You can use the "Form arccosine value" instruction to calculate the size of the angle from a
cosine value, which corresponds to this value. Only valid floating-point numbers within the
range -1 to +1 can be specified as input values. The calculated angle size is given in the radian
measure and can range in value from 0 to +.
Syntax
Use the following syntax for the "Form arccosine value" instruction:
SCL
ACOS(<Expression>)
The syntax of the instruction consists of the following parts:
Parameter Declaration Data type Description
<Expression> Input Floating-point numbers Cosine value
Function value Floating-point numbers Size of angle in the
radian measure
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
SCL
"Tag_Result" := ACOS("Tag_Value");
The result of the instruction is returned in the "Tag_Result" operand as a function value.
The following table shows how the instruction works using specific operand values:
Operand Value
Tag_Value 0
Tag_Result +1.570796 (/2)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1967
See also
Overview of the valid data types (Page 899)
Expressions (Page 1156)
Operators and operator precedence (Page 1161)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
ATAN: Form arctangent value
Description
You can use the "Form arctangent value" instruction to calculate the size of the angle from a
tangent value, which corresponds to this value. Only valid floating-point numbers may be
specified as input values. The calculated angle size is given in the radian measure and can
range in value from -/2 to +/2.
Syntax
Use the following syntax for the "Form arctangent value" instruction:
SCL
ATAN(<Expression>)
The syntax of the instruction consists of the following parts:
Parameter Declaration Data type Description
<Expression> Input Floating-point numbers Tangent value
Function value Floating-point numbers Size of angle in the
radian measure
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
SCL
"Tag_Result" := ATAN("Tag_Value");
The result of the instruction is returned in the operand "Tag_Result" as a function value.
The following table shows how the instruction works using specific operand values:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1968 System Manual, 01/2013,
Operand Value
Tag_Value 1.0
Tag_Result +0.785398 (/4)
See also
Overview of the valid data types (Page 899)
Expressions (Page 1156)
Operators and operator precedence (Page 1161)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
FRAC: Return fraction
Description
The result of the instruction "Return fraction" returns the decimal places of a value. Input value
123.4567, for example, returns the value 0.4567.
Syntax
The following syntax is used for the instruction "Return fraction":
SCL
FRAC(<Expression>)
FRAC_<Data type>(<Expression>)
The syntax of the instruction consists of the following parts:
Parameter Declaration Data type Description
<Expression> Input Floating-point numbers Input value
_<Data type> Floating-point numbers
Default: REAL
Data type of the
function value:
You do not need to
specify the data
type if using the
default.
Any other valid data
type you may use
must be declared
explicitly.
Function value Floating-point numbers Decimal places of the
input value
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1969
Example
The following example shows how the instruction works:
SCL
"Tag_Result1" := FRAC("Tag_Value");
"Tag_Result2" := FRAC_LREAL("Tag_Value");
The following table shows how the instruction works using specific operand values:
Operand Value
Tag_Value 2.555 -1.4421
Tag_Result1 0.555 -0.4421
See also
Overview of the valid data types (Page 899)
Expressions (Page 1156)
Operators and operator precedence (Page 1161)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
Move operations
MOVE_BLK: Move block
Description
The instruction "Move block" copies the contents of a memory area (source area) to another
memory area (destination area). The number of elements to be copied to the destination area
is specified with the COUNT parameter. The width of the elements to be moved is defined by
the width of the first element in the source area.
Syntax
The following syntax is used for the instruction "Move block":
SCL
MOVE_BLK(IN := <Operand>,
COUNT := <Operand>,
OUT => <Operand>)
The syntax of the instruction consists of the following parts:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1970 System Manual, 01/2013,
Parameter Declaration Data type
S7-1200 S7-1500 Description
IN Input Binary numbers,
integers, floating-
point numbers,
TIME, DATE,
CHAR, TOD,
DATE and CHAR
as components of
an ARRAY
structure
Binary numbers,
integers, floating-
point numbers,
S5TIME, TIME,
LTIME, DATE,
CHAR, TOD,
LTOD, DATE and
CHAR as a
component of an
ARRAY structure
The first element
of the source area
to be copied.
COUNT Input USINT, UINT,
UDINT
USINT, UINT,
UDINT, ULINT
Number of
elements to be
copied from the
source area to the
destination area.
OUT Output Binary numbers,
integers, floating-
point numbers,
TIME, DATE,
CHAR, TOD,
DATE and CHAR
as components of
an ARRAY
structure
Binary numbers,
integers, floating-
point numbers,
S5TIME, TIME,
LTIME, DATE,
CHAR, TOD,
LTOD, DATE and
CHAR as a
component of an
ARRAY structure
The first element
of the destination
area to which the
content of the
source area is
copied.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
SCL
MOVE_BLK(IN := #a_array[2],
COUNT := "Tag_Count",
OUT => #b_array[1]);
The following table shows how the instruction works using specific operand values:
Parameter Operand Value
IN a_array[2] Operand "a_array" is of the
ARRAY data type and consists
of 5 elements of the INT data
type.
COUNT Tag_Count 3
OUT b_array[1] Operand "b_array" is of the
ARRAY data type and consists
of 6 elements of the INT data
type.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1971
The instruction selects three INT elements from the tag "a_array" (a_array[2..4]) and copies
their contents into the tag "b_array" (b_array[1..3]).
See also
Overview of the valid data types (Page 899)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
UMOVE_BLK: Move block uninterruptible
Description
The instruction "Move block uninterruptible" copies the contents of a memory area (source
area) to another memory area (destination area) without interruption. The number of elements
to be copied to the destination area is specified with the COUNT parameter. The width of the
elements to be moved is defined by the width of the first element in the source area.
Note
The copy operation cannot be interrupted by other operating system activities. This is why
the alarm reaction times of the CPU increase during the execution of the instruction "Move
block uninterruptible".
Syntax
The following syntax is used for the instruction "Move block uninterruptible":
SCL
UMOVE_BLK(IN := <Operand>,
COUNT := <Operand>,
OUT=> <Operand>)
The syntax of the instruction consists of the following parts:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1972 System Manual, 01/2013,
Parameter Declaration Data type Description
S7-1200 S7-1500
IN Input Binary numbers,
integers, floating-
point numbers,
TIME, DATE,
CHAR, TOD,
DATE and CHAR
as components of
an ARRAY
structure
Binary numbers,
integers, floating-
point numbers,
S5TIME, TIME,
LTIME, DATE,
CHAR, TOD,
LTOD, DATE and
CHAR as a
component of an
ARRAY structure
The first element
of the source area
to be copied.
COUNT Input USINT, UINT,
UDINT
USINT, UINT,
UDINT, ULINT
Number of
elements to be
copied from the
source area to the
destination area.
OUT Output Binary numbers,
integers, floating-
point numbers,
TIME, DATE,
CHAR, TOD,
DATE and CHAR
as components of
an ARRAY
structure
Binary numbers,
integers, floating-
point numbers,
S5TIME, TIME,
LTIME, DATE,
CHAR, TOD,
LTOD, DATE and
CHAR as a
component of an
ARRAY structure
The first element
of the destination
area to which the
content of the
source area is
copied.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
SCL
UMOVE_BLK(IN := #a_array[2],
COUNT := "Tag_Count",
OUT => #b_array[1]);
The following table shows how the instruction works using specific operand values:
Parameter Operand Value
IN a_array[2] Operand "a_array" is of the
ARRAY data type and consists
of 5 elements of the INT data
type.
COUNT Tag_Count 3
OUT b_array[1] Operand "b_array" is of the
ARRAY data type and consists
of 6 elements of the INT data
type.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1973
The instruction selects three INT elements from the tag "a_array" (a_array[2..4]) and moves
their content to the output tag "b_array" (b_array[1..3]). The copy operation cannot be
interrupted by other operating system activities.
See also
Overview of the valid data types (Page 899)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
FILL_BLK: Fill block
Description
The "Fill block" instruction is used to copy the content of a memory area (source area) to a
selected memory area (target area). The number of repeated copy operations is specified with
the COUNT parameter. When the instruction is executed, the source area is selected and
moved to the destination area as often as specified by the value of the COUNT parameter.
Syntax
The following syntax is used for the instruction "Fill block":
SCL
FILL_BLK(IN := <Operand>,
COUNT := <Operand>,
OUT => <Operand>)
The syntax of the instruction consists of the following parts:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1974 System Manual, 01/2013,
Parameter Declaration Data type Description
S7-1200 S7-1500
IN Input Binary numbers,
integers, floating-
point numbers,
TIME, TOD,
DATE, CHAR,
DATE and CHAR
as components of
an ARRAY
structure
Binary numbers,
integers, floating-
point numbers,
S5TIME, TIME,
LTIME, DATE,
CHAR, TOD,
LTOD, DATE and
CHAR as a
component of an
ARRAY structure
Element used to
fill the destination
area.
COUNT Input USINT, UINT,
UDINT
USINT, UINT,
UDINT, ULINT
Number of
repeated copy
operations
OUT Output Binary numbers,
integers, floating-
point numbers,
TIME, TOD,
DATE, CHAR,
DATE and CHAR
as components of
an ARRAY
structure
Binary numbers,
integers, floating-
point numbers,
S5TIME, TIME,
LTIME, DATE,
CHAR, TOD,
LTOD, DATE and
CHAR as a
component of an
ARRAY structure
Address in
destination area
where filling
begins.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
SCL
FILL_BLK(IN := #a_array[2],
COUNT := "Tag_Count",
OUT => #b_array[1]);
The following table shows how the instruction works using specific operand values:
Parameter Operand Value
IN a_array[2] Operand "a_array" is of the
ARRAY data type and consists
of 4 elements of the WORD
(ARRAY[1..4] of WORD) data
type.
COUNT Tag_Count 3
OUT b_array[1] Operand "b_array" is of the
ARRAY data type and consists
of 5 elements of the WORD
(ARRAY[1..5] of WORD) data
type.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1975
The instruction copies the second element (a_array[2]) of the "a_array" tag three times to the
"b_array" output tag (b_array[1..3]).
See also
Overview of the valid data types (Page 899)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
UFILL_BLK: Fill block uninterruptible
Description
The instruction "Fill block uninterruptible" is used to copy the content of a memory area (source
area) to a selected memory area (target area). The number of repeated copy operations is
specified with the COUNT parameter. When the instruction is executed, the value at the IN
input is selected and copied to the destination area as often as specified by the value in the
COUNT parameter.
The copy operation cannot be interrupted by other operating system activities. This is why the
alarm reaction times of the CPU increase during the execution of the "Fill block uninterruptible"
instruction.
Syntax
The following syntax is used for the "Fill block uninterruptible" instruction:
SCL
UFILL_BLK(IN := <Operand>,
COUNT := <Operand>,
OUT => <Operand>)
The syntax of the instruction consists of the following parts:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1976 System Manual, 01/2013,
Parameter Declaration Data type Description
S7-1200 S7-1500
IN Input Binary numbers,
integers, floating-
point numbers,
TIME, DATE,
CHAR, TOD,
DATE and CHAR
as components of
an ARRAY
structure
Binary numbers,
integers, floating-
point numbers,
S5TIME, TIME,
LTIME, DATE,
CHAR, TOD,
LTOD, DATE and
CHAR as a
component of an
ARRAY structure
Element used to
fill the destination
area.
COUNT Input USINT, UINT,
UDINT
USINT, UINT,
UDINT, ULINT
Number of
repeated copy
operations
OUT Output Binary numbers,
integers, floating-
point numbers,
TIME, TOD,
DATE, CHAR,
DATE and CHAR
as components of
an ARRAY
structure
Binary numbers,
integers, floating-
point numbers,
S5TIME, TIME,
LTIME, DATE,
CHAR, TOD,
LTOD, DATE and
CHAR as a
component of an
ARRAY structure
Address in
destination area
where filling
begins.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
SCL
UFILL_BLK(IN := #a_array[2],
COUNT := "Tag_Count",
OUT => #b_array[1]);
The following table shows how the instruction works using specific operand values:
Parameter Operand Value
IN a_array[2] Operand "a_array" is of the
ARRAY data type and consists
of 4 elements of the WORD
(ARRAY[1..4] of WORD) data
type.
COUNT Tag_Count 3
OUT b_array[1] Operand "b_array" is of the
ARRAY data type and consists
of 5 elements of the WORD
(ARRAY[1..5] of WORD) data
type.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1977
The instruction copies the second element (a_array[2]) of the "a_array" tag three times to the
"b_array" output tag (b_array[1..3]). The copy operation cannot be interrupted by other
operating system activities.
See also
Overview of the valid data types (Page 899)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
SWAP: Swap
Description
You can use the "Swap" instruction to change the arrangement of the bytes of an input value
and save the result in the specified operand.
The following figure shows how the bytes of an operand of the DWORD data type are swapped
using the "Swap" instruction:
15... ...8 7... ...0
0 1 1 0 1 0 1 0 0 1 0 1 1 1 0 0 0 0 0 1 1 1 1 0 1 1 0 0 0 1 0 1
16 23... ...24 31...
15... ...8 7... ...0
1 1 0 0 0 1 0 1 0 0 0 1 1 1 1 0 0 1 0 1 1 1 0 0 0 1 1 0 1 0 1 0
16 23... ...24 31...
1 2 3 4
1
2
3 4
Result
lnput value
Syntax
The following syntax is used for the "Swap" instruction:
SCL
SWAP(<Expression>)
The syntax of the instruction consists of the following parts:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1978 System Manual, 01/2013,
Parameter Declaration Data type Description
S7-1200 S7-1500
<Expression> Input WORD, DWORD WORD, DWORD,
LWORD
Input value
Function value WORD, DWORD WORD, DWORD,
LWORD
Result of the
instruction
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
SCL
"Tag_Result" := SWAP("Tag_Value");
The result of the instruction is returned as a function value.
The following table shows how the instruction works using specific operand values:
Operand Value
Tag_Value 0000 1111 0101 0101
Tag_Result 0101 0101 0000 1111
See also
Overview of the valid data types (Page 899)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
PEEK: Read memory address
Description
The "Read memory address" instruction is used to read a memory address from a memory
area without specifying a data type.
Syntax
The following syntax is used for the "Read memory address" instruction:
SCL
PEEK(AREA:= <Operand>,
DBNUMBER:= <Operand>,
BYTEOFFSET:= <Operand>)
PEEK_<Data type>(AREA := <Operand>,
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1979
SCL
DBNUMBER:= <Operand>,
BYTEOFFSET:= <Operand>)
The syntax of the instruction consists of the following parts:
Parameter Declaration Data type Description
AREA Input BYTE The following areas can
be selected:
16#81: Input
16#82: Output
16#83: Bit memory
16#84: DB
16#1: Peripheral
input (S7-1500 only)
DBNUMBER Input DINT, DB_ANY Number of the data
block if AREA = DB,
otherwise "0"
BYTEOFFSET Input DINT Address to read from
_<Data type> Bit strings
default: BYTE
Data type of the
function value:
You do not need to
specify the data
type if using the
default.
Any other valid data
type you may use
must be declared
explicitly.
Function value Bit strings Result of the instruction
For additional information on valid data types, refer to "See also".
Note
If you read the memory address of the input, output or bit memory areas, you will need to set
the "DBNUMBER" parameter with the value "0", as the instruction is faulty otherwise.
Example
The following example shows how the instruction works:
SCL
"Tag_Result1" := PEEK(AREA := "Tag_Area",
DBNUMBER := "Tag_DBNumber",
BYTEOFFSET := "Tag_Byte");
"Tag_Result2" := PEEK_WORD(AREA := "Tag_Area",
DBNUMBER := "Tag_DBNumber",
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1980 System Manual, 01/2013,
SCL
BYTEOFFSET := "Tag_Byte");
The following table shows how the instruction works using specific operand values:
Parameter Operand Value
AREA Tag_Area 16#84
DBNUMBER Tag_DBNumber 5
BYTEOFFSET Tag_Byte 20
Function value Tag_Result1 Byte value "20"
Function value Tag_Result2 Word value "20"
The instruction reads the value of address "20" from the "Tag_Byte" operand at data block "5"
and returns the result as a function value at the "Tag_Result" operand.
See also
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
Overview of the valid data types (Page 899)
PEEK_BOOL: Read memory bit
Description
The "Read memory bit" instruction is used to read a memory bit from a memory area without
specifying a data type.
Note
Memory area
The instruction can only be used to access "Standard" memory areas.
Syntax
The following syntax is used for the "Read memory bit" instruction:
SCL
PEEK_BOOL(AREA := <Operand>,
DBNUMBER := <Operand>,
BYTEOFFSET := <Operand>,
BITOFFSET := <Operand>)
The syntax of the instruction consists of the following parts:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1981
Parameter Declaration Data type Description
AREA Input BYTE The following areas can
be selected:
16#81: Input
16#82: Output
16#83: Bit memory
16#84: DB
16#1: Peripheral
input (S7-1500 only)
DBNUMBER Input DINT, DB_ANY Number of the data
block if AREA = DB,
otherwise "0"
BYTEOFFSET Input DINT Address to read from
BITOFFSET Input INT Bit to be read from
Function value BOOL Result of the instruction
For additional information on valid data types, refer to "See also".
Note
If you read the memory bit from the input, output or bit memory areas, you will need to set
the "DBNUMBER" parameter with the value "0", as the instruction is faulty otherwise.
Example
The following example shows how the instruction works:
SCL
"Tag_Result" := PEEK_BOOL(AREA := "Tag_Area",
DBNUMBER := "Tag_DBNumber",
BYTEOFFSET := "Tag_Byte",
BITOFFSET := "Tag_Bit");
The following table shows how the instruction works using specific operand values:
Parameter Operand Value
AREA Tag_Area 16#84
DBNUMBER Tag_DBNumber 5
BYTEOFFSET Tag_Byte 20
BITOFFSET Tag_Bit 3
Function value Tag_Result 3
The instruction reads the value of memory bit "3" from the "Tag_Bit" operand at byte "20" of
data block "5" and returns the result at the "Tag_Result" operand as function value.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1982 System Manual, 01/2013,
See also
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
Overview of the valid data types (Page 899)
POKE: Write memory address
Description
The "Write memory address" instruction is used to write a memory address to a memory area
without specifying a data type.
Note
Memory area
The instruction can only be used to access "Standard" memory areas.
Syntax
The following syntax is used for the "Write memory address" instruction:
SCL
POKE(AREA := <Operand>,
DBNUMBER := <Operand>,
BYTEOFFSET := <Operand>,
VALUE := <Operand>)
The syntax of the instruction consists of the following parts:
Parameter Declaration Data type Description
AREA Input BYTE The following areas can
be selected:
16#81: Input
16#82: Output
16#83: Bit memory
16#84: DB
16#2: Peripheral
output (S7-1500
only)
DBNUMBER Input DINT, DB_ANY Number of the data
block if AREA = DB,
otherwise "0"
BYTEOFFSET Input DINT Address to be written
VALUE Input Bit strings Value to be written
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1983
For additional information on valid data types, refer to "See also".
Note
If you write the memory address in the input, output or bit memory areas, you will need to set
the "DBNUMBER" parameter with the value "0", as the instruction is faulty otherwise.
Example
The following example shows how the instruction works:
SCL
POKE_WORD(AREA := "Tag_Area",
DBNUMBER := "Tag_DBNumber",
BYTEOFFSET := "Tag_Byte"),
VALUE := "Tag_Value";
The following table shows how the instruction works using specific operand values:
Parameter Operand Value
AREA Tag_Area 16#84
DBNUMBER Tag_DBNumber 5
BYTEOFFSET Tag_Byte 20
VALUE Tag_Value 16#11
The instruction overwrites the memory address "20" in the data block "5" with value "16#11".
See also
Overview of the valid data types (Page 899)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
POKE_BOOL: Write memory bit
Description
The "Write memory bit" instruction is used to write a memory bit to a memory area without
specifying a data type.
Note
Memory area
The instruction can only be used to access "Standard" memory areas.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1984 System Manual, 01/2013,
Syntax
The following syntax is used for the "Write memory bit" instruction:
SCL
POKE_BOOL(AREA := <Operand>,
DBNUMBER := <Operand>,
BYTEOFFSET := <Operand>,
BITOFFSET := <Operand>,
VALUE := <Operand>)
The syntax of the instruction consists of the following parts:
Parameter Declaration Data type Description
AREA Input BYTE The following areas can
be selected:
16#81: Input
16#82: Output
16#83: Bit memory
16#84: DB
16#2: Peripheral
input (S7-1500 only)
DBNUMBER Input DINT, DB_ANY Number of the data
block if AREA = DB,
otherwise "0"
BYTEOFFSET Input DINT Address to be written
BITOFFSET Input INT Bit to be written
VALUE Input BOOL Value to be written
For additional information on valid data types, refer to "See also".
Note
If you write the memory bit in the input, output or bit memory areas, you need to set the
"DBNUMBER" parameter with the value "0", as the instruction is faulty otherwise.
Example
The following example shows how the instruction works:
SCL
POKE_BOOL(AREA := "Tag_Area",
DBNUMBER := "Tag_DBNumber",
BYTEOFFSET := "Tag_Byte",
BITOFFSET := "Tag_Bit",
VALUE := "Tag_Value");
The following table shows how the instruction works using specific operand values:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1985
Parameter Operand Value
AREA Tag_Area 16#84
DBNUMBER Tag_DBNumber 5
BYTEOFFSET Tag_Byte 20
BITOFFSET Tag_Bit 3
VALUE Tag_Value M0.0
The instruction overwrites the memory bit "3" in data block "5" in byte "20" with the value "M0.0".
See also
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
Overview of the valid data types (Page 899)
POKE_BLK: Write memory area
Description
The "Write memory area" instruction copies the content a memory area to a different memory
area without specifying a data type.
Note
Memory area
The instruction can only be used to access "Standard" memory areas.
Syntax
The following syntax is used for the "Write memory area" instruction:
SCL
POKE_BLK(AREA_SRC:= <Operand>,
DBNUMBER_SRC:= <Operand>,
BYTEOFFSET_SRC:= <Operand>,
AREA_DEST:= <Operand>,
DBNUMBER_DEST:= <Operand>,
BYTEOFFSET_DEST:= <Operand>,
COUNT:= <Operand>)
The syntax of the instruction consists of the following parts:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1986 System Manual, 01/2013,
Parameter Declaration Data type Description
AREA_SRC Input BYTE The following areas can
be selected in the
source memory area:
16#81: Input
16#82: Output
16#83: Bit memory
16#84: DB
16#1: Peripheral
input (S7-1500 only)
DBNUMBER_SRC Input DINT, DB_ANY Number of the data
block in the source
memory area, if AREA
= DB, otherwise "0"
BYTEOFFSET_SRC Input DINT Address in the source
memory area to be
written
AREA_DEST Input BYTE The following areas can
be selected in the
destination memory
area:
16#81: Input
16#82: Output
16#83: Bit memory
16#84: DB
16#2: Peripheral
input (S7-1500 only)
DBNUMBER_DEST Input DINT, DB_ANY Number of the data
block in the destination
memory area, if AREA
= DB, otherwise "0"
BYTEOFFSET_DEST Input DINT Address in the
destination memory
area to be written
COUNT Input DINT Number of bytes which
are copied
For additional information on valid data types, refer to "See also".
Note
If you write the memory address in the input, output or bit memory areas, you will need to set
the "DBNUMBER" parameter with the value "0", as the instruction is faulty otherwise.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1987
Example
The following example shows how the instruction works:
SCL
POKE_BLK(AREA_SRC := "Tag_Source_Area",
DBNUMBER_SRC := "Tag_Source_DBNumber",
BYTEOFFSET_SRC := "Tag_Source_Byte"),
AREA_DEST := "Tag_Destination_Area",
DBNUMBER_DEST := "Tag_Destination_DBNumber",
BYTEOFFSET_DEST := "Tag_Destination_Byte",
COUNT := "Tag_Count");
The following table shows how the instruction works using specific operand values:
Parameter Operand Value
AREA_SRC Tag_Source_Area 16#84
DBNUMBER_SRC Tag_Source_DBNumber 5
BYTEOFFSET_SRC Tag_Source_Byte 20
AREA_DEST Tag_Destination_Area 16#83
DBNUMBER_DEST Tag_Destination_DBNumber 0
BYTEOFFSET_DEST Tag_Destination_Byte 30
COUNT Tag_Count 100
The instruction writes 100 byte from data block "5" starting with address "20" in the memory
area of the bit memory starting at address "30".
See also
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
Overview of the valid data types (Page 899)
BLKMOV: Move block
Description
The instruction "Move block" copies the contents of a memory area (source area) to another
memory area (destination area). The move operation takes place in the direction of ascending
addresses. You use ANY to define the source and destination areas.
Note
The tags of the instruction can only be used in data blocks with the block property "Standard
access" or, if the tag was declared with the retentive setting "Set in IDB", also "with optimized
access".
The following figure shows the principle of the move operation:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1988 System Manual, 01/2013,
Copying is performed in
the direction of ascending
addresses
Memory area
Move
A DB10.DBW4
DB10.DBW6
DB10.DBW8
DB10.DBW10
MW10
MW12
MW14
MW16
B
C D
E F
G H
A B
C D
E F
G H
Consistency of the source data and destination data
Note that while the instruction "Move block" is being executed, the source data remains
unchanged; otherwise the consistency of the destination data cannot be guaranteed.
Interruptibility
As long as the source area is not part of a data block that only exists in the load memory, there
is no limit to the nesting depth.
If, however, BLKMOV is interrupted while copying from a DB that is not relevant to program
execution, the execution of BLKMOV can no longer be nested.
Memory areas
The instruction "Move block" moves the following memory areas:
Areas of a data block
Bit memory
Process image input
Process image output
Data blocks not relevant for program execution
General rules when copying
The source and destination areas must not overlap. If the source and destination areas have
different lengths, only the length of the smaller area will be moved.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1989
If the source area is smaller than the destination area, the entire source area will be written to
the destination area. The remaining bytes of the destination area remain unchanged.
If the destination area is smaller than the source area, the entire destination area will be written.
The remaining bytes of the source area are ignored.
If an area of the BOOL data type is copied, the specified length of the area must be divisible
by 8, otherwise the instruction will not execute.
Rules for moving character strings
You can use the "Move block" instruction to also move source and destination areas of the
STRING data type. If only the source area is of the data type STRING, the characters that are
actually contained in the character string are moved. Information on the actual and maximum
length is also written to the destination area. If the source and destination area are both
STRING data type, the current length of the character string in the destination area is set to
the number of characters actually moved.
If you want to move the information on the maximum and actual length of a character string,
specify the areas in bytes in the SRCBLK and DSTBLK parameters.
Rules for moving data blocks that are not relevant to program execution
The source area can also be in a data block in load memory that is not relevant for program
execution. Data blocks that are not relevant for program execution are indicated by the key
word UNLINKED.
If an unlinked data block is copied to the work memory with the instruction "Move block" and
downloaded at the same time, for example, by the programming device, the execution of the
instruction can be delayed for several milliseconds. This results in a longer OB cycle and may
trip the cycle monitoring.
If an unlinked data block is copied with the instruction "Move block" and the copy operation is
interrupted, the execution of the instruction can no longer be continued.
If the instruction Read from data block in the load memory is available on your CPU, you must
use this instruction to read data blocks that are not runtime-relevant from load memory. If you
use the "Move block" instruction, error W#16#8092 is output.
Syntax
The following syntax is used for the instruction "Move block":
SCL
BLKMOV(SRCBLK:= <Operand>,
DSTBLK => <Operand>)
The syntax of the instruction consists of the following parts:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1990 System Manual, 01/2013,
Parameter Declaration Data type Description
SRCBLK Input ANY Specifies the memory
area to be moved
(source area).
DSTBLK Output ANY Specifies the memory
area to which the data
will be moved
(destination area).
Function value (RET_VAL) INT Error information
For additional information on valid data types, refer to "See also".
RET_VAL Parameter
The following table shows the meaning of the values of the RET_VAL parameter:
Error code*
(W#16#...)
Explanation
0000 No error
8091 The permitted nesting depth was exceeded
8092 The instruction cannot be executed because a specified data block is write protected, non-executable, or
not loaded.
8xyy For more information on errors, refer to "See also".
*The error codes can be displayed as integer or hexadecimal value in the program editor. For additional information on
toggling display formats, refer to "See also".
See also
Overview of the valid data types (Page 899)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
UBLKMOV: Move block uninterruptible
Description
The instruction "Move block uninterruptible" copies the contents of a memory area (source
area) to another memory area (destination area). The move operation takes place in the
direction of ascending addresses. You use ANY pointers to define the source and destination
areas.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1991
The copy operation cannot be interrupted by other operating system activities. As a result the
alarm reaction time of the CPU can increase during the execution of the instruction "Move
block uninterruptible".
Note
The tags of the instruction can only be used in data blocks with the block property "Standard
access" or, if the tag was declared with the retentive setting "Set in IDB", also "with optimized
access".
Memory areas
The instruction "Move block uninterruptible" copies the following memory areas:
Areas of a data block
Bit memory
Process image input
Process image output
General rules when copying
The source and destination area must not overlap during the execution of the instruction "Move
block uninterruptible". If the source area is smaller than the destination area, the entire source
area will be written to the destination area. The remaining bytes of the destination area remain
unchanged.
If the destination area is smaller than the source area, the entire destination area will be written.
The remaining bytes of the source area are ignored.
If a source or destination area defined as a formal parameter is less than a destination or
source area specified on the SRCBLK or DSTBLK parameter, no data will be transferred.
If an area of the BOOL data type is copied, the specified length of the area must be divisible
by 8, otherwise the instruction will not execute.
The instruction "Move block uninterruptible" copies a maximum of 512 bytes. Note the CPU
specific restrictions for this.
Rules for moving character strings
The instruction "Move block uninterruptible" copies source and destination areas of the data
type STRING. If only the source area is of the data type STRING, the characters that are
actually contained in the character string are moved. Information on the actual and maximum
length are not written in the destination area. If the source and destination area are both of the
data type STRING, the current length of the character string in the destination area is set to
the number of characters actually moved. If areas of the data type STRING are moved, you
must specify "1" as the area length.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1992 System Manual, 01/2013,
Rules for moving character strings
The instruction "Move block uninterruptible" copies source and destination areas of the data
type STRING. If only the source area is of the data type STRING, the characters that are
actually contained in the character string are moved. Information on the actual and maximum
length is not written to the destination area. If the source and destination area are both STRING
data type, the current length of the character string in the destination area is set to the number
of characters actually moved. If areas of the STRING data type are moved, specify "1" as the
area length.
Syntax
The following syntax is used for the instruction "Move block uninterruptible":
SCL
UBLKMOV(SRCBLK:= <Operand>,
DSTBLK => <Operand>)
The syntax of the instruction consists of the following parts:
Parameter Declaration Data type Description
SRCBLK Input ANY Specifies the memory
area to be moved
(source area).
DSTBLK Output ANY Specifies the memory
area to which the data
will be moved
(destination area).
Function value (RET_VAL) INT Error information
For additional information on valid data types, refer to "See also".
RET_VAL Parameter
The following table shows the meaning of the values of the RET_VAL parameter:
Error code
(W#16#...)
Explanation
0000 No error
8091 The source area is in a data block that is not relevant for program execution.
8xyy For more information on errors, refer to "See also".
*The error codes can be displayed as integer or hexadecimal value in the program editor. For additional information on
toggling display formats, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1993
See also
Overview of the valid data types (Page 899)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
FILL: Fill block
Description
The instruction "Fill block" fills a memory area (destination area) with the content of another
memory area (source area). The instruction "Fill block" copies the content of the source area
to the destination area until the destination area is completely written. The move operation
takes place in the direction of ascending addresses.
Note
The tags of the instruction can only be used in data blocks with the block property "Standard
access" or, if the tag was declared with the retentive setting "Set in IDB", also "with optimized
access".
The following figure shows the principle of the move operation:
BVAL
BLK
FlLL
MW14
MW16
MW18
MW20
MW100
MW102
MW104
MW106
A B
C D
E F
G H
A B
C D
E F
G H
A B
C D
MW108
MW110
MW112
MW114
MW116
MW118
A B
C D
E F
G H
Example: The contents of the range MW100 to MW118 are to be preassigned with the contents
of the memory words MW14 to MW20.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1994 System Manual, 01/2013,
Consistency of the source data and destination data
Note that while the instruction "Fill block" is being executed, the source data remains
unchanged; otherwise the consistency of the destination data cannot be guaranteed.
Memory areas
The instruction "Fill block" copies the following memory areas:
Areas of a data block
Bit memory
Process image input
Process image output
Data blocks not relevant for program execution
The instruction "Fill block" copies the following memory areas:
Instructions, system data blocks
Counters
Timers
Memory areas of the I/O area
General rules when copying
The source and destination areas must not overlap. If the destination area to be preset is not
an integer multiple of the length of the BVAL input parameter, the destination area is
nevertheless written up to the last byte.
If the destination area to be preset is smaller than the source area, the function only copies as
much data as can be written to the destination area.
If the actually present destination or source area is smaller than the assigned memory area
for the source or destination area (BVAL, BLK parameters), no data will be transferred.
If the ANY pointer (source or destination) is the BOOL type, the length specified must be
divisible by 8; otherwise the instruction will not execute.
If the destination area is STRING data type, the instruction writes the entire string including
the administration information.
Syntax
The following syntax is used for the instruction "Fill block":
SCL
FILL(BVAL:= <Operand>,
BLK => <Operand>)
The syntax of the instruction consists of the following parts:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1995
Parameter Declaration Data type Description
BVAL Input ANY Specification of the
memory area (source
area) with whose
content the destination
area on the BLK
parameter will be filled.
BLK Output ANY Specification of the
memory area that will
be filled with the content
of the source area.
Function value (RET_VAL) INT Error information
For additional information on valid data types, refer to "See also".
BVAL Parameter
When you transfer a structure as an input parameter, remember that the length of a structure
is always based on an even number of bytes. The structure will need one byte of additional
memory space if you declare a structure with an odd number of bytes.
RET_VAL Parameter
The following table shows the meaning of the values of the RET_VAL parameter:
Error code
(W#16#...)
Explanation
0000 No error
8xyy For more information on errors, refer to "See also".
*The error codes can be displayed as integer or hexadecimal value in the program editor. For additional
information on toggling display formats, refer to "See also".
See also
Overview of the valid data types (Page 899)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
Conversion operations
CONVERT: Convert value
Description
Use the "Convert value" instruction to program explicit conversions. You determine the data
types to be converted in a dialogue box with opens automatically when you insert the
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1996 System Manual, 01/2013,
instruction. When executed, the instruction reads the source value and converts it into the
specified target value.
For information on possible conversions, refer to the "Explicit conversion" section at "See also".
Note
For S7-1500 CPU: You can select the data types DWORD and LWORD if REAL or LREAL
were selected as IN data type.
Syntax
Use the following syntax for the "Convert value" instruction:
SCL
<Target_value> := <Conversion_function>(<Source_value>);
The syntax of the instruction consists of the following parts:
Parameter Declaration Data type Description
S7-1200 S7-1500
<Source_value> Input, constant Bit strings,
integers, floating-
point numbers,
TIME, DATE,
TOD, DTL, strings
Bit strings,
integers, floating-
point numbers,
TIME, LTIME,
DATE, TOD,
LTOD, DTL,
strings
Value to be
converted.
<Conversion_function
>
- - - Function that
specifies the data
type to be
converted .
<Target_value> Output Bit strings,
integers, floating-
point numbers,
TIME, DATE,
TOD, DTL, strings
Bit strings,
integers, floating-
point numbers,
TIME, LTIME,
DATE, TOD,
LTOD, DTL,
strings
Result of the
conversion
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
SCL
"Tag_INT" := REAL_TO_INT("Tag_REAL");
The following table shows how the instruction works using specific operand values:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1997
Operand Data type Value
Tag_REAL REAL 20.56
Tag_INT INT 21
During the conversion, the value of the "Tag_REAL" operand will be rounded to the nearest
integer and saved in the "Tag_INT" operand.
See also
Overview of the valid data types (Page 899)
Operators and operator precedence (Page 1161)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
ROUND: Round numerical value
Description
The "Round numerical value" instruction is used to round the value at input IN to the nearest
integer. The instruction interprets the value at input IN as a floating-point number and converts
it into an integer or floating-point number. If the input value is exactly between an even and
odd number, the even number is selected.
Syntax
The following syntax is used for the "Round numerical value" instruction:
SCL
ROUND(<Expression>)
The syntax of the instruction consists of the following parts:
Parameter Declaration Data type Description
<Expression> Input Floating-point numbers Input value to be
rounded.
Function value Integers, floating-point
numbers
Result of the rounding
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
SCL
"Tag_Result" := ROUND("Tag_Value");
Programming the PLC
9.8 References
STEP 7 Basic V12.0
1998 System Manual, 01/2013,
The result of the instruction is returned in the operand "Tag_Result" as a function value.
The following table shows how the instruction works using specific operand values:
Operand Value
Tag_Value 1.50000000 -1.50000000
Tag_Result 2 -2
See also
Overview of the valid data types (Page 899)
Operators and operator precedence (Page 1161)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
CEIL: Generate next higher integer from floating-point number
Description
Use the "Generate next higher integer from floating-point number" instruction to round the
value to the nearest integer. The instruction interprets the input value as floating-point number
and converts it to the next higher integer. The function value can be greater than or equal to
the input value.
Syntax
The following syntax is used for the "Generate next higher integer from floating-point number"
instruction:
SCL
CEIL(<Expression>)
CEIL_<Data type>(<Expression>)
The syntax of the instruction consists of the following parts:
Parameter Declaration Data type Description
<Expression> Input Floating-point
numbers
Input value
_<Data type> Integers, floating-
point numbers.
Default: DINT
Data type of the function value:
You do not need to specify the data
type if using the default.
Any other valid data type you may use
must be declared explicitly.
Function value Integers, floating-
point numbers
Input value rounded up
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 1999
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
SCL
"Tag_Result1" := CEIL("Tag_Value");
"Tag_Result2" := CEIL_REAL("Tag_Value);
The following table shows how the instruction works using specific operand values:
Operand Value
Tag_Value 0.5 -0.5
Tag_Result1 1 0
Tag_Result2 1.0 0.0
The result of the instruction is returned in the operand "Tag_Result" as a function value.
See also
Overview of the valid data types (Page 899)
Expressions (Page 1156)
Operators and operator precedence (Page 1161)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
FLOOR: Generate next lower integer from floating-point number
Description
Use the "Generate next lower integer from floating-point number" instruction to round the value
of a floating point number to the next lower integer. The instruction interprets the input value
as floating-point number and converts it to the next lower integer. The function value can be
equal or less than the input value.
Syntax
Use the following syntax for the "Generate next lower integer from floating-point number"
instruction:
SCL
FLOOR(<Expression>)
FLOOR_<data type>(<expression>)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2000 System Manual, 01/2013,
The syntax of the instruction consists of the following parts:
Parameter Declaration Data type Description
<Expression> Input Floating-point
numbers
Input value
_<Data type> Integers, floating-
point numbers.
Default: DINT
Data type of the function value:
You do not need to specify the data
type if using the default.
Any other valid data type you may
use must be declared explicitly.
Function value Integers, floating-
point numbers
Input value rounded
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
SCL
"Tag_Result1" := FLOOR("Tag_Value");
"Tag_Result2" := FLOOR_REAL("Tag_Value");
The following table shows how the instruction works using specific operand values:
Operand Value
Tag_Value 0.5 -0.5
Tag_Result1 0 -1
Tag_Result2 0.0 -1.0
The result of the instruction is returned in the operand "Tag_Result" as a function value.
See also
Overview of the valid data types (Page 899)
Expressions (Page 1156)
Operators and operator precedence (Page 1161)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2001
TRUNC: Truncate numerical value
Description
The "Truncate numerical value" instruction is used to generate an integer from the input value
without rounding. The instruction selects only the integer part of the input value and returns
this part without decimal places as the function value.
Syntax
The following syntax is used for the "Truncate numerical value" instruction:
SCL
TRUNC(<Expression>)
TRUNC_<Data type>(<Expression>)
The syntax of the instruction consists of the following parts:
Parameter Declaration Data type Description
<Expression> Input Floating-point numbers Input value
_<Data type> Integers, floating-point
numbers
Default: DINT
Data type of the function value:
You do not need to specify the
data type if using the default.
Any other valid data type you
may use must be declared
explicitly.
Function value Integers, floating-point
numbers
Integer component of the input
value
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
SCL
"Tag_Result1" := TRUNC("Tag_Value1");
"Tag_Result2" := TRUNC("Tag_Value2"+"Tag_Value3");
"Tag_Result3" := TRUNC_SINT("Tag_Value4");
The result of the instruction is returned in the operand "Tag_Result" as a function value.
The following table shows how the instruction works using specific operand values:
Operand Value
Tag_Value1 -1.5
Tag_Result1 -1
Tag_Value2 2.1
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2002 System Manual, 01/2013,
Operand Value
Tag_Value3 3.2
Tag_Result2 5
Tag_Result3 2
Tag_Value4 2.4
See also
Overview of the valid data types (Page 899)
Operators and operator precedence (Page 1161)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
SCALE_X: Scale
Description
Use the "Scale" instruction to scale a floating-point number by mapping it to a specific value
range. You specify the value range with the MIN and MAX parameters. The result of the scaling
is an integer.
The following figure shows an example of how values can be scaled:
<Result>
<Expression>
MlN
MAX
0.0 1.0
The instruction "Scale" works with the following equation:
OUT = [VALUE (MAX MIN)] + MIN
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2003
Syntax
The following syntax is used for the "Scale" instruction:
SCL
SCALE_X(MIN := <Operand>,
VALUE := <Operand>,
MAX := <Operand>)
SCALE_X_<Data type>(MIN := <Operand>,
VALUE := <Operand>,
MAX := <Operand>)
The syntax of the instruction consists of the following parts:
Parameter Declaration Data type Description
MIN Input Integers, floating-point numbers Low limit of the value
range
VALUE Input Floating-point numbers Value to be scaled.
MAX Input Integers, floating-point numbers High limit of the value
range
_<Data type> Integers, floating-point numbers
Default: INT
Data type of the
function value:
You do not need to
specify the data
type if using the
default.
Any other valid data
type you may use
must be declared
explicitly.
Function value Integers, floating-point numbers Result of scaling
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
SCL
"Tag_Result1" := SCALE_X(MIN := "Tag_Value1",
VALUE := "Tag_Real",
MAX := "Tag_Value2");
"Tag_Result2" := SCALE_X_REAL(MIN := "Tag_Value1",
VALUE := "Tag_Real",
MAX := "Tag_Value2");
The result of the instruction is returned in the operand "Tag_Result" as a function value.
The following table shows how the instruction works using specific operand values:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2004 System Manual, 01/2013,
Operand Value
Tag_Real 0.5
Tag_Value1 10
Tag_Value2 30
Tag_Result1 20
Tag_Result2 20.0
See also
Overview of the valid data types (Page 899)
Operators and operator precedence (Page 1161)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
NORM_X: Normalize
Description
You can use the instruction "Normalize" to normalize the value of the tag at the VALUE input
by mapping it to a linear scale. You can use the parameters MIN and MAX to define the limits
of a value range that is applied to the scale. Depending on the location of the normalized value
in this value range, the result at output OUT is calculated and stored as a floating-point number.
If the value to be normalized equals the value at input MIN, the instruction returns returns the
result "0.0". If the value to be normalized equals the value at input MAX, the instruction returns
returns the result "1.0".
The following figure shows an example of how values can be normalized:
<Result>
<Expression>
MlN MAX
1.0
0.0
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2005
The "Normalize" instruction works with the following equation:
OUT = (VALUE MIN) / (MAX MIN)
Syntax
The following syntax is used for the "Normalize" instruction:
SCL
NORM_X(MIN := <Operand>,
VALUE := <Operand>,
MAX := <Operand>)
NORM_X_<Data type>(MIN := <Operand>,
VALUE := <Operand>,
MAX := <Operand>)
The syntax of the instruction consists of the following parts:
Parameter Declaration Data type Description
MIN Input Integers, floating-point
numbers
Low limit of the value
range
VALUE Input Integers, floating-point
numbers
Value to be normalized.
MAX Input Integers, floating-point
numbers
High limit of the value
range
_<Data type> Floating-point numbers
Default: REAL
Data type of the
function value:
You do not need to
specify the data
type if using the
default.
Any other valid data
type you may use
must be declared
explicitly.
Function value Floating-point numbers Result of the
normalization
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
SCL
"Tag_Result1" := NORM_X(MIN := "Tag_Value1",
VALUE := "Tag_InputValue",
MAX := "Tag_Value2");
"Tag_Result2" := NORM_X_LREAL(MIN := "Tag_Value1",
VALUE := "Tag_InputValue",
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2006 System Manual, 01/2013,
SCL
MAX := "Tag_Value2");
The result of the instruction is returned in the operand "Tag_Result" as a function value.
The following table shows how the instruction works using specific operand values:
Operand Value
Tag_InputValue 20
Tag_Value1 10
Tag_Value2 30
Tag_Result1 0.5
Tag_Result2 0.5
See also
Overview of the valid data types (Page 899)
Operators and operator precedence (Page 1161)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
SCALE: Scale
Description
The instruction "Scale" converts the integer on the parameter IN into a floating-point number,
which can be scaled in physical units between a low and a high limit. You use the LO_LIM and
HI_LIM parameters to specify the low limit and high limit of the value range to which the input
value is scaled. The result of the instruction is output on the OUT parameter.
The instruction "Scale" works with the following equation:
OUT = [((FLOAT (IN) K1)/(K2K1)) (HI_LIMLO_LIM)] + LO_LIM
The values of the "K1" and "K2" constants are determined by the signal state on the BIPOLAR
parameter. The following signal states are possible on the BIPOLAR parameter:
Signal state "1": It is assumed that the value at the IN parameter is bipolar and in a value
range between -27648 and 27648. In this case the "K1" constant has the value "-27648.0"
and the "K2" constant the value "+27648.0".
Signal state "0": It is assumed that the value at the IN parameter is unipolar and in a value
range between 0 and 27648. In this case the "K1" constant has the value "0.0" and the "K2"
constant the value "+27648.0".
When the value at the IN parameter is greater than the value of the "K2" constant, the result
of the instruction is set to the value of the high limit (HI_LIM) and an error is output.
When the value at the IN parameter is less than the value of the "K1" constant, the result of
the instruction is set to the value of the low limit value (LO_LIM) and an error is output.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2007
When the indicated low limit is greater than the high limit (LO_LIM >HI_LIM), the result is scaled
in reverse proportion to the input value.
Syntax
The following syntax is used for the "Scale" instruction:
SCL
SCALE(IN := <Expression>,
HI_LIM := <Operand>,
LO_LIM := <Operand>,
BIPOLAR := <Operand>,
OUT => <Operand>)
The syntax of the instruction consists of the following parts:
Parameter Declaration Data type Description
IN Input INT Input value to be scaled.
HI_LIM Input REAL High limit
LO_LIM Input REAL Low limit
BIPOLAR Input BOOL Indicates if the value at
the IN parameter is to
be interpreted as
bipolar or unipolar. The
parameter can assume
the following values:
1: Bipolar
0: Unipolar
OUT Output REAL Result of the instruction
Function value (RET_VAL) WORD Error information
For additional information on valid data types, refer to "See also".
RET_VAL Parameter
The following table shows the meaning of the values of the parameter RET_VAL:
Error code
(W#16#...)
Explanation
0000 No error
0008 The value of the parameter IN is greater than 27 648 or is less than 0 (unipolar) or -27
648 (bipolar).
8xyy For more information on errors, refer to "See also".
*The error codes can be displayed as integer or hexadecimal value in the program editor. For additional
information on toggling display formats, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2008 System Manual, 01/2013,
Example
The following example shows how the instruction works:
"Tag_ErrorCode" := SCALE(IN := "Tag_InputValue",
HI_LIM := "Tag_HighLimit"
LO_LIM := "Tag_LowLimit"
BIPOLAR := "Tag_Bipolar",
OUT => "Tag_Result");
The error information is returned in the operand "Tag_ErrorCode" as a function value.
The following table shows how the instruction works using specific operand values:
Parameter Operand Value
IN Tag_InputValue 22
HI_LIM Tag_HighLimit 100.0
LO_LIM Tag_LowLimit 0.0
BIPOLAR Tag_Bipolar 1
OUT Tag_Result 50.03978588
RET_VAL Tag_ErrorCode W#16#0000
See also
Overview of the valid data types (Page 899)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
Expressions (Page 1156)
Operators and operator precedence (Page 1161)
UNSCALE: Unscale
Description
The instruction "Unscale" unscales the floating-point number on the IN parameter in physical
units between a low and a high limit and converts them into an integer. You use the LO_LIM
and HI_LIM parameters to specify the low limit and high limit of the value range to which the
input value is unscaled. The result of the instruction is output on the OUT parameter.
The instruction "Unscale" works with the following equation:
OUT = [((INLO_LIM)/(HI_LIMLO_LIM)) (K2K1)] + K1
The values of the "K1" and "K2" constants are determined by the signal state on the BIPOLAR
parameter. The following signal states are possible on the BIPOLAR parameter:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2009
Signal state "1": It is assumed that the value at the IN parameter is bipolar and in a value
range between -27648 and 27648. In this case the "K1" constant has the value "-27648.0"
and the "K2" constant the value "+27648.0".
Signal state "0": It is assumed that the value at the IN parameter is unipolar and in a value
range between 0 and 27648. In this case the "K1" constant has the value "0.0" and the "K2"
constant the value "+27648.0".
When the value at the IN parameter is greater than the value of the "HI_LIM" constant, the
result of the instruction is set to the value of the constant (K2) and an error is output.
When the value at the IN parameter is less than the value of the constant of the low limit
(LO_LIM), the result of the instruction is set to the value of the constant (K1) and an error is
output.
Syntax
The following syntax is used for the instruction "Unscale":
SCL
UNSCALE(IN := <Expression>,
HI_LIM := <Operand>,
LO_LIM := <Operand>,
BIPOLAR := <Operand>,
OUT => <Operand>)
The syntax of the instruction consists of the following parts:
Parameter Declaration Data type Description
IN Input REAL Input value to be
unscaled to an integer
value.
HI_LIM Input REAL High limit
LO_LIM Input REAL Low limit
BIPOLAR Input BOOL Indicates if the value at
the IN parameter is to
be interpreted as
bipolar or unipolar. The
parameter can assume
the following values:
1: Bipolar
0: Unipolar
OUT Output INT Result of the instruction
Function value (RET_VAL) WORD Error information
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2010 System Manual, 01/2013,
RET_VAL Parameter
The following table shows the meaning of the values of the parameter RET_VAL:
Error code
(W#16#...)
Explanation
0000 No error
0008 The value of the IN parameter is greater than the value of the high limit (HI_LIM) or less than the value
of the low limit (LO_LIM).
8xyy For more information on errors, refer to "See also".
*The error codes can be displayed as integer or hexadecimal value in the program editor. For additional information on
toggling display formats, refer to "See also".
Example
The following example shows how the instruction works:
SCL
"Tag_ErrorCode" := UNSCALE(IN := "Tag_InputValue",
HI_LIM := "Tag_HighLimit"
LO_LIM := "Tag_LowLimit"
BIPOLAR := "Tag_Bipolar",
OUT => "Tag_Result");
The error information is returned in the operand "Tag_ErrorCode" as a function value.
The following table shows how the instruction works using specific operand values:
Parameter Operand Value
IN Tag_InputValue 50.03978588
HI_LIM Tag_HighLimit 100.0
LO_LIM Tag_LowLimit 0.0
BIPOLAR Tag_Bipolar 1
OUT Tag_Result 22
RET_VAL Tag_ErrorCode W#16#0000
See also
Overview of the valid data types (Page 899)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
Expressions (Page 1156)
Operators and operator precedence (Page 1161)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2011
Program control operations
IF: Run conditionally
Description
The instruction "Run conditionally" branches the program flow depending on a condition. The
condition is an expression with Boolean value (TRUE or FALSE). Logical expression or
comparative expressions can be stated as conditions.
When the instruction is executed, the stated expressions are evaluated. If the value of an
expression is TRUE, the condition is fulfilled; if the value is FALSE, it is not fulfilled.
Syntax
Depending on the type of branch, you can program the following forms of the instruction:
Branch through IF:
SCL
IF <Condition> THEN <Instructions>
END_IF;
If the condition is satisfied, the instructions programmed after the THEN are executed. If the
condition is not satisfied, the execution of the program continues with the next instruction after
the END_IF.
Branch through IF and ELSE:
SCL
IF <Condition> THEN <Instructions1>
ELSE <Instructions0>;
END_IF;
If the condition is satisfied, the instructions programmed after the THEN are executed. If the
condition is not satisfied, the instructions programmed after the ELSE are executed. Then the
execution of the program continues with the next instruction after the END_IF.
Branch through IF, ELSIF and ELSE:
SCL
IF <Condition1> THEN <Instructions1>
ELSIF <Condition2> THEN <Instruction2>
ELSE <Instructions0>;
END_IF;
If the first condition (<Condition1>) is satisfied, the instructions (<Instructions1>) after the
THEN are executed. After execution of the instructions, the execution of the program continues
after the END_IF.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2012 System Manual, 01/2013,
If the first condition is not satisfied, the second condition (<Condition2>) is checked. If the
second condition (<Condition2>) is fulfilled, the instructions (<Instructions2>) after the THEN
are executed. After execution of the instructions, the execution of the program continues after
the END_IF.
If none of the conditions are fulfilled, the instructions (<Instructions0>) after ELSE are executed
followed by the execution of the program after END_IF.
You can nest as many combinations of ELSIF and THEN as you like within the IF instruction.
The programming of an ELSE branch is optional.
The syntax of the IF instruction consists of the following parts:
Parameter Data type Description
<Condition> BOOL Expression to be evaluated
<Instructions> - Instructions to be executed with satisfied condition. An
exception are instructions programmed after the ELSE. These
are executed if no condition within the program loop is satisfied.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
SCL
IF "Tag_1" = 1
THEN "Tag_Value" := 10;
ELSIF "Tag_2" = 1
THEN "Tag_Value" := 20;
ELSIF "Tag_3" = 1
THEN "Tag_Value" := 30;
ELSE "Tag_Value" := 0;
END_IF;
The following table shows how the instruction works using specific operand values:
Operand Value
Tag_1 1 0 0 0
Tag_2 0 1 0 0
Tag_3 0 0 1 0
Tag_Value 10 20 30 0
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2013
See also
Operators and operator precedence (Page 1161)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
Overview of the valid data types (Page 899)
CASE: Create multiway branch
Description
The instruction "Create multiway branch" executes one of several instruction sequences
depending on the value of a numerical expression.
The value of the expression must be an integer. When the instruction is executed, the value
of the expression is compared with the values of several constants. If the value of the
expression agrees with the value of a constant, the instructions programmed directly after this
constant are executed. The constants can assume the following values:
An integer (for example, 5)
A range of integers (for example, 15..20)
An enumeration consisting of integers and ranges (for example, 10, 11, 15..20)
Syntax
The following syntax is used for the "Create multiway branch" instruction:
SCL
CASE <expression> OF
<Constant1>: <Instructions1>
<Constant2>: <Instructions2>
<ConstantX>: <InstructionsX>; // X >=3
ELSE <Instructions0>;
END_CASE;
The syntax of the instruction consists of the following parts:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2014 System Manual, 01/2013,
Parameter Data type Description
<expression> Integers Value which is compared to the programmed constant values.
<Constant> Integers Constant values which form the condition for the execution of
an instruction sequence. The constants can assume the
following values:
An integer (for example, 5)
A range of integers (for example, 15..20)
An enumeration consisting of integers and ranges (for
example, 10, 11, 15..20)
<Instruction> - Any instructions which are executed if the value of the
expression agrees with the value of a constant. An exception
are instructions programmed after the ELSE. These
instructions are executed if the values do not agree.
For additional information on valid data types, refer to "See also".
If the value of the expression agrees with the value of the first constant (<Constant1>), the
instructions (<Instructions1>) which are programmed directly after the first constant are
executed. Program execution subsequently resumes after the END_CASE.
If the value of the expression does not agree with the value of the first constant (<Constant1>),
this value is compared to the value of the constant which is programmed next. In this way, the
CASE instruction is executed until the values agree. If the value of the expression does not
correspond to any of the programmed constant values, the instructions (<Instructions0>) which
are programmed after the ELSE are executed. ELSE is an optional part of the syntax and can
be omitted.
The CASE instruction can also be nested by replacing an instruction block with CASE.
END_CASE represents the end of the CASE instruction.
Example
The following example shows how the instruction works:
SCL
CASE "Tag_Value" OF
0 :
"Tag_1" := 1;
1,3,5 :
"Tag_2" :=1;
6..10 :
"Tag_3" := 1;
16,17,20..25 :
"Tag_4" := 1;
ELSE "Tag_5" := 1;
END_CASE;
The following table shows how the instruction works using specific operand values:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2015
Operand Values
Tag_Value 0 1, 3 , 5 6, 7, 8, 9, 10 16,17, 20, 21,
22, 23, 24, 25
2
Tag_1 1 - - - -
Tag_2 - 1 - - -
Tag_3 - - 1 - -
Tag_4 - - - 1 -
Tag_5 - - - - 1
1: The operand is set to the signal state "1".
-: The signal state of the operand remains unaltered.
See also
CONTINUE: Recheck loop condition (Page 2021)
Overview of the valid data types (Page 899)
Operators and operator precedence (Page 1161)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
EXIT: Exit loop immediately (Page 2022)
FOR: Run in counting loop
Description
The instruction "Run in counting loop" causes repeated execution of a program loop until a run
variable lies within a specified value range.
Program loops can also be nested. Within a program loop, you can program additional program
loops with other run variables.
The current continuous run of a program loop can be ended by the instruction "Recheck loop
condition" (CONTINUE). The instruction "Exit loop immediately" (EXIT) ends the entire loop
execution. For additional information on this topic, refer to "See also".
Syntax
The following syntax is used for the "Run in counting loop" instruction:
SCL
FOR <Run_tag> := <Start_value> TO <End_value> BY <Increment> DO
<Instructions>
END_FOR;
The syntax of the FOR instruction consists of the following parts:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2016 System Manual, 01/2013,
Parameter Data type Description
<Run tag> SINT, INT,
DINT, LINT
Operand whose value is evaluated with the loop execution. The
data type of the run tag determines the data type of the other
parameters.
<Start value> SINT, INT,
DINT, LINT
Expression whose value is allocated at the start of the loop
execution of the run tags.
<End value> SINT, INT,
DINT, LINT
Expression whose value defines the last run of the program
loop. The value of the run variable is checked after each loop:
End value not reached:
The instructions according to DO are executed
End value is reached:
The FOR loop is executed one last time
End value exceeded:
The FOR loop is completed
An alteration to the end value is not permitted during execution
of the instruction.
<Increment> SINT, INT,
DINT, LINT
Expression by whose value the run tag is increased (positive
increment) or decreased (negative increment) after each loop.
Specification of the increment is optional. If no increment is
given, the value of the run tag is increased by 1 after each loop.
An alteration of the increment is not permitted during execution
of the instruction.
<Instructions> - Instructions which are carried out with each loop, as long as
the value of the run tag lies within the value range. The value
range is defined by the start and end values.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
SCL
FOR i :
= 2 TO 8 BY 2
DO "a_array[i] := "Tag_Value"*"b_array[i]";
END_FOR;
The operand "Tag_Value" is multiplied with the elements (2, 4, 6, 8) of the ARRAY tag
"b_array". The result is read in to the elements (2, 4, 6, 8) of the ARRAY tag "a_array".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2017
See also
CONTINUE: Recheck loop condition (Page 2021)
EXIT: Exit loop immediately (Page 2022)
Overview of the valid data types (Page 899)
Operators and operator precedence (Page 1161)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
WHILE: Run if condition is met
Description
The instruction "Run if condition is met" causes a program loop to be repeatedly executed until
the implementation condition is satisfied. The condition is an expression with Boolean value
((TRUE or FALSE). Logical expression or comparative expressions can be stated as
conditions.
When the instruction is executed, the stated expressions are evaluated. If the value of an
expression is TRUE, the condition is fulfilled; if the value is FALSE, it is not fulfilled.
Program loops can also be nested. Within a program loop, you can program additional program
loops with other run variables.
The current continuous run of a program loop can be ended by the instruction "Recheck loop
condition" (CONTINUE). The instruction "Exit loop immediately" (EXIT) ends the entire loop
execution. For additional information on this topic, refer to "See also".
Syntax
The following syntax is used for the "Run if condition is met" instruction:
SCL
WHILE <Condition> DO <Instructions>
END_WHILE;
The syntax of the WHILE instruction consists of the following parts:
Parameter Data type Description
<Condition> BOOL Expression which is evaluated before each loop.
<Instructions> - Instructions to be executed with satisfied condition. If the
condition has not been satisfied, program execution continues
after END_WHILE.
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2018 System Manual, 01/2013,
Example
The following example shows how the instruction works:
SCL
WHILE
"Tag_Value1" <> "Tag_Value2"
DO "Tag_Result"
:= "Tag_Input";
END_WHILE;
As long as the values of the operands "Tag_Value1" and "Tag_Value2" do not match, the value
of the operand "Tag_Input" is allocated to the operand "Tag_Result".
See also
EXIT: Exit loop immediately (Page 2022)
Operators and operator precedence (Page 1161)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
CONTINUE: Recheck loop condition (Page 2021)
Overview of the valid data types (Page 899)
REPEAT: Run if condition is not met
Description
The instruction "Run if condition is not met" causes a program loop to be repeatedly executed
until a termination condition is met. The condition is an expression with Boolean value (TRUE
or FALSE). Logical expression or comparative expressions can be stated as conditions.
When the instruction is executed, the stated expressions are evaluated. If the value of an
expression is TRUE, the condition is fulfilled; if the value is FALSE, it is not fulfilled.
The instructions are executed once, even if the termination condition is fulfilled.
Program loops can also be nested. Within a program loop, you can program additional program
loops with other run variables.
The current continuous run of a program loop can be ended by the instruction "Recheck loop
condition" (CONTINUE). The instruction "Exit loop immediately" (EXIT) ends the entire loop
execution. For additional information on this topic, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2019
Syntax
The following syntax is used for the "Run if condition is not met" instruction:
SCL
REPEAT <Instructions>
UNTIL <Condition> END_REPEAT;
The syntax of the REPEAT instruction consists of the following parts:
Parameter Data type Description
<Instructions> - Instructions that are executed as long as the programmed
condition has the value FALSE. The instructions are executed
once, even if the termination condition is fulfilled.
<Condition> BOOL Expression which is evaluated after each loop. If the expression
has the value FALSE, the program loop is executed once again.
If the expression has the value TRUE, the program loop
continues after END_REPEAT.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
SCL
REPEAT "Tag_Result"
:= "Tag_Value";
UNTIL "Tag_Error"
END_REPEAT;
As long as the value of the operand "Tag_Error" has the signal state "0", the value of the
operand "Tag_Value" is allocated to the operand "Tag_Result".
See also
CONTINUE: Recheck loop condition (Page 2021)
EXIT: Exit loop immediately (Page 2022)
Operators and operator precedence (Page 1161)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
Overview of the valid data types (Page 899)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2020 System Manual, 01/2013,
CONTINUE: Recheck loop condition
Description
The "Recheck loop condition" instruction ends the current program run of a FOR, WHILE or
REPEAT loop.
After execution of the instruction, the conditions for the continuation of the program loop are
evaluated again. The instruction affects the program loop which directly contains the instruction.
Syntax
The following syntax is used for the "Recheck loop condition" instruction:
SCL
CONTINUE;
Example
The following example shows how the instruction works:
SCL
FOR i
:= 1 TO 15 BY 2 DO
IF (i < 5) THEN
CONTINUE;
END_IF;
"DB10".Test[i] := 1;
END_FOR;
For additional information on valid data types, refer to "See also".
If the condition i < 5 is satisfied, then the subsequent value allocation ("DB10".Test[i] := 1) will
not be executed. The run variable (i) is increased by the increment of "2" and checked to see
whether its current value lies in the programmed value range. If the run variable lies in the
value range, the IF condition is evaluated again.
If the condition i < 5 is not satisfied, then the subsequent value allocation ("DB10".Test[i] := 1)
will be executed and a new loop started. In this case, the run variable is also increased by the
increment "2" and checked.
See also
Operators and operator precedence (Page 1161)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
EXIT: Exit loop immediately (Page 2022)
Overview of the valid data types (Page 899)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2021
EXIT: Exit loop immediately
Description
The instruction "Exit loop immediately" cancels the execution of a FOR, WHILE or REPEAT
loop at any point regardless of conditions. The execution of the program is continued after the
end of the loop (END_FOR, END_WHILE, END_REPEAT).
The instruction affects the program loop which directly contains the instruction.
Syntax
The following syntax is used for the "Exit loop immediately" instruction:
SCL
EXIT;
Example
The following example shows how the instruction works:
SCL
FOR i := 15 TO 1 BY -2 DO
IF (i < 5)
THEN EXIT;
END_IF;
"DB10".Test[i] := 1;
END_FOR;
For additional information on valid data types, refer to "See also".
If the condition i < 5 is satisfied, then the execution of the loop will be cancelled. Program
execution resumes after the END_FOR.
If the condition i < 5 is not satisfied, then the subsequent value allocation ("DB10".Test[i] := 1)
will be executed and a new loop started. The run tag (i) is decreased by the increment of "-2"
and it is checked whether its current value lies in the programmed value range. If the (i) run
variable lies within the value range, the IF condition is evaluated again.
See also
Operators and operator precedence (Page 1161)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
CONTINUE: Recheck loop condition (Page 2021)
Overview of the valid data types (Page 899)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2022 System Manual, 01/2013,
GOTO: Jump
Description
Use the instruction "Jump" to resume the execution of a program at a given point marked with
a jump label.
The jump labels and the instruction "Jump" must be in the same block. The name of a jump
label can only be assigned once within a block. Each jump label can be the target of several
jump instructions.
A jump from the "outside" into a program loop is not permitted, but a jump from a loop to the
"outside" is possible.
Syntax
Use the following syntax for the "Jump" instruction:
SCL
GOTO <Jump label>
...
<Jump label>: <Instructions>
The syntax of the GOTO instruction consists of the following parts:
Parameter Data type Description
<jump label> - Jump label to be jumped to
<Instructions> - Instructions which are executed after the jump.
Example
The following example shows how the instruction works:
SCL
CASE "Tag_Value" OF
1 : GOTO MyLABEL1;
2 : GOTO MyLABEL2;
3 : GOTO MyLABEL3;
ELSE GOTO MyLABEL4;
END_CASE;
MyLABEL1: "Tag_1" := 1;
MyLABEL2: "Tag_2" := 1;
MyLABEL3: "Tag_3" := 1;
MyLABEL4: "Tag_4" := 1;
Depending on the value of the "Tag_Value" operand, the execution of the program will resume
at the point identified by the corresponding jump label. If the operand "Tag_Value" has the
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2023
value 2, for example, program execution will resume at the jump label "MyLABEL2". The
program line identified by the jump label "MyLABEL1" will be skipped in this case.
See also
Operators and operator precedence (Page 1161)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
Overview of the valid data types (Page 899)
RETURN: Exit block
Description
The instruction "Exit block" exits the program execution in the currently edited block and
continues in the calling block.
The instruction can be omitted at the end of the block.
Syntax
The following syntax is used for the "Exit block" instruction:
SCL
RETURN;
Example
The following example shows how the instruction works:
SCL
IF "Tag_Error" <>0 THEN RETURN;
END_IF;
If the signal state of the "Tag_Error" operand is not zero, execution of the program ends in the
block currently being processed.
See also
Operators and operator precedence (Page 1161)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
Overview of the valid data types (Page 899)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2024 System Manual, 01/2013,
(*...*): Inserting a comment section
Description
You can use the "Insert comment section" instruction to add a comment section. The text within
the parenthesis "(*...*)" is handled as a comment.
Syntax
The following syntax is used for the "Insert comment section" instruction:
SCL
(*...*)
Example
The following example shows how the instruction works:
SCL
(*This is a comment section.*)
See also
Operators and operator precedence (Page 1161)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
Overview of the valid data types (Page 899)
Runtime control
STP: Exit program
Description
The "Exit program" instruction is used to set the CPU to STOP mode and therefore to terminate
the execution of the program. The effects of changing from RUN to STOP depend on the CPU
configuration.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2025
Syntax
The following syntax is used for the instruction "Exit program":
SCL
STP()
See also
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
RE_TRIGR: Restart cycle monitoring time
Description
The instruction "Restart cycle monitoring time" restarts the cycle monitoring of the CPU. The
cycle time monitoring then restarts with the time you have set in the CPU configuration.
The instruction "Restart cycle monitoring time" can be called, regardless of the priority, in all
blocks.
If the instruction is called in a block with a higher priority, such as a hardware interrupt,
diagnostic interrupt, or cyclic interrupt, the instruction is not executed and the ENO enable
output is set to signal state "0".
The instruction "Restart cycle monitoring time" can be called a maximum of 10 times in a
program cycle.
Note
Make sure that you do not create an infinite loop in the cyclical program processing, i.e. in
OB1, when you use the instruction "Restart cycle monitoring time". Otherwise the CPU will
not reach the cycle control point. As a result, it may not be possible to execute certain CPU
functions (e.g. process image update).
Note
If the instruction "Restart cycle monitoring time" is started more than 30 times within a LOOP
instruction, the CPU switches to STOP because of a runtime error.
Syntax
The following syntax is used for the "Restart cycle monitoring time" instruction:
SCL
RE_TRIGR()
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2026 System Manual, 01/2013,
See also
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
GetError: Get error locally
Description
The instruction "Get error locally" queries the occurrence of errors within a block. If the system
signals errors during block execution, the instruction gives detailed information about the first
error that occurred.
The error information can only be saved in operands of the "ErrorStruct" system data type.
The system data type "ErrorStruct" specifies the exact structure in which the information about
the error is stored. Use additional instructions to evaluate this structure and program an
appropriate response. When the first error has been eliminated, the instruction issues
additional information about the next error that has occurred.
Note
The instruction "Get error locally" enables local error handling within a block. If "Get error
locally" is inserted into the program code of a block, any predefined system responses are
ignored if an error occurs.
Syntax
The following syntax is used for the instruction "Get error locally":
SCL
<Error information> := GET_ERROR()
The syntax of the instruction consists of the following parts:
Parameter Data type Description
Function value ErrorStruct Information about errors that have occurred
Data type "ErrorStruct"
The following table shows the structure of the data type ErrorStruct:
Structure component Data type Description
ERROR_ID WORD Error ID
FLAGS BYTE Shows if an error occurred during a block call.
16#01: Error during a block call.
16#00: No error during a block call.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2027
Structure component Data type Description
REACTION BYTE Default reaction:
0: Ignore (write error),
1: Continue with substitute value "0" (read error),
2: Skip instruction (system error)
CODE_ADDRESS CREF Information on address and type of block
BLOCK_TYPE BYTE Type of block where the error occurred:
1: OB
2: FC
3: FB
CB_NUMBER UINT Number of the code block
OFFSET UDINT Reference to the internal memory
MODE BYTE Access mode: Depending on the type of access, the
following information can be output:
Mode (A) (B) (C) (D) (E)
0
1 Offset
2 Area
3 Location Scope Numb
er
4 Area Offset
5 Area DB no. Offset
6 PtrNo./
Acc
Area DB no. Offset
7 PtrNo./
Acc
Slot
No. /
Scope
Area DB no. Offset
OPERAND_NUMBER UINT Operand number of the machine command
POINTER_NUMBER_LOCATION UINT (A) Internal pointer
SLOT_NUMBER_SCOPE UINT (B) Storage area in internal memory
DATA_ADDRESS NREF Information about the address of an operand
AREA BYTE (C) Memory area:
L: 16#40 4E, 86, 87, 8E, 8F, C0 CE
E: 16#81
A: 16#82
M: 16#83
DB: 16#84, 85, 8A, 8B
DB_NUMBER UINT (D) Number of the data block
OFFSET UDINT (E) Relative address of the operand
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2028 System Manual, 01/2013,
Structure component "ERROR_ID"
The following table shows the values that can be output at the structure component
"ERROR_ID":
ID*
(hexadecimal)
ID*
(decimal)
Description
0 0 No error
2503 9475 Invalid pointer
2505 9477 Calling the instruction "Stop" (SFC46) in the user program
2520 9504 Invalid STRING
2522 9506 Read errors: Operand outside the valid range
2523 9507 Write errors: Operand outside the valid range
2524 9508 Read errors: Invalid operand
2525 9509 Write errors: Invalid operand
2528 9512 Read errors: Data alignment
2529 9513 Write errors: Data alignment
252C 9516 Invalid pointer
2530 9520 Write errors: Data block
2533 9523 Invalid pointer used
2534 9524 Block number error FC
2535 9525 Block number error FB
2538 9528 Access error: DB does not exist
2539 9529 Access error: Wrong DB used
253A 9530 Global data block does not exist
253C 9532 Faulty information or the function does not exist
253D 9533 System function does not exist
253E 9534 Faulty information or the function block does not exist
253F 9535 System block does not exist
2550 9552 Access error: DB does not exist
2551 9553 Access error: Wrong DB used
2575 9589 Error in the program nesting depth
2576 9590 Error in the local data distribution
2942 10562 Read errors: Input
2943 10563 Write errors: Output
*The error codes can be displayed as integer or hexadecimal value in the program editor. For additional
information on toggling display formats, refer to "See also".
The instruction "Get error locally" can also be used to forward an alarm about the error status
to the calling block. To do this, you have to program the instruction at the end of the called
block.
See also
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2029
GetErrorID: Get error ID locally
Description
The instruction "Get error ID locally" queries the occurrence of errors within a block. If the
system signals errors during block execution, the error ID of the first error that has occurred
is given. The error ID can only be saved in operands of the WORD data type. When the first
error has been eliminated, the instruction outputs the error ID of the next error that occurred.
The instruction "Get error ID locally" can also be used to forward an alarm about the error
status to the calling block. To do this, you have to program the instruction at the end of the
called block.
Note
The instruction "Get error ID locally" enables local error handling within a block. If the
instruction "Get error ID locally" is inserted in the program code of a block, any predefined
system responses are ignored if an error occurs.
Syntax
The following syntax is used for the instruction "Get error ID locally":
SCL
<Error_ID> := GET_ERR_ID()
The syntax of the instruction consists of the following parts:
Parameter Data type Description
Function value WORD Error ID
Error ID
The following table shows the values that can be output:
ID*
(hexadecimal)
ID*
(decimal)
Description
0 0 No error
2503 9475 Invalid pointer
2505 9477 Calling the instruction "Stop" (SFC46) in the user program
2520 9504 Invalid STRING
2522 9506 Read errors: Operand outside the valid range
2523 9507 Write errors: Operand outside the valid range
2524 9508 Read errors: Invalid operand
2525 9509 Write errors: Invalid operand
2528 9512 Read errors: Data alignment
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2030 System Manual, 01/2013,
ID*
(hexadecimal)
ID*
(decimal)
Description
2529 9513 Write errors: Data alignment
252C 9516 Invalid pointer
2530 9520 Write errors: Data block
2533 9523 Invalid pointer used
2534 9524 Block number error FC
2535 9525 Block number error FB
2538 9528 Access error: DB does not exist
2539 9529 Access error: Wrong DB used
253A 9530 Global data block does not exist
253C 9532 Faulty information or the function does not exist
253D 9533 System function does not exist
253E 9534 Faulty information or the function block does not exist
253F 9535 System block does not exist
2550 9552 Access error: DB does not exist
2551 9553 Access error: Wrong DB used
2575 9589 Error in the program nesting depth
2576 9590 Error in the local data distribution
2942 10562 Read errors: Input
2943 10563 Write errors: Output
*The error codes can be displayed as integer or hexadecimal value in the program editor. For additional
information on toggling display formats, refer to "See also".
See also
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
INIT_RD: Initialize all retain data
Description
The "Initialize all retain data" instruction is used to reset the retentive data of all data blocks,
bit memories and SIMATIC timers and counters at the same time. The instruction can only be
executed within a startup OB because the execution exceeds the program cycle duration.
Syntax
Use the following syntax for the "Initialize all retain data" instruction:
SCL
INIT_RD(REQ := <Operand>
RET_VAL := <Operand>)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2031
The syntax of the instruction consists of the following parts:
Parameter Declaration Data type Memory area Description
REQ Input BOOL I, Q, M, D, L If the input "REQ"
has the signal
state "1", all
retentive data are
reset.
RET_VAL Output INT I, Q, M, D, L Error information:
If an error occurs
during the
execution of the
instruction, an
error code is
output at the
RET_VAL
parameter.
For additional information on valid data types, refer to "See also".
RET_VAL Parameter
The following table shows the meaning of the values of the parameter RET_VAL:
Error code*
(W#16#...)
Explanation
0000 No error
80B5 The instruction cannot be executed because it was not programmed within a startup OB.
8xyy For more information on errors, refer to "See also".
*The error codes can be displayed as integer or hexadecimal value in the program editor. For additional information on
toggling display formats, refer to "See also".
Example
The following example shows how the instruction works:
SCL
INIT_RD(REQ := "Tag_REQ",
RET_VAL := "Tag_Result");
If the operand "Tag_REQ" has the signal state "1", the instruction is executed. All retentive
data of all data blocks, bit memories and SIMATIC timers and counters are reset.
See also
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
Overview of the valid data types (Page 899)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2032 System Manual, 01/2013,
WAIT: Configure time delay
Description
The instruction "Configure time delay" pauses the program execution for a specific period of
time. You indicate the period of time in microseconds on the WT parameter of the instruction.
You can configure time delays of up to 32 767 microseconds (s). The shortest possible time
delay depends on the respective CPU and corresponds to the execution time of the instruction
"Configure time delay".
The execution of the instruction can be interrupted by higher priority events.
The instruction "Configure time delay" supplies no error information.
Syntax
The following syntax is used for the instruction "Configure time delay":
SCL
WAIT(WT:= <Operand>)
The syntax of the instruction consists of the following parts:
Parameter Declaration Data type Description
WT Input INT Time delay in microseconds (s)
See also
Overview of the valid data types (Page 899)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
RUNTIME: Measure program runtime
Description
The "Measure program runtime" instruction is used to measure the runtime of the entire
program, individual blocks or command sequences.
If you want to measure the runtime of your entire program, call the instruction "Measure
program runtime" in OB1. Measurement of the runtime is started with the first call and the
output RET_VAL returns the runtime of the program after the second call. The measured
runtime includes all CPU processes that can occur during the program execution, for example,
interruptions caused by higher-level events or communication. The instruction "Measure
program runtime" reads an internal counter of the CPU and writes the value to the in/out
parameter. The instruction calculates the current program runtime according to the internal
counter frequency and writes it to output RET_VAL.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2033
If you want to measure the runtime of individual blocks or individual command sequences, you
need three separate networks. Call the instruction "Measure program runtime" in an individual
network within your program. You set the starting point of the runtime measurement with this
first call of the instruction. Then you call the required program block or the command sequence
in the next network. In another network, call the "Measure program runtime" instruction a
second time and assign the same memory to the in/out parameter as you did during the first
call of the instruction. The "Measure program runtime" instruction in the third network reads
an internal CPU counter and calculates the current runtime of the program block or the
command sequence according to the internal counter frequency and writes it to the output
RET_VAL.
Note
The runtime of a command sequence cannot be determined exactly, because the sequence
of instructions within a command sequence is changed during optimized compilation of the
program.
The "Measure program runtime" instruction has no error information.
Syntax
The following syntax is used for the "Measure program runtime" instruction:
SCL
RUNTIME(<Operand>)
The syntax of the instruction consists of the following parts:
Parameter Declaration Data type Description
<Operand> InOut LREAL Saves the starting point
of the runtime
measurement.
Function value
LREAL Returns the measured
runtime in seconds
For additional information on valid data types, refer to "See also".
Example
The following example shows the how the instruction works based on the runtime calculation
of a program block:
SCL
"Tag_Result" := RUNTIME("Tag_Memory");
"Best_before_date_DB" ();
"Tag_Result" := RUNTIME("Tag_Memory");
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2034 System Manual, 01/2013,
The starting point for the runtime measurement is set with the first call of the instruction and
buffered as reference for the second call of the instruction in the "TagMemory" operand.
The "Best_before_date" program block FB1 is called.
When the program block FB1 has been processed, the instruction is executed a second time.
The second call of the instruction calculates the runtime of the program block and writes the
result to the output "Tag_Result".
See also
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
Overview of the valid data types (Page 899)
Word logic operations
DECO: Decode
Description
The instruction "Decode" sets a bit specified by the input value in the output value.
The instruction "Decode" reads the value of the parameter IN and sets the bit in the output
value, whose bit position corresponds to the read value. The other bits in the output value are
filled with zeroes. If the value of the IN parameter is greater than 31, a modulo 32 instruction
is executed.
Syntax
The following syntax is used for the instruction "Decode":
SCL
DECO(IN := <Expression>)
DECO_WORD(IN := <Expression>)
The syntax of the instruction consists of the following parts:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2035
Parameter Declaration Data type Description
IN Input UINT Position of the bit in the
output value which is
set.
_<Data type> Bit strings
default: DWORD
Data type of the
function value:
You do not need to
specify the data
type if using the
default.
Any other valid data
type you may use
must be declared
explicitly.
Function value Bit strings Current output value
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
SCL
"Tag_Result" := DECO(IN := "Tag_Value");
"Tag_Result2" := DECO_BYTE(IN := "Tag_Value2");
The following figure shows how the instruction works using specific operand values:
0000 0000 0000 0000 0000 0000 0000 1000
3 ... 0 15 ... ... 16 31 ...
3 "Tag_Value"
"Tag_Result"
The instruction reads the number "3" from the value of the operand "Tag_Value" and sets the
third bit to the value of the operand "Tag_Result".
See also
Overview of the valid data types (Page 899)
Operators and operator precedence (Page 1161)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2036 System Manual, 01/2013,
ENCO: Encode
Description
The instruction "Encode" reads the bit number of the lowest-value bit set in the input value and
issues this as a result.
Syntax
The following syntax is used for the instruction "Encode":
SCL
ENCO(IN := <Expression>)
The syntax of the instruction consists of the following parts:
Parameter Declaration Data type Description
IN Input Bit strings Input value
Function value INT Bit number of the bit in
the input value that is
read out.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
SCL
"Tag_Result" := ENCO(IN := "Tag_Value");
The following figure shows how the instruction works using specific operand values:
0000 1111 0000 0101 0000 1001 0000 1000
3 ... 0 15 ... ... 16 31 ...
3
"Tag_Value"
"Tag_Result"
The instruction reads the lowest-value set bit of the operand "Tag_Value" and writes the bit
position "3" in the operand "Tag_Result".
See also
Overview of the valid data types (Page 899)
Operators and operator precedence (Page 1161)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2037
SEL: Select
Description
The instruction "Select" selects one of the parameters IN0 or IN1 depending on a switch (G
parameter) and issues its content as a result. When the parameter G has the signal status "0",
the value at parameter IN0 is moved. When the parameter G has the signal status "1", the
value at parameter IN1 is moved and returned as a function value.
The instruction is only executed if the tags of all parameters are of the same data type class.
Syntax
The following syntax is used for the instruction "Select":
SCL
SEL(G:= <Expression>,
IN0 := <Expression>,
IN1 := <Expression>)
The syntax of the instruction consists of the following parts:
Parameter Declaration Data type
S7-1200 S7-1500 Description
G Input BOOL BOOL Switch
IN0 Input Bit strings, integers,
floating-point
numbers, TIME,
TOD, DATE, CHAR,
DT
Bit strings, integers,
floating-point
numbers, CHAR,
timers, DATE,
TOD, LTOD, DT,
LDT
First input value
IN1 Input Bit strings, integers,
floating-point
numbers, TIME,
TOD, DATE, CHAR,
DT
Bit strings, integers,
floating-point
numbers, CHAR,
timers, DATE,
TOD, LTOD, DT,
LDT
Second input value
Function value Bit strings, integers,
floating-point
numbers, TIME,
TOD, DATE, CHAR,
DT
Bit strings, integers,
floating-point
numbers, CHAR,
timers, DATE,
TOD, LTOD, DT,
LDT
Result of the
instruction
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2038 System Manual, 01/2013,
Example
The following example shows how the instruction works:
SCL
"Tag_Result" := SEL(G := "Tag_Value",
IN0 := "Tag_0",
IN1 := "Tag_1");
The result of the instruction is returned in the operand "Tag_Result" as a function value.
The following table shows how the instruction works using specific operand values:
Operand Value
Tag_Value 0 1
Tag_0 W#16#0000 W#16#4C
Tag_1 W#16#FFFF D#16#5E
Tag_Result W#16#0000 D#16#5E
See also
Overview of the valid data types (Page 899)
Operators and operator precedence (Page 1161)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
MUX: Multiplex
Description
The "Multiplex" instruction copies the value of a selected input parameter and issues it. Use
the parameter K to determine the number of the input parameter whose value will be moved.
Numbering starts at IN1 and is incremented continuously with each new input. You can declare
up to 32 input parameters when you use a CPU S7-1200 and a maximum of 256 input
parameters when you use a CPU S7-1500.
If the value of the K parameter is greater than the number of inputs and the INELSE parameter
is not set, the instruction function value is invalid and the ENO enable output is set to 0.
Numerical data types and time data types are permitted at the inputs. All tags with assigned
parameters must be of the same data type.
Syntax
The following syntax is used for the instruction "Multiplex":
SCL
MUX(K := <Expression>,
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2039
SCL
IN1 := <Expression>,
IN2 := <Expression>,
INELSE := <Expression>)
The syntax of the instruction consists of the following parts:
Parameter Declaration Data type Description
S7-1200 S7-1500
K Input Integers Integers Specifies the
parameter whose
content is to be
transferred.
If K = 0 =>
Parameter IN0
If K = 1 =>
Parameter
IN1, etc.
IN1 Input Binary numbers,
integers, floating-
point numbers,
strings, TOD,
DATE, TIME, DT
Binary numbers,
integers, floating-
point numbers,
strings, TOD,
LTOD, DATE,
timers, DT, LDT
First input value
IN2 Input Binary numbers,
integers, floating-
point numbers,
strings, TOD,
DATE, TIME, DT
Binary numbers,
integers, floating-
point numbers,
strings, TOD,
LTOD, DATE,
timers, DT, LDT
Second input value
INn Input Binary numbers,
integers, floating-
point numbers,
strings, TOD,
DATE, TIME, DT
Binary numbers,
integers, floating-
point numbers,
strings, TOD,
LTOD, DATE,
timers, DT, LDT
Optional input
values
INELSE Input Binary numbers,
integers, floating-
point numbers,
strings, TOD,
DATE, TIME, DT
Binary numbers,
integers, floating-
point numbers,
strings, TOD,
LTOD, DATE,
timers, DT, LDT
Specifies the
value to be copied
when K <> n.
Function value
Binary numbers,
integers, floating-
point numbers,
strings, TOD,
DATE, TIME, DT
Binary numbers,
integers, floating-
point numbers,
strings, TOD,
LTOD, DATE,
timers, DT, LDT
Result of the
instruction
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2040 System Manual, 01/2013,
Example
The following example shows how the instruction works:
SCL
"Tag_Result" := MUX(K := "Tag_Number",
IN1 := "Tag_1",
IN2 := "Tag_2",
INELSE := "Tag_3");
The result of the instruction is returned in the operand "Tag_Result" as a function value.
The following table shows how the instruction works using specific operand values:
Operand Value
Tag_Number 2 4
Tag_1 DW#16#00000000 DW#16#00000000
Tag_2 DW#16#003E4A7D DW#16#003E4A7D
Tag_3 DW#16#FFFF0000 DW#16#FFFF0000
Tag_Result DW#16#003E4A7D DW#16#FFFF0000
See also
Overview of the valid data types (Page 899)
Operators and operator precedence (Page 1161)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
DEMUX: Demultiplex
Description
The "Demultiplex" instruction transfers the value of the input parameter IN to a selected output
parameter. The selection of the input parameter takes place independently of the parameter
value K. The K parameter specifies the output parameter number to which the value of the
input parameter IN is transferred. The other output parameters are not changed. Numbering
starts at OUT1 and continues consecutively with each new output. You can declare a maximum
of 32 output parameters.
If the value of the K parameter is greater than the number of output parameters, the value of
the input parameter IN is transferred to the output parameter OUTELSE.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2041
Syntax
The following syntax is used for the instruction "Demultiplex":
SCL
DEMUX(K := <Expression>,
IN := <Expression>,
OUT1 := <Operand>,
OUT2 := <Operand>,
OUTELSE := <Operand>)
The syntax of the instruction consists of the following parts:
Parameter Declaration Data type Description
S7-1200 S7-1500
K Input Integers Integers Specifies the
output to which the
input value (IN)
will be copied.
If K = 0 =>
Parameter
OUT0
If K = 1 =>
Parameter
OUT1, etc.
IN Input Binary numbers,
integers, floating-
point numbers,
strings, TIME,
TOD, DATE, DT
Binary numbers,
integers, floating-
point numbers,
strings, timers,
TOD, LTOD,
DATE, DT, LDT
Input value
OUT0 Output Binary numbers,
integers, floating-
point numbers,
strings, TIME,
TOD, DATE, DT
Binary numbers,
integers, floating-
point numbers,
strings, timers,
TOD, LTOD,
DATE, DT, LDT
First output
OUT1 Output Binary numbers,
integers, floating-
point numbers,
strings, TIME,
TOD, DATE, DT
Binary numbers,
integers, floating-
point numbers,
strings, timers,
TOD, LTOD,
DATE, DT, LDT
Second output
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2042 System Manual, 01/2013,
Parameter Declaration Data type Description
S7-1200 S7-1500
OUTn Output Binary numbers,
integers, floating-
point numbers,
strings, TIME,
TOD, DATE, DT
Binary numbers,
integers, floating-
point numbers,
strings, timers,
TOD, LTOD,
DATE, DT, LDT
Optional outputs
OUTELSE Output Binary numbers,
integers, floating-
point numbers,
strings, TIME,
TOD, DATE, DT
Binary numbers,
integers, floating-
point numbers,
strings, timers,
TOD, LTOD,
DATE, DT, LDT
Output to which
the value at input
IN is copied if K >
n.
For additional information on available data types, refer to "See also".
Example
The following example shows how the instruction works:
SCL
DEMUX(K := "Tag_Number",
IN := "Tag_Value",
OUT1 := "Tag_1",
OUT2 := "Tag_2",
OUTELSE := "Tag_3");
The following tables show how the instruction works using specific operand values:
Input values of the "Demultiplex" instruction before the network execution
Parameter Operand Values
K Tag_Number 2 4
IN Tag_Value DW#16#FFFFFFFF DW#16#003E4A7D
Output values of the "Demultiplex" instruction after the network execution
Parameter Operand Values
OUT1 Tag_1 Unchanged Unchanged
OUT2 Tag_2 DW#16#FFFFFFFF Unchanged
OUTELSE Tag_3 Unchanged DW#16#003E4A7D
See also
Overview of the valid data types (Page 899)
Operators and operator precedence (Page 1161)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2043
Shift and rotate
SHR: Shift right
Description
The "Shift right" instruction shifts the contents of the IN parameter bit-by-bit to the right and
returns it as a function value. The parameter N is used to specify the number of bit positions
by which the specified value should be shifted.
If the value of the N parameter is "0", the value of the IN parameter is given as a result.
If the value of the N parameter is greater than the number of available bit positions, then the
value of the IN parameter is shifted to the right by the available number of bit positions.
The bit positions that are freed by shifting in the left operand area are filled with zeros.
The following figure shows how the content of an integer data type operand is shifted by four
bit positions to the right:
<Result>
4 places
These four bits
are lost.
The freed bit positions
are filled with zeros.
lN
N
0 0 0 0 1 0 1 0 1 1 1 1 0 0 0 0 1 0 1 0
15... ...8 7... ...0
1 0 1 0 1 1 1 1 0 0 0 0 1 0 1 0
Syntax
The following syntax is used for the instruction "Shift right":
SCL
SHR(IN := <Operand>,
N := <Operand>)
The syntax of the instruction consists of the following parts:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2044 System Manual, 01/2013,
Parameter Declaration Data type Description
IN Input Bit strings, integers Value to be shifted
N Input UINT Number of bits by which
the value (IN) is shifted
Function value Bit strings, integers Result of the instruction
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
SCL
"Tag_Result" := SHR(IN := "Tag_Value",
N := "Tag_Number");
The following table shows how the instruction works using specific operand values:
Parameter Operand Value
IN Tag_Value 0011 1111 1010 1111
N Tag_Number 3
Function value Tag_Result 0000 0111 1111 010 1
The content of the "Tag_Value" operand is shifted by three bit positions to the right. The result
of the instruction is returned in the operand "Tag_Result" as a function value.
See also
Overview of the valid data types (Page 899)
Operators and operator precedence (Page 1161)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
SHL: Shift left
Description
The "Shift left" instruction shifts the contents of the IN parameter bit-by-bit to the left and returns
it as a function value. The parameter N is used to specify the number of bit positions by which
the specified value should be shifted.
If the value of the N parameter is "0", the value of the IN parameter is given as a result.
If the value of the N parameter is greater than the number of bit positions, the value of the IN
parameter is shifted to the left by the available number of bit positions.
The bit positions freed by the shift are filled with zeros in the result value.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2045
The following figure shows how the content of an operand of the WORD data type is shifted
six bit positions to the left:
6 positions
The bit positions
that have become free
will be filled with zeroes.
These six bits
will be lost.
lN
N
<Result> 0 1 1 0 1 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 1 1
15... ...8 7... ...0
0 0 0 0 1 1 1 1 0 1 0 1 0 1 0 1
Syntax
The following syntax is used for the instruction "Shift left":
SCL
SHL(IN := <Operand>,
N := <Operand>)
The syntax of the instruction consists of the following parts:
Parameter Declaration Data type Description
IN Input Bit strings, integers Value to be shifted
N Input UINT Number of bits by which
the value (IN) is shifted
Function value Bit strings, integers Result of the instruction
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
SCL
"Tag_Result" := SHL(IN := "Tag_Value",
N := "Tag_Number");
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2046 System Manual, 01/2013,
The following table shows how the instruction works using specific operand values:
Parameter Operand Value
IN Tag_Value 0011 1111 1010 1111
N Tag_Number 4
Function value Tag_Result 1111 1010 1111 0000
The value of the "Tag_Value" operand is shifted by four bit positions to the left. The result of
the instruction is returned in the operand "Tag_Result" as a function value.
See also
Overview of the valid data types (Page 899)
Operators and operator precedence (Page 1161)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
ROR: Rotate right
Description
The "Rotate right" instruction rotates the content of the IN parameter bit-by-bit to the right and
assigns the result to the specified operand. The parameter N is used to specify the number of
bit positions by which the specified value should be rotated. The bit positions freed by rotating
are filled with the bit positions that are pushed out.
If the value of the N parameter is "0", the value at input IN is given as a result.
If the value at the N parameter is greater than the number of available bit positions, the operand
value at the IN input is still rotated by the specified number of bit positions.
The following figure shows how the content of an operand of the DWORD data type is rotated
three bit positions to the right:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2047
3 places
The signal state of the three
shifted bits is inserted into the
freed positions.
lN
N
<Result> 1 0 1 1 0 1 0 1 0 1 0 0 1 1 1 0 0 0 0 1 0 0 0 1 1 1 1 0 1 0 1 0 1 0 1
31... ...16 15... ...0
1 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 0 1 0 1 0 1 0 1
Syntax
The following syntax is used for the instruction "Rotate right":
SCL
ROR(IN := <Operand>,
N := <Operand>)
The syntax of the instruction consists of the following parts:
Parameter Declaration Data type Description
IN Input Bit strings Value to be rotated
N Input UINT Number of bit positions
by which the value (IN)
is rotated.
Function value Bit strings Result of the instruction
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
SCL
"Tag_Result" := ROR(IN := "Tag_Value",
N := "Tag_Number");
The following table shows how the instruction works using specific operand values:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2048 System Manual, 01/2013,
Parameter Operand Value
IN Tag_Value 0000 1111 1001 0101
N Tag_Number 5
Function value Tag_Result 1010 1000 0111 1100
The content of the "Tag_Value" operand is rotated by five bit positions to the right. The result
of the instruction is returned in the operand "Tag_Result" as a function value.
See also
Overview of the valid data types (Page 899)
Operators and operator precedence (Page 1161)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
ROL: Rotate left
Description
The "Rotate left" instruction rotates the contents of the IN parameter bit-by-bit to the left and
returns it as a function value. The parameter N is used to specify the number of bit positions
by which the specified value should be rotated. The bit positions freed by rotating are filled
with the bit positions that are pushed out.
If the value of the N parameter is "0", the value at input IN is given as a result.
If the value at the N parameter is greater than the number of available bit positions, the operand
value at the IN input is still rotated by the specified number of bit positions.
The following figure shows how the content of an operand of the DWORD data type is rotated
three bit positions to the left:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2049
3 positions
The signal state of the three
bits that have been moved will be
added in the positions which have
become free.
lN
N
<Result>
1 0 0 0 0 1 0 1 0 1 0 1 0 1 1 1 0 0 0 0 1 0 0 0 0 1 1 1 1 1 1 1 1 1 1
31... ...16 15... ...0
1 1 1 1 0 0 0 0 1 0 1 0 0 0 0 0 1 0 1 0 1 1 1 1 0 0 0 0 1 1 1 1
Syntax
The following syntax is used for the "Rotate left" instruction:
SCL
ROL(IN := <Operand>,
N := <Operand>)
The syntax of the instruction consists of the following parts:
Part / Parameter Declaration Data type Description
IN Input Bit strings Value to be rotated
N Input UINT Number of bit positions
by which the value (IN)
is rotated
Function value Bit strings Result of the instruction
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
SCL
"Tag_Result" := ROL(IN := "Tag_Value",
N := "Tag_Number");
The following table shows how the instruction works using specific operand values:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2050 System Manual, 01/2013,
Parameters Operand Value
IN Tag_Value 1010 1000 1111 0110
N Tag_Number 5
Function value Tag_Result 0001 1110 1101 0101
The content of the operand "Tag_Value" is rotated five bit positions to the left. The result of
the instruction is returned in the operand "Tag_Result" as a function value.
See also
Overview of the valid data types (Page 899)
Operators and operator precedence (Page 1161)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
Additional instructions
DRUM: Implement sequencer
Description
The "Implement sequencer" instruction is used to assign the programmed values of the
OUT_VAL parameter of the corresponding step to the programmed output bits (OUT1 to
OUT16) and the output word (OUT_WORD). The specific step must thereby satisfy the
conditions of the programmed enable mask on the S_MASK parameter while the instruction
remains at this step. The instruction advances to the next step if the event for the step is true
and the programmed time for the current step elapses, or if the value at the JOG parameter
changes from "0" to "1". The instruction is reset if the signal state on the RESET parameter
changes to "1". The current step is hereby equated to the preset step (DSP).
The amount of time spent on a step is determined by the product of the preset timebase (DTBP)
and the preset counter value (S_PRESET) for each step. At the start of a new step, this
calculated value is loaded into the DCC parameter, which contains the time remaining for the
current step. If, for example the value at the DTBP parameter is "2" and the preset value for
the first step is "100" (100 ms), the DCC parameter has the value "200" (200 ms).
A step can be programmed with a time value, an event, or both. Steps that have an event bit
and the time value "0" advance to the next step as soon as the signal state of the event bit is
"1". Steps that are programmed only with a time value start the time immediately. Steps that
are programmed with an event bit and a time value greater than "0" start the time when the
signal state of the event bit is "1". The event bits are initialized with a signal state of "1".
When the sequencer is on the last programmed step (LST_STEP) and the time for this step
has expired, the signal state on the Q parameter is set to "1"; otherwise it is set to "0". When
the parameter Q is set, the instruction remains on the step until it is reset.
In the configurable mask (S_MASK) you can selected the separate bits in the output word
(OUT_WORD) and set or reset the output bits (OUT1 to OUT16) by means of the output values
(OUT_VAL). If a bit of the configurable mask is in the signal state "1", the value OUT_VAL sets
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2051
or resets the corresponding bit. If the signal state of a bit of the configurable mask is "0", the
corresponding bit is left unchanged. All the bits of the configurable mask for all 16 steps are
initialized with a signal state of "1".
The output bit on the OUT1 parameter corresponds to the least significant bit of the output
word (OUT_WORD). The output bit on the OUT16 parameter corresponds to the most
significant bit of the output word (OUT_WORD).
When you insert the instruction in the program, the "Call options" dialog opens in which you
can specify whether the IEC counter is stored in its own data block (single instance) or as a
local tag (multiple instance) in the block interface. If you create a separate data block, you will
find it in the project tree in the "Program resources" folder under "Program blocks > System
blocks". For additional information on this topic, refer to "See also".
Syntax
The following syntax is used for the "Implement sequencer" instruction:
SCL
<Instance>.DRUM(RESET := <Operand>,
JOG := <Operand>,
DRUM_EN := <Operand>,
LST_STEP := <Operand>,
EVENT1 := <Operand>,
EVENT2 := <Operand>,
EVENT3 := <Operand>,
EVENT4 := <Operand>,
EVENT5 := <Operand>,
EVENT6 := <Operand>,
EVENT7 := <Operand>,
EVENT8 := <Operand>,
EVENT9 := <Operand>,
EVENT10 := <Operand>,
EVENT11 := <Operand>,
EVENT12 := <Operand>,
EVENT13 := <Operand>,
EVENT14 := <Operand>,
EVENT15 := <Operand>,
EVENT16 := <Operand>,
OUT1 => <Operand>,
OUT2 => <Operand>,
OUT3 => <Operand>,
OUT4 => <Operand>,
OUT5 => <Operand>,
OUT6 => <Operand>,
OUT7 => <Operand>,
OUT8 => <Operand>,
OUT9 => <Operand>,
OUT10 => <Operand>,
OUT11 => <Operand>,
OUT12 => <Operand>,
OUT13 => <Operand>,
OUT14 => <Operand>,
OUT15 => <Operand>,
OUT16 => <Operand>,
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2052 System Manual, 01/2013,
SCL
Q => <Operand>,
OUT_WORD => <Operand>,
ERR_CODE => <Operand>)
The following table shows the parameters of the instruction:
Parameter Declaration Data type Description
RESET Input BOOL A signal state of "1"
indicates a reset
condition.
JOG Input BOOL When the signal state
changes from "0" to "1",
the instruction
advances to the next
step.
DRUM_EN Input BOOL A signal state of "1"
allows the sequencer to
advance based on the
event and time criteria.
LST_STEP Input BYTE Step number of the last
step programmed.
EVENT1 Input BOOL Event bit 1; initial signal
state is "1".
EVENT2 Input BOOL Event bit 2; initial signal
state is "1".
EVENT3 Input BOOL Event bit 3; initial signal
state is "1".
EVENT4 Input BOOL Event bit 4; initial signal
state is "1".
EVENT5 Input BOOL Event bit 5; initial signal
state is "1".
EVENT6 Input BOOL Event bit 6; initial signal
state is "1".
EVENT7 Input BOOL Event bit 7; initial signal
state is "1".
EVENT8 Input BOOL Event bit 8; initial signal
state is "1".
EVENT9 Input BOOL Event bit 9; initial signal
state is "1".
EVENT10 Input BOOL Event bit 10; initial
signal state is "1".
EVENT11 Input BOOL Event bit 11; initial
signal state is "1".
EVENT12 Input BOOL Event bit 12; initial
signal state is "1".
EVENT13 Input BOOL Event bit 13; initial
signal state is "1".
EVENT14 Input BOOL Event bit 14; initial
signal state is "1".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2053
Parameter Declaration Data type Description
EVENT15 Input BOOL Event bit 15; initial
signal state is "1".
EVENT16 Input BOOL Event bit 16; initial
signal state is "1".
OUT1 Output BOOL Output bit 1
OUT2 Output BOOL Output bit 2
OUT3 Output BOOL Output bit 3
OUT4 Output BOOL Output bit 4
OUT5 Output BOOL Output bit 5
OUT6 Output BOOL Output bit 6
OUT7 Output BOOL Output bit 7
OUT8 Output BOOL Output bit 8
OUT9 Output BOOL Output bit 9
OUT10 Output BOOL Output bit 10
OUT11 Output BOOL Output bit 11
OUT12 Output BOOL Output bit 12
OUT13 Output BOOL Output bit 13
OUT14 Output BOOL Output bit 14
OUT15 Output BOOL Output bit 15
OUT16 Output BOOL Output bit 16.
Q Output BOOL A signal state of "1"
indicates that the time
for the last step has
elapsed.
OUT_WORD Output WORD Word address to which
the sequencer writes
the output values.
ERR_CODE Output WORD Error information
JOG_HIS Static BOOL JOG parameter history
bit
EOD Static BOOL A signal state of "1"
indicates that the time
for the last step has
elapsed.
DSP Static BYTE Preset step of the
sequencer
DSC Static BYTE Current step of the
sequencer
DCC Static DWORD Current numerical
value of the sequencer
DTBP Static WORD Preset timebase of the
sequencer
PREV_TIME Static DWORD Previous system time
S_PRESET Static ARRAY of WORD Count preset for each
step [1 to 16] where 1
count = 1 ms.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2054 System Manual, 01/2013,
Parameter Declaration Data type Description
OUT_VAL Static ARRAY of BOOL Output values for each
step [1 to 16, 0 to 15].
S_MASK Static ARRAY of BOOL Configurable mask for
each step [1 to 16,
0 to 15]. Initial signal
states are "1".
The static parameters are not visible when calling the instruction in the program. These are
saved in the instance of the instruction.
ERR_CODE Parameter
The following table shows the meaning of the values of the parameter ERR_CODE:
ERR_CODE* Explanation
W#16#0000 No error
W#16#000B The value at the LST_STEP parameter is less than 1 or greater than 16.
W#16#000C The value at the DSC parameter is less than 1 or greater than the value at
the LST_STEP parameter.
W#16#000D The value at the DSP parameter is less than 1 or greater than the value at
the LST_STEP parameter.
*The error codes can be displayed as integer or hexadecimal value in the program editor. For additional information on
toggling display formats, refer to "See also".
See also
Overview of the valid data types (Page 899)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
DCAT: Discrete control-timer alarm
Description
The "Discrete control-timer alarm" instruction is used to accumulate the time from the point at
which the CMD parameter issues the command to open or close. The time is accumulated
until the preset time (PT) is exceeded or the information is received that the device was opened
or closed (O_FB or C_FB) within the specified time. If the preset time is exceeded before the
information on the opening or closing of the device is received, the corresponding alarm is
activated. If the signal state on the command input changes state before the preset time, the
time is restarted.
When you insert the instruction in the program, the "Call options" dialog opens in which you
can specify whether the IEC timer is stored in its own data block (single instance) or as a local
tag (multiple instance) in the block interface. If you create a separate data block, you will find
it in the project tree in the "Program resources" folder under "Program blocks > System blocks".
For additional information on this topic, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2055
The "Discrete control-timer alarm" instruction has the following reactions to the input conditions:
When the signal state of the CMD parameter changes from "0" to "1", the signal states of
the parameters Q, CMD_HIS, ET (only if ET < PT), OA and CA are influenced as follows:
The parameters Q and CMD_HIS are set to "1".
The parameters ET, OA and CA are reset to "0".
When the signal state on the parameter CMD changes from "1" to "0", the parameters Q,
ET (only if ET < PT), OA, CA and CMD_HIS are reset to "0".
When the signal state of the parameters CMD and CMD_HIS is "1" and the parameter O_FB
is set to "0", the time difference (ms) since the last execution of the instruction is added to
the value at the parameter ET. If the value of the parameter ET exceeds the value of the
parameter PT, the signal state on the parameter OA is set to "1". If the value of the
parameter ET does not exceed the value of the parameter PT, the signal state on the
parameter OA is reset to "0". The value at the parameter CMD_HIS is set to the value of
the parameter CMD.
If the signal state of the parameters CMD, CMD_HIS and O_FB are set to "1" and the
parameter C_FB has the value "0", the signal state of the parameter OA is set to "0". The
value of parameter ET is set to the value of parameter PT. If the signal state of the parameter
O_FB changes to "0", the alarm is set the next time the instruction is executed. The value
of parameter CMD_HIS is set to the value of parameter CMD.
If the parameters CMD, CMD_HIS and C_FB have the value "0", the time difference (ms)
since the last execution of the instruction is added to the value of the parameter ET. If the
value of the parameter ET exceeds the value of the parameter PT, the signal state of the
parameter CA is reset to "1". If the value at the parameter PT is not exceeded, the parameter
CA has the signal state "0". The value of parameter CMD_HIS is set to the value of
parameter CMD.
If the parameters CMD, CMD_HIS and O_FB have the signal state "0" and the parameter
C_FB is set to "1", the parameter CA is set to "0". The value of parameter ET is set to the
value of parameter PT. If the signal state of the parameter C_FB changes to "0", the alarm
is set the next time the instruction is executed. The value of parameter CMD_HIS is set to
the value of parameter CMD.
If the parameters O_FB and C_FB simultaneously have the signal state "1", the signal states
of both alarm outputs are set to "1".
The "Discrete control-timer alarm" instruction has no error information.
Syntax
The following syntax is used for the "Discrete control-timer alarm" instruction:
SCL
<Instance>.DCAT(CMD := <Operand>,
O_FB := <Operand>,
C_FB := <Operand>,
Q => <Operand>,
OA => <Operand>
CA => <Operand>)
The following table shows the parameters of the instruction:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2056 System Manual, 01/2013,
Parameter Declaration Data type Description
CMD Input BOOL A signal state of "0" indicates a "close"
command.
A signal state of "1" indicates an "open"
command.
O_FB Input BOOL Feedback input when opening
C_FB Input BOOL Feedback input when closing
Q Output BOOL Shows the status of the parameter CMD
OA Output BOOL Alarm output when opening
CA Output BOOL Alarm output when closing
ET Static DINT Currently elapsed time, where 1 count =
1 ms.
PT Static DINT Preset time value, where 1 count = 1 ms.
PREV_TIME Static DWORD Previous system time
CMD_HIS Static BOOL CMD history bit
For additional information on valid data types, refer to "See also".
The static parameters are not visible when calling the instruction in the program. These are
saved in the instance of the instruction.
Example
In the following example the parameter CMD changes from "0" to "1". After the execution of
the instruction the parameter Q is set to "1" and the two alarm outputs OA and CA have the
signal state "0". The parameter CMD_HIS of the instance data block is set to the signal state
"1" and the parameter ET is reset to "0".
Note
You can initialize static parameters in the data block.
SCL
"DCAT_DB".DCAT(CMD := "Tag_Input_CMD",
O_FB := "Tag_Input_O_FB",
C_FB := "Tag_Input_C_FB",
Q => "Tag_Output_Q",
OA => "Tag_Output_OA",
CA => "Tag_Output_CA");
The following tables show how the instruction works using specific values:
Before processing
In this example the following values are used for the input and output parameters:
Parameter Operand Value
CMD Tag_Input_CMD TRUE
O_FB Tag_Input_O_FB FALSE
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2057
Parameter Operand Value
C_FB Tag_Input_C_FB FALSE
Q Tag_Output_Q FALSE
OA Tag_Output_OA FALSE
CA Tag_Output_CA FALSE
The following values are saved in the instance data block "DCAT_DB" of the instruction:
Parameter Address Value
ET DBD4 L#12
PT DBD8 L#222
CMD_HIS DBX16.0 FALSE
After processing
The following values are written to the output parameters after the instruction has been
executed:
Parameter Operand Value
Q Tag_Output_Q TRUE
OA Tag_Output_OA FALSE
CA Tag_Output_CA FALSE
The following values are saved in the instance data block "DCAT_DB" of the instruction:
Parameter Address Value
ET DBD4 L#0
CMD_HIS DBX16.0 TRUE
See also
Overview of the valid data types (Page 899)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
MCAT: Motor control-timer alarm
Description
The "Motor control-timer alarm" instruction is used to accumulate the time from the point at
which one of the command inputs (opening or closing) is switched on. The time is accumulated
until the preset time is exceeded or the relevant feedback input indicates that the device has
executed the requested operation within the specified time. If the preset time is exceeded
before the feedback is received, the corresponding alarm is triggered.
When you insert the instruction in the program, the "Call options" dialog opens in which you
can specify whether the IEC timer is stored in its own data block (single instance) or as a local
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2058 System Manual, 01/2013,
tag (multiple instance) in the block interface. If you create a separate data block, you will find
it in the project tree in the "Program resources" folder under "Program blocks > System blocks".
For additional information on this topic, refer to "See also".
Execution of the "Motor control-timer alarm" instruction
The following table shows the reactions of the "Motor control-timer alarm" instruction to the
various input conditions:
Input parameters Output parameters
ET O_H
IS
C_H
IS
O_C
MD
C_C
MD
S_C
MD
O_F
B
C_F
B
OO CO OA CA ET O_H
IS
C_H
IS
Q Status
X 1 1 X X X X X 0 0 1 1 PT 0 0 0 Alarm
X X X X X X 1 1 0 0 1 1 PT 0 0 0 Alarm
X X X X X 1 X X 0 0 0 0 X 0 0 1 Stop
X X X 1 1 X X X 0 0 0 0 X 0 0 1 Stop
X 0 X 1 0 0 X X 1 0 0 0 0 1 0 1 Start
opening
<PT 1 0 X 0 0 0 X 1 0 0 0 INC 1 0 1 Open
X 1 0 X 0 0 1 0 0 0 0 0 PT 1 0 1 Opened
>=P
T
1 0 X 0 0 0 X 0 0 1 0 PT 1 0 0 Opening
alarm
X X 0 0 1 0 X X 0 1 0 0 0 0 1 1 Start closing
<PT 0 1 0 X 0 X 0 0 1 0 0 INC 0 1 1 Close
X 0 1 0 X 0 0 1 0 0 0 0 PT 0 1 1 Closed
>=P
T
0 1 0 X 0 X 0 0 0 0 1 PT 0 1 0 Closing
alarm
X 0 0 0 0 0 X X 0 0 0 0 X 0 0 1 Stopped
Legend:
INC Add the time difference (ms) since the last processing of the FB to ET
PT PT is set to the same value as ET
X Cannot be used
<PT ET < PT
>=PT ET >= PT
If the input parameters O_HIS and C_HIS both have the signal state "1", they are immediately set to the signal state "0". In
this case, the last line in the table (X) mentioned above is valid. Because it is therefore not possible to check whether the
input parameters O_HIS and C_HIS have the signal state "1", the output parameters are set as follows in this case:
OO = FALSE
CO = FALSE
OA = FALSE
CA = FALSE
ET = PT
Q = TRUE
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2059
Syntax
The following syntax is used for the "Motor control-timer alarm" instruction:
SCL
<Instance>.MCAT(O_CMD := <Operand>,
C_CMD := <Operand>,
S_CMD := <Operand>,
O_FB := <Operand>,
C_FB := <Operand>,
00 => <Operand>,
C0 => <Operand>,
OA => <Operand>,
CA => <Operand>,
Q => <Operand>)
The following table shows the parameters of the instruction:
Parameter Declaration Data type Description
O_CMD Input BOOL "Open" command input
C_CMD Input BOOL "Close" command input
S_CMD Input BOOL "Stop" command input
O_FB Input BOOL Feedback input when
opening
C_FB Input BOOL Feedback input when
closing
OO Output BOOL "Open" output
CO Output BOOL "Close" output
OA Output BOOL Alarm output when
opening
CA Output BOOL Alarm output when
closing
Q Output BOOL A signal state of "0"
indicates an error
condition.
ET Static DINT Currently elapsed time,
where 1 count = 1 ms
PT Static DINT Preset time value,
where 1 count = 1 ms
PREV_TIME Static DWORD Previous system time
O_HIS Static BOOL "Open" history bit
C_HIS Static BOOL "Close" history bit
For additional information on valid data types, refer to "See also".
The static parameters are not visible when calling the instruction in the program. These are
saved in the instance of the instruction.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2060 System Manual, 01/2013,
Example
The following example shows how the instruction works:
Note
You can initialize static parameters in the data block.
SCL
"MCAT_DB".MCAT(O_CMD := "Tag_Iput_O_CMD",
C_CMD := "Tag_Input_C_CMD",
S_CMD := "Tag_Input_S_CMD",
O_FB := "Tag_Input_O_FB",
C_FB := "Tag_Input_C_FB",
OO => "Tag_OutputOpen",
CO => "Tag_OutputClosed",
OA => "Tag_Output_OA",
CA => "Tag_Output_CA",
Q => "Tag_Output_Q");
The following tables show how the instruction works using specific values:
Before processing
In this example the following values are used for the input and output parameters:
Parameter Operand Value
O_CMD Tag_Input_O_CMD TRUE
C_CMD Tag_Input_C_CMD FALSE
S_CMD Tag_Input_S_CMD FALSE
O_FB Tag_Input_O_FB FALSE
C_FB Tag_Input_C_FB FALSE
OO Tag_OutputOpen FALSE
CO Tag_OutputClosed FALSE
OA Tag_Output_OA FALSE
CA Tag_Output_CA FALSE
Q Tag_Output_Q FALSE
The following values are saved in the instance data block "MCAT_DB" of the instruction:
Parameter Address Value
ET DBD4 L#2
PT DBD8 L#22
O_HIS DBX16.0 TRUE
C_HIS DBX16.1 FALSE
After processing
The following values are written to the output parameters after the instruction has been
executed:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2061
Parameter Operand Value
OO Tag_OutputOpen TRUE
CO Tag_OutputClosed FALSE
OA Tag_Output_OA FALSE
CA Tag_Output_CA FALSE
Q Tag_Output_Q TRUE
The following values are saved in the instance data block "MCAT_DB" of the instruction:
Parameter Address Value
ET DBD4 L#0
O_HIS DBX16.0 TRUE
CMD_HIS DBX16.1 FALSE
See also
Overview of the valid data types (Page 899)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
IMC: Compare input bits with the bits of a mask
Description
The "Compare input bits with the bits of a mask" instruction is used to compare the signal state
of up to 16 programmed input bits (IN_BIT0 to IN_BIT15) with the corresponding bit of a mask.
Up to 16 steps with masks can be programmed. The value of the IN_BIT0 parameter is
compared with the value of the mask CMP_VAL[x,0], with "x" indicating the step number. On
the CMP_STEP parameter, you specify the step number of the mask that is used for the
comparison. All programmed values are compared in the same manner. Unprogrammed input
bits or unprogrammed bits of the mask have a default signal state FALSE.
If a match is found in the comparison, the signal state of the OUT parameter is set to "1".
Otherwise the OUT parameter is set to "0".
If the value of CMP_STEP parameter is greater than 15, the instruction is not executed. An
error message is output at the ERR_CODE parameter.
When you insert the instruction in the program, the "Call options" dialog opens in which you
can specify whether the instruction data will be stored in its own data block (single instance)
or as a local tag (multiple instance) in the block interface. If you create a separate data block,
you will find it in the project tree in the "Program resources" folder under "Program blocks >
System blocks". For additional information on this topic, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2062 System Manual, 01/2013,
Syntax
The following syntax is used for the "Compare input bits with the bits of a mask" instruction:
SCL
<Instance>.IMC(IN_BIT0 := <Operand>,
IN_BIT1 := <Operand>,
IN_BIT2 := <Operand>,
IN_BIT3 := <Operand>,
IN_BIT4 := <Operand>,
IN_BIT5 := <Operand>,
IN_BIT6 := <Operand>,
IN_BIT7 := <Operand>,
IN_BIT8 := <Operand>,
IN_BIT9 := <Operand>,
IN_BIT10 := <Operand>,
IN_BIT11 := <Operand>,
IN_BIT12 := <Operand>,
IN_BIT13 := <Operand>,
IN_BIT14 := <Operand>,
IN_BIT15 := <Operand>,
CMP_STEP := <Operand>,
OUT => <Operand>,
ERR_CODE => <Operand>)
The following table shows the parameters of the instruction:
Parameter Declaration Data type Description
IN_BIT0 Input BOOL Input bit 0 to be compared with bit 0 of the
mask.
IN_BIT1 Input BOOL Input bit 1 to be compared with bit 1 of the
mask.
IN_BIT2 Input BOOL Input bit 2 to be compared with bit 2 of the
mask.
IN_BIT3 Input BOOL Input bit 3 to be compared with bit 3 of the
mask.
IN_BIT4 Input BOOL Input bit 4 to be compared with bit 4 of the
mask.
IN_BIT5 Input BOOL Input bit 5 to be compared with bit 5 of the
mask.
IN_BIT6 Input BOOL Input bit 6 to be compared with bit 6 of the
mask.
IN_BIT7 Input BOOL Input bit 7 to be compared with bit 7 of the
mask.
IN_BIT8 Input BOOL Input bit 8 to be compared with bit 8 of the
mask.
IN_BIT9 Input BOOL Input bit 9 to be compared with bit 9 of the
mask.
IN_BIT10 Input BOOL Input bit 10 to be compared with bit 10 of the
mask.
IN_BIT11 Input BOOL Input bit 11 to be compared with bit 11 of the
mask.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2063
Parameter Declaration Data type Description
IN_BIT12 Input BOOL Input bit 12 to be compared with bit 12 of the
mask.
IN_BIT13 Input BOOL Input bit 13 to be compared with bit 13 of the
mask.
IN_BIT14 Input BOOL Input bit 14 to be compared with bit 14 of the
mask.
IN_BIT15 Input BOOL Input bit 15 to be compared with bit 15 of the
mask.
CMP_STEP Input BYTE The step number of the mask used for the
comparison.
OUT Output BOOL A signal state of "1" indicates that a match
was found.
A signal state of "0" indicates that no match
was found.
ERR_CODE Output WORD Error information
CMP_VAL Static ARRAY OF WORD Comparison masks [0 to 15, 0 to 15]: The first
number of the index is the step number and
the second number is the bit number of the
mask.
For additional information on valid data types, refer to "See also".
The static parameters are not visible when calling the instruction in the program. These are
saved in the instance of the instruction.
ERR_CODE Parameter
The following table shows the meaning of the values of the ERR_CODE parameter:
Error code*
(W#16#...)
Explanation
0000 No error
000A The value at the CMP_STEP parameter is greater than 15.
*The error codes can be displayed as integer or hexadecimal value in the program editor. For additional information on
toggling display formats, refer to "See also".
See also
Overview of the valid data types (Page 899)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2064 System Manual, 01/2013,
SMC: Compare scan matrix
Description
You can use the "Compare scan matrix" instruction to compare the signal state of up to 16
programmed input bits (IN_BIT0 to IN_BIT15) with the corresponding bit of the comparison
masks for each step. Processing starts at step 1 and is continued until the last programmed
step (LAST) or until a match is found. The input bit of the IN_BIT0 parameter is compared with
the value of the mask CMP_VAL[x,0], with "x" indicating the step number. All programmed
values are compared in the same manner. If a match is found the signal state of the OUT
parameter is set to "1" and the step number with the matching mask is written in the OUT_STEP
parameter. Unprogrammed input bits or unprogrammed bits of the mask have a default signal
state FALSE. If more than one step has a matching mask, only the first one found is indicated
in the OUT_STEP parameter. If no match is found, the signal state of the OUT parameter is
set to "0". In this case the value at the OUT_STEP parameter is greater by "1" than the value
at the LAST parameter.
When you insert the instruction in the program, the "Call options" dialog opens in which you
can specify whether the instruction data will be stored in its own data block (single instance)
or as a local tag (multiple instance) in the block interface. If you create a separate data block,
you will find it in the project tree in the "Program resources" folder under "Program blocks >
System blocks". For additional information on this topic, refer to "See also".
Syntax
The following syntax is used for the "Compare scan matrix" instruction:
SCL
<Instance>.SMC(IN_BIT0 := <Operand>,
IN_BIT1 := <Operand>,
IN_BIT2 := <Operand>,
IN_BIT3 := <Operand>,
IN_BIT4 := <Operand>,
IN_BIT5 := <Operand>,
IN_BIT6 := <Operand>,
IN_BIT7 := <Operand>,
IN_BIT8 := <Operand>,
IN_BIT9 := <Operand>,
IN_BIT10 := <Operand>,
IN_BIT11 := <Operand>,
IN_BIT12 := <Operand>,
IN_BIT13 := <Operand>,
IN_BIT14 := <Operand>,
IN_BIT15 := <Operand>,
OUT => <Operand>,
OUT_STEP => <Operand>,
ERR_CODE => <Operand>)
The following table shows the parameters of the instruction:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2065
Parameter Declaration Data type Description
IN_BIT0 Input BOOL Input bit 0 to be compared with bit 0 of the
mask.
IN_BIT1 Input BOOL Input bit 1 to be compared with bit 1 of the
mask.
IN_BIT2 Input BOOL Input bit 2 to be compared with bit 2 of the
mask.
IN_BIT3 Input BOOL Input bit 3 to be compared with bit 3 of the
mask.
IN_BIT4 Input BOOL Input bit 4 to be compared with bit 4 of the
mask.
IN_BIT5 Input BOOL Input bit 5 to be compared with bit 5 of the
mask.
IN_BIT6 Input BOOL Input bit 6 to be compared with bit 6 of the
mask.
IN_BIT7 Input BOOL Input bit 7 to be compared with bit 7 of the
mask.
IN_BIT8 Input BOOL Input bit 8 to be compared with bit 8 of the
mask.
IN_BIT9 Input BOOL Input bit 9 to be compared with bit 9 of the
mask.
IN_BIT10 Input BOOL Input bit 10 to be compared with bit 10 of the
mask.
IN_BIT11 Input BOOL Input bit 11 to be compared with bit 11 of the
mask.
IN_BIT12 Input BOOL Input bit 12 to be compared with bit 12 of the
mask.
IN_BIT13 Input BOOL Input bit 13 to be compared with bit 13 of the
mask.
IN_BIT14 Input BOOL Input bit 14 to be compared with bit 14 of the
mask.
IN_BIT15 Input BOOL Input bit 15 to be compared with bit 15 of the
mask.
OUT Output BOOL A signal state of "1" indicates that a match
was found.
A signal state of "0" indicates that no match
was found.
OUT_STEP Output BYTE Contains the step number with the matching
mask, or the step number which is greater by
"1" than the value at the LAST parameter,
provided no match is found.
ERR_CODE Output WORD Error information
LAST Static BYTE Specifies the step number of the last step to
be scanned for a matching mask.
CMP_VAL Static ARRAY OF WORD Comparison masks [0 to 15, 0 to 15]: The first
number of the index is the step number and
the second number is the bit number of the
mask.
For additional information on valid data types, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2066 System Manual, 01/2013,
The static parameters are not visible when calling the instruction in the program. These are
saved in the instance of the instruction.
ERR_CODE Parameter
The following table shows the meaning of the values of the parameter ERR_CODE:
Error code*
(W#16#...)
Explanation
0000 No error
000E The value at the LAST parameter is greater than 15.
*The error codes can be displayed as integer or hexadecimal value in the program editor. For additional information on
toggling display formats, refer to "See also".
See also
Overview of the valid data types (Page 899)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
LEAD_LAG: Lead and lag algorithm
Description
Use the "Lead and lag algorithm" instruction to process signals with an analog tag. The gain
value must be greater than zero. The result of the "Lead and lag algorithm" instruction is
calculated using the following equation:
OUT =
LG_TlME
LG_TlME + SAMPLE_T
PREV_OUT + GAlN
LD_TlME + SAMPLE_T
LG_TlME + SAMPLE_T
lN - GAlN
LG_TlME + SAMPLE_T
LD_TlME
* PREV_lN
The instruction "Lead and lag algorithm" supplies plausible results only when processing is in
fixed program cycles. The same units must be specified at the parameters LD_TIME, LG_TIME
and SAMPLE_T. At LG_TIME > 4 + SAMPLE_T, the instruction approaches the following
function:
OUT = GAIN * ((1 + LD_TIME * s) / (1 + LG_TIME * s)) * IN
When the value of the GAIN parameter is less than or equal to zero, the calculation is not
performed and an error information is output on the ERR_CODE parameter.
You can use the "Lead and lag algorithm" instruction in conjunction with loops as a
compensator in dynamic feed-forward control. The instruction consists of two operations. The
"Lead" operation shifts the phase of output OUT so that the output leads the input. The "Lag"
operation, on the other hand, shifts the output so that the output lags behind the input. Because
the "Lag" operation is equivalent to an integration, it can be used as a noise suppressor or as
a low-pass filter. The "Lead" operation is equivalent to a differentiation and can therefore be
used as a high-pass filter. The two instructions together (Lead and Lag) result in the output
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2067
phase lagging behind the the input at lower frequencies and leading it at higher frequencies.
This means that the "Lead and lag algorithm" instruction can be used as a band pass filter.
When you insert the instruction in the program, the "Call options" dialog opens automatically.
In this dialog, you can specify whether Lead and Lag are stored in their own data block (single
instance) or as local tag (multiple instance) in the block interface. If you create a separate data
block, you will find it in the project tree in the "Program resources" folder under "Program blocks
> System blocks". For additional information on this topic, refer to "See also".
Syntax
The following syntax is used for the "Lead and lag algorithm" instruction:
SCL
<Instance>.LEAD_LAG(IN := <Operand>,
SAMPLE_T := <Operand>,
OUT=> <Operand>,
ERR_CODE => <Operand>)
The following table shows the parameters of the instruction:
Parameter Declaration Data type Description
IN Input REAL The input value of the
current sample time
(cycle time) to be
processed.
Constants can also be
specified on the IN
parameter.
SAMPLE_T Input INT Sample time
Constants can also be
specified on the
SAMPLE_T parameter.
OUT Output REAL Result of the instruction
ERR_CODE Output WORD Error information
LD_TIME Static REAL Lead time in the same
unit as sample time.
LG_TIME Static REAL Lag time in the same
unit as sample time
GAIN Static REAL Gain as % / % (the ratio
of the change in output
to a change in input as
a steady state).
PREV_IN Static REAL Previous input
PREV_OUT Static REAL Previous output
For additional information on valid data types, refer to "See also".
The static parameters are not visible when calling the instruction in the program. These are
saved in the instance of the instruction.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2068 System Manual, 01/2013,
ERR_CODE Parameter
The following table shows the meaning of the values of the parameter ERR_CODE:
Error code*
(W#16#...)
Explanation
0000 No error
0009 The value at the GAIN parameter is less than or equal to zero.
*The error codes can be displayed as integer or hexadecimal value in the program editor. For additional information on
toggling display formats, refer to "See also".
Example
The following example shows how the instruction works:
Note
You can initialize static parameters in the data block.
SCL
"LEAD_LAG_DB".LEAD_LAG(IN := "Tag_Input",
SAMPLE_T := "Tag_Input_SAMPLE_T",
OUT => "Tag_Output_Result",
ERR_CODE => "Tag_ErrorCode");
The following tables show how the instruction works using specific values:
Before processing
In this example the following values are used for the input parameters:
Parameter Operand Value
IN Tag_Input 2.0
SAMPLE_T Tag_Input_SAMPLE_T 10
The following values are saved in the instance data block "LEAD_LAG_DB" of the instruction:
Parameter Address Value
LD_TIME DBD12 2.0
LG_TIME DBD16 2.0
GAIN DBD20 1.0
PREV_IN DBD24 6.0
PREV_OUT DBD28 6.0
After processing
The following values are written to the output parameters after the instruction has been
executed:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2069
Parameter Operand Value
OUT Tag_Output_Result 2.0
The following values are saved in the instance data block "LEAD_LAD_DB" of the instruction:
Parameter Operand Value
PREV_IN DBD24 2.0
PREV_OUT DBD28 2.0
See also
Overview of the valid data types (Page 899)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
SEG: Create bit pattern for seven-segment display
Description
The "Create bit pattern for seven-segment display" instruction is used to convert each of the
four hexadecimal digits of the specified source word (IN) into an equivalent bit pattern for a 7-
segment display. The result of the instruction is output in the double word on the OUT
parameter.
The following relation exists between the hexadecimal digits and the assignment of the 7
segments (a, b, c, d, e, f, g):
Input digit
(Binary)
Assignment of the
segments
g f e d c b a
Display
(Hexadecimal)
Seven-segment display
0000 00111111 0
0001 00000110 1
0010 01011011 2
0011 01001111 3
0100 01100110 4
0101 01101101 5
0110 01111101 6
0111 00000111 7
1000 01111111 8
1001 01100111 9
1010 01110111 A
1011 01111100 B
1100 00111001 C
1101 01011110 D
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2070 System Manual, 01/2013,
1110 01111001 E
1111 01110001 F
Syntax
Use the following syntax for the "Create bit pattern for seven-segment display" instruction:
SCL
SEG(IN := <Operand>,
OUT => <Operand>)
The following table shows the parameters of the instruction:
Parameter Declaration Data type Description
IN Input WORD Source word with four
hexadecimal digits
OUT Output DWORD Bit pattern for the seven-
segment display
Example
The following example shows how the instruction works:
SCL
SEG(IN := "Tag_Input",
OUT => "Tag_Output");
The following table shows how the instruction works using specific operand values:
Parameter Operand Value
Hexadecimal Binary
IN Tag_Input W#16#1234 0001 0010 0011 0100
OUT Tag_Output DW16#065B4F66 00000110 01011011 01001111
01100110
Display: 1234
See also
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
Overview of the valid data types (Page 899)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2071
BCDCPL: Create tens complement
Description
The "Create tens complement" instruction is used to create the tens complement of a seven-
digit BCD number specified on the IN parameter. This instruction uses the following
mathematical formula to calculate:
10000000 (as BCD)
7-digit BCD value
----------------------------------------
Tens complement (as BCD)
Syntax
The following syntax is used for the "Create tens complement" instruction:
SCL
BCDCPL(IN := <Operand>)
The following table shows the parameters of the instruction:
Parameter Declaration Data type Description
IN Input DWORD 7-digit BCD number
<RET_VAL> Return DWORD Result of the instruction
Example
The following example shows how the instruction works:
SCL
"Tag_Output" := BCDCPL(IN := "Tag_Input");
The following table shows how the instruction functions using specific values:
Parameter Operand Value*
IN Tag_Input DW#16#01234567
RET_VAL Tag_Output DW#16#08765433
*The error codes can be displayed as integer or hexadecimal value in the program editor. For additional
information on toggling display formats, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2072 System Manual, 01/2013,
See also
Overview of the valid data types (Page 899)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
BITSUM: Count number of set bits
Description
The "Count number of set bits" instruction is used to count the number of bits of an operand
that is set to the signal state "1". The operand whose bits are to be counted is specified on the
IN parameter. The result of the instruction is output on the RET_VAL parameter.
Syntax
The following syntax is used for the "Count number of set bits" instruction:
SCL
BITSUM (IN := <Operand>)
The following table shows the parameters of the instruction:
Parameter Declaration Data type Description
IN Input DWORD Operand whose set bits
are counted.
<RET_VAL> Return INT Result of the instruction
Example
The following example shows how the instruction works:
SCL
"Tag_Output" := BITSUM(IN := "Tag_Input");
The following table shows how the instruction functions using specific values:
Parameter Operand Value*
IN Tag_Input DW#16#12345678
RET_VAL Tag_Output W#16#000D (13 Bits)
*The error codes can be displayed as integer or hexadecimal value in the program editor. For additional
information on toggling display formats, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2073
See also
Overview of the valid data types (Page 899)
Entering SCL instructions (Page 1172)
Editing SCL instructions (Page 1189)
9.8.3 Extended instructions
9.8.3.1 Date and time-of-day
T_COMP: Compare time tags
Description
This instruction is used to compare the contents of two tags of the data types "Timers" or "Date
and time".
The instruction supports comparisons of the following data types: DATE, TIME, LTIME, TOD
(TIME_OF_DAY), LTOD (LTIME_OF_DAY), DT (DATE_AND_TIME), LDT
(DATE_AND_LTIME), DTL. Before you can execute a comparison, the data types must have
the same length and format.
The comparison result is output at the OUT parameter as a return value. The parameter OUT
is set to "1" if the comparison condition applied has been satisfied.
The following comparison options can be used:
Symbol Description
EQ The return value has the signal state 1" if the time is the same at the parameter IN1 and IN2.
NE The return value has the signal state 1" if the time at parameters IN1 and IN2 is not identical.
GE The return value has the signal state "1" if the time at parameter IN1 is greater (more recent) than or equal
to the time at parameter IN2 .
LE The return value has the signal state "1" if the time at parameter IN1 is less (less recent) than or equal to
the time at parameter IN2.
GT The return value has the signal state 1" if the time at parameter IN1 is greater (more recent) than the time
at parameter IN2.
LT The return value has the signal state "1" if the time at parameter IN1 is less (less recent) than the time at
parameter IN2 .
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2074 System Manual, 01/2013,
Parameter
The following table shows the parameters of the instruction "T_COMP":
Parameter Declaration Data type Memory area Description
IN1 Input DATE, TIME, LTIME,
TOD, LTOD, DT,
LDT, DTL
I, Q, M, D, L or constant First value to be compared.
IN2 Input DATE, TIME, LTIME,
TOD, LTOD, DT,
LDT, DTL
I, Q, M, D, L or constant Second value to be compared.
OUT Output BOOL I, Q, M, D, L Return value
For additional information on valid data types, refer to "Overview of the valid data types
(Page 899)".
T_CONV: Convert times and extract
Description
You use the instruction "T_CONV" to convert the data type of the IN input parameter to the
data type that is output at the OUT output. You select the data formats for the conversion from
the instruction boxes of the input and output.
Parameters
The following table shows the parameters of the instruction "T_CONV". If an input and output
parameter of the same data type is used, the instruction copies the corresponding value.
Parameter Declaration Data type Memory area Description
S7-1200 S7-1500
IN Input Integers, TIME,
date and time*
WORD,
integers,
timers, date
and time*
I, Q, M, D, L or
constant
Value to be converted
OUT Return Integers, TIME,
date and time*
WORD,
integers,
timers, date
and time*
I, Q, M, D, L Result of the conversion
* The range of supported data types depends on the CPU. Please refer to the overviews of valid data types for information
on the data types supported by the S7-1200 and S7-1500 modules.
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2075
T_ADD: Add times
Description
You use this instruction to add the time information in the IN1 input to the time information in
the IN2 input. You can query the result in the OUToutput parameter. You can add the following
formats:
Addition of a time period to another time period.
Example: Addition of a TIME data type to another TIME data type.
Addition of a time period to a time.
Example: Addition of a TIME data type to the DTL data type.
The data type for the value at input parameter IN1 and output parameter OUT is defined by
the selection in the instruction boxes of the input and output. You can only specify time
information in TIME format in the IN2 input parameter (for S7-1500 modules also LTIME).
Parameters
The following tables show the parameters of the "T_ADD" instruction, according to the possible
conversions:
Table 9-34 Addition of a time period to another time period
Parameter Declaration Data type Memory area Description
S7-1200 S7-1500
IN1 Input
TIME TIME, LTIME I, Q, M, D, L or
constant
First number to be added
IN2 Input TIME TIME, LTIME I, Q, M, D, L or
constant
Second number to be added
OUT Return DINT,
DWORD,
TIME, TOD
TIME, LTIME, I, Q, M, D, L Result of addition
The data type selection depends on
the data types selected for the IN1
and IN2 input parameters.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2076 System Manual, 01/2013,
Table 9-35 Addition of a time period to a time
Parameter Declaration Data type Memory area Description
S7-1200 S7-1500
IN1 Input DTL, TOD DT, DOT,
LTOD, LDT,
DTL
I, Q, M, D, L or
constant
First number to be added
IN2 Input TIME TIME, LTIME I, Q, M, D, L or
constant
Second number to be added
OUT Return DINT,
DWORD,
TIME, TOD,
UDINT, DTL
DT, DTL,
LDT, TOD,
LTOD
I, Q, M, D, L Result of addition
The data type selection depends on
the data types selected for the IN1
and IN2 input parameters.
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
T_SUB: Subtract times
Description
You use this instruction to subtract the time information in the IN2 input parameter from the
time information in the IN1 input parameter. You can query the difference in the OUT output
parameter. You can subtract the following formats:
Subtraction of a time period from another time period
Example: Subtraction of a time period of the data type TIME from another time period of
the data type TIME. The result can be output to a tag with the TIME format.
Subtraction of a time period from a time
Example: Subtraction of a time period of the data type TIME from a time of the data type
DTL. The result can be output to a tag with the DTL format.
You decide the formats of the values in the IN1 input parameter and the OUT output parameter
by selecting the data types for the input and output parameters of the instruction.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2077
Parameters
The following tables show the parameters of the "T_SUB" instruction, according to the possible
conversions:
Table 9-36 Subtraction of a time period from another time period
Parameter Declaration Data type Memory area Description
S7-1200 S7-1500
IN1 Input TIME TIME, LTIME I, Q, M, D, L or
constant
Minuend
IN2 Input TIME TIME, LTIME I, Q, M, D, L or
constant
Subtrahend
OUT Return DINT, DWORD,
TIME, TOD,
UDINT
TIME, LTIME I, Q, M, D, L Result of subtraction
Table 9-37 Subtraction of a time period from a time
Parameter Declaration Data type Memory area Description
S7-1200 S7-1500
IN1 Input DTL, TOD TOD, LTOD, DTL,
DT, LDT
I, Q, M, D, L or
constant
Minuend
IN2 Input TIME TIME, LTIME I, Q, M, D, L or
constant
Subtrahend
OUT Return DTL, DINT,
DWORD, TIME,
TOD, UDINT
TOD, LTOD, DTL,
DT, LDT
I, Q, M, D, L Result of subtraction
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
T_DIFF: Time difference
Description
You use this instruction to subtract the time information in the IN2 input parameter from the
time information in the IN1 input parameter. The result is stored in the OUT output parameter
in TIME format.
If the time information at the IN2 input parameter is greater than the time information at the
IN1 input parameter, the result is output as a negative value at the OUT output parameter.
If the result of the subtraction is outside the TIME range, the result is set to "0" (0:00) and
the enable output ENO = "0".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2078 System Manual, 01/2013,
Parameters
The following table shows the parameters of the "T_DIFF" instruction:
Parameter Declaration Data type Memory area Description
S7-1200 S7-1500
IN1 Input DTL DTL, DATE, DT,
TOD, LTOD,
LDT
I, Q, M, D, L or
constant
Minuend
IN2 Input DTL DTL, DATE, DT,
TOD, LTOD,
LDT
I, Q, M, D, L or
constant
Subtrahend
OUT Return TIME TIME, LTIME,
INT
I, Q, M, D, L Difference in TIME format
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
T_COMBINE: Combine times
Description
The instruction combines the value of a date with the value of a time and converts this into a
combined date and time value.
The date is output at the input parameter IN1. A value of between 1990-01-01 and
2089-12-31 must be used for the data type DATE (this is not checked).
The time is input at the IN2 input value (TOD/LTOD data type).
The combined data type for the date and time value is output at the OUT output value.
Parameter
The following table shows the parameters of the instruction "T_COMBINE":
Parameter Declaration Data type Memory area Description
S7-1200 S7-1500
IN1 Input DATE DATE,
WORD,
UINT, INT
I, Q, M, D, L or
constant
Input tag of the date
IN2 Input TOD TOD, LTOD I, Q, M, D, L or
constant
Input tag of the time
OUT Return DTL DT, DTL, LDT I, Q, M, D, L Return value of the date and time
For additional information on valid data types, refer to "Overview of the valid data types
(Page 899)".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2079
Time-of-day functions
WR_SYS_T: Set time-of-day
Description
You use this instruction to set the date and time-of-day of the CPU clock. You specify the date
and time information at the IN input parameter of the instruction. You can query whether errors
have occurred during execution of the instruction in the RET_VAL output parameter.
The "WR_SYS_T" instruction cannot be used to pass information about the local time zone or
daylight saving time.
Parameters
The following table shows the parameters of the "WR_SYS_T" instruction:
Parameter Declaration Data type Memory area Description
S7-1200 S7-1500
IN Input DTL DT, DTL, LDT I, Q, M, D, L or
constant
Date and time
RET_VAL Return INT, REAL,
DINT
INT I, Q, M, D, L Status of the instruction
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
RET_VAL parameter
Error code*
(W#16#....)
Description
0000 No error
8080 Error in date
8081 Error in time
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
RD_SYS_T: Read time-of-day
Description
You use this instruction to read out the current date and current time-of-day of the CPU clock.
The read out dates are output at the OUT output parameter of the instruction. The provided
value does not include information about the local time zone or daylight saving time.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2080 System Manual, 01/2013,
You can query whether errors have occurred during execution of the instruction in the
RET_VALoutput.
Parameters
The following table shows the parameters of the "RD_SYS_T" instruction:
Parameter Declaration Data type Memory area Description
S7-1200 S7-1500
RET_VAL Return INT, REAL,
DINT
Bit string I, Q, M, D, L Status of the instruction
OUT Output DTL DT, DTL, LDT I, Q, M, D, L Date and time of CPU
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
RET_VAL parameter
Error code*
(W#16#....)
Description
0000 No error
8081 Time value specified at the LOCTIME parameter is outside the valid value range:
With DTL: min. DTL#1970-01-01-00:00:00.0, max. DTL#2554-12-31-23:59:59.999999999
With LDT: min. LDT#1970-1-1-0:0:0.000000000, max. LDT#2262-04-11-23:47:16.854775807
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
RD_LOC_T: Read local time
Description
You use this instruction to read out the current local time from the CPU clock and output this
at the OUT output. Information on the time zone and the start of daylight saving time and
standard time, which you have set in the configuration of the CPU clock, is used to output the
local time.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2081
Parameter
The following table shows the parameters of the "RD_LOC_T" instruction:
Parameter Declaration Data type Memory area Description
S7-1200 S7-1500
RET_VAL Return INT INT M, D, L Status of the instruction
OUT Output DTL DT, LDT, DTL D Local time
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
RET_VAL parameter
Error code*
(W#16#....)
Description
0000 No error
0001 No error. Local time is output as daylight saving time.
8080 Local time cannot be read out.
8081 Time value specified at the LOCTIME parameter is outside the valid value range:
With DTL: min. DTL#1970-01-01-00:00:00.0, max. DTL#2554-12-31-23:59:59.999999999
With LDT: min. LDT#1970-1-1-0:0:0.000000000, max. LDT#2262-04-11-23:47:16.854775807
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
WR_LOC_T: Write local time
Description
The instruction "WR_LOC_T" is used to set the date and time of the CPU clock. You specify
the date and time information as local time at the LOCTIME input parameter of the instruction.
The instruction uses the "TimeTransformationRule" structure to calculate the system time. The
granularity of the time information for local time and system time is product-specific and is at
least one millisecond. Input values at the LOCTIME parameter which are less than those
supported by the CPU are rounded up during system time calculation.
You can query whether errors have occurred during execution of the instruction in the
RET_VAL output parameter.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2082 System Manual, 01/2013,
Parameter
The following table shows the parameters of the "WR_LOC_T" instruction:
Parameter Declaration Data type Memory area Description
LOCTIME Input DTL, LDT I, Q, M, D, L or
constant
Local time
DST Input BOOL I, Q, M, D, L or
constant
Daylight Saving Time
Only evaluated during the "double hour"
when the clocks change to daylight saving
time.
TRUE = daylight saving time (first hour)
FALSE = standard time (second hour)
RET_VAL Return INT I, Q, M, D, L Error message (see "RET_VAL parameter")
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
RET_VAL parameter
Error code*
(W#16#....)
Description
0000 No error.
8080 The LOCTIME parameter has an invalid value.
8081 Time value specified at the LOCTIME parameter is outside the valid value range:
With DTL: min. DTL#1970-01-01-00:00:00.0, max. DTL#2554-12-31-23:59:59.999999999
With LDT: min. LDT#1970-1-1-0:0:0.000000000, max. LDT#2262-04-11-23:47:16.854775807
8082** Invalid value specified for the month (byte 2 in DTL format).
8083** Invalid value specified for the day (byte 3 in DTL format).
8084** Invalid value specified for the hour (byte 5 in DTL format).
8085** Invalid value specified for the minute (byte 5 in DTL format).
8086** Invalid value specified for the second (byte 7 in DTL format).
8087** Invalid value specified for the nanosecond (byte 8 to 11 in DTL format).
8089 Time value does not exist (hour already passed upon changeover to daylight saving time).
80B0 The real-time clock has failed.
80B1 The "TimeTransformationRule" structure has not been defined.
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
** Only for local time information at the LOCTIME parameter in DTL format.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2083
SET_TIMEZONE: Set time zone
Description
You use this instruction to calculate the local time based on the module time. The module time
of the CPU is the UTC time. The module time is used exclusively for communication within the
system. The rule for conversion to local time is defined in the "TimeTransformationRule"
attribute that you specify in the TimeZone parameter. The rule defines the time zone calculation
as well as the automatic changeover between daylight saving time and standard time.
Parameters
The following table shows the parameters of the "SET_TIMEZONE" instruction:
Parameter Declaration Data type Memory area Description
REQ Input BOOL I, Q, M, D, L or
constant
REQ=1: Conversion of module time to local
time
TimeZone Input Time Transformation
Rule (Page 2085)
D Rule for conversion of module time to local
time.
DONE Output BOOL I, Q, M, D, L 0: Job not yet started or is still executing
1: Job completed error-free
BUSY Output BOOL I, Q, M, D, L 0: Job not yet started or already
completed
1: Job not yet completed. A new job
cannot be started.
ERROR Output BOOL I, Q, M, D, L 0: No error
1: Error occurred
STATUS Output DINT, DWORD,
UDINT, WORD
I, Q, M, D, L Error message
For additional information on valid data types, refer to "Overview of the valid data types
(Page 899)".
STATUS parameter
Error code*
(W#16#....)
Description
7000 No job processing active.
7001 Start of job processing. Parameter BUSY = 1, DONE = 0
7002 Intermediate call (REQ
irrelevant): Instruction already active; BUSY has the value "1".
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2084 System Manual, 01/2013,
TimeTransformationRule
Description
The times for changeover to daylight saving time and standard time are defined in the
TimeTransformationRule structure. The structure is as follows:
Name Data type Description
TimeTransformationRule STRUCT
Bias INT // Time difference between local time and UTC [min]
DaylightBias INT // Time difference between daylight saving and standard time [min]
DaylightStartMonth USINT // Month of conversion to daylight saving time
DaylightStartWeek USINT // Week of conversion to daylight saving time
// 1 = First occurrence of the weekday in the month, ...,
// 5 = Last occurrence of the weekday in the month
DaylightStartWeekday USINT // Weekday of daylight saving time changeover:
// 1 = Sunday
DaylightStartHour USINT // Hour of daylight saving time changeover
DaylightStartMinute USINT // Minute of daylight saving time changeover
StandardStartMonth USINT // Month of conversion to standard time
StandardStartWeek USINT // Week of conversion to standard time
// 1 = First occurrence of the weekday in the month, ...,
// 5 = Last occurrence of the weekday in the month
StandardStartWeekday USINT // Weekday of standard time changeover:
// 1 = Sunday
StandardStartHour USINT // Hour of standard time changeover
StandardStartMinute USINT // Minute of standard time changeover
TimeZoneName STRING[80] // Name of time zone: "(GMT+01:00) Amsterdam, Berlin, Bern, Rome,
Stockholm, Vienna"
SNC_RTCB: Synchronize slave clocks
Definition: Synchronization of slave clocks
The synchronization of clock slaves refers to the transfer of the date and time-of-day from the
clock master of a bus segment to all clock slaves of this bus segment.
Description
You use this instruction to synchronize all slave clocks present on a bus segment independent
of the assigned synchronization interval. Successful synchronization is only possible if
"SNC_RTCB" is called on a CPU whose real-time clock was assigned as the master clock for
at least one bus segment.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2085
Parameters
The following table shows the parameters of the "SNC_RTCB" instruction:
Parameter Declaration Data type Memory area Description
RET_VAL Output INT I, Q, M, D, L If an error occurs while the instruction is
being executed, the return value contains
an error code.
For additional information on valid data types, refer to "Overview of the valid data types
(Page 899)".
Parameter RET_VAL
Error code*
(W#16#...)
Explanation
0000 No error occurred during synchronization.
0001 The existing clock was not assigned the master clock function for
any of the bus segments.
8xyy General error information
See also: Evaluating errors with output parameter RET_VAL (Page 1422)
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
TIME_TCK: Read system time
Description
With the "TIME_TCK" instruction, you read the system time of the CPU. The system time is a
time counter that counts from 0 to a maximum of 2147483647 ms. In case of an overflow, the
system time is counted again starting with "0". The time scale and the accuracy of the system
time is 1 ms. The system time is only influenced by the operating modes of the CPU. You can
use the system time, for example, to measure the duration of processes by comparing the
results of two "TIME_TCK" calls. The instruction does not provide any error information.
The following table provides an overview of how the system time changes depending on the
operating modes of the CPU.
Mode System time ...
Startup ... is constantly updated
RUN
STOP ... is stopped and retains the current value
Warm restart ... is deleted and restarts with "0"
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2086 System Manual, 01/2013,
Parameter
The following table shows the parameters of the instruction "TIME_TCK":
Parameters Declaration Data type Memory area Description
RET_VAL Return TIME I, Q, M, D, L The RET_VAL parameter contains
the read system time in the range
from 0 to 2
31
-1 ms.
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
RTM: Runtime meters
Description
You can use this instruction to set, start, stop, and read out a 32-bit runtime meter of your CPU.
Ensure that the runtime meter can also be stopped or restarted during execution of the user
program, which may render the saved values incorrect.
Parameters
The following table shows the parameters of the instruction "RTM":
Parameter Declaration Data type Memory area Description
NR Input RTM (UINT) I, Q, M, D, L or
constant
Number of the runtime meter
Numbering starts with 0.
For information on the number of runtime meters
of your CPU, refer to the technical data.
MODE Input BYTE I, Q, M, D, L or
constant
Job ID:
0: Read out (the status is then written to CQ
and the current value to CV). After the
runtime meter has reached (2E31) -1 hours,
it stops at the highest value that can be
displayed and outputs an "Overflow" error
message.
1: start (at the last counter value)
2: stop
4: set (to the value specified in PV)
5: set (to the value specified in PV) and then
start
6: set (to the value specified in PV) and then
stop
PV Input DINT I, Q, M, D, L or
constant
New value for the runtime meter
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2087
Parameter Declaration Data type Memory area Description
RET_VAL Return INT I, Q, M, D, L If an error occurs while the instruction is
being executed, the return value contains an
error code.
CQ Output BOOL I, Q, M, D, L Status of the runtime meter (1: running)
CV Output DINT I, Q, M, D, L Current value of the runtime meter
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
RET_VAL parameter
Error code
(W#16#...)
Explanation
0000 No error
8080 Wrong number for the runtime meter
8081 A negative value was passed to the PV parameter.
8082 Overflow of the runtime meter
8091 The MODE input parameter contains an invalid value.
25xx, 29xx General error information
See also: Evaluating errors with GET_ERR_ID (Page 2030)
9.8.3.2 String + Char
S_MOVE: Move character string
Description
You can use this instruction to move the content of a character string (STRING). The character
string in the IN input parameter is copied to the OUT output parameter.
You can insert additional outputs for the S_MOVE instruction. In this case, the content of the
operand in the IN input parameter is transferred to all available outputs.
You can use the "MOVE_BLK" and "UMOVE_BLK" instructions to copy tags of data type
ARRAY.
Parameters
The following table shows the parameters of the "S_MOVE" instruction:
Parameter Declaration Data type Memory area Description
IN Input STRING D, L Source value
OUT Output STRING D, L Destination address
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2088 System Manual, 01/2013,
For additional information on valid data types, refer to "Overview of the valid data types
(Page 899)".
S_COMP: Compare character strings
Description
The instruction compares the contents of two tags in the STRING format and outputs the result
of the comparison as a return value. The tags that are to be compared will be interconnected
at the IN1 and IN2 inputs. You can only assign a symbolically defined tag for the input
parameters.
Use the instruction box to select the comparison condition. If the comparison condition (for
example, greater than or equal to) is satisfied, the signal state is set to "1" at the output
parameter OUT .
The following comparison options can be used:
Symbol Description
EQ The return value has the signal state "1" if the string at the IN1 parameter is the same as
the string at the IN2 parameter.
NE The return value has the signal state "1" if the string at the IN1 parameter is not equal to
the string at the IN2 parameter.
GT
(1)
The return value has the signal state 1" if the string at the IN1 parameter is greater than
the string at the IN2 parameter.
LT
(1)
The return value has the signal state "1" if the string at the IN1 parameter is less than the
string at the IN2 parameter.
GE
(1)
The return value has the signal state "1" if the string at the IN1 parameter is greater than
or equal to the string at the IN2 parameter.
LE
(1)
The return value has the signal state "1" if the string at the IN1 parameter is less than or
equal to the string at the IN2 parameter.
(1)
The characters are compared by their ASCII code (for example, 'a' is greater than 'A'), starting from
the left. The first character to be different decides the result of the comparison. If the first characters
are the same, the longer string is greater.
Parameters
The following table shows the parameters of the instruction "S_COMP":
Parameters Declaration Data type Memory area Description
IN1 Input STRING* D, L Input tag in the STRING
format.
IN2 Input STRING* D, L Input tag in the STRING
format.
OUT Output BOOL I, Q, M, D, L Result of comparison
* Define the maximum length of the character string if you use the data type STRING in the interface
declaration for a temporary variable (you will find further information in the description of the data type).
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2089
For additional information on valid data types, refer to "Overview of the valid data types
(Page 899)".
S_CONV: Convert character string
Description
You use this instruction to convert the value at the IN input to the data format you have specified
in the OUT output. The following conversions are possible:
Conversion of a character string (STRING) to a numerical value:
The conversion is performed for all characters of the character string specified in the IN
input parameter. Permitted characters are the digits "0" to "9", the decimal point, and the
plus and minus signs. The first character of the string may be a valid number or a sign.
Leading spaces and exponential notations are ignored.
Character conversion can be interrupted by invalid characters. You decide the output format
of the conversion by selecting a data type for the OUT output parameter.
Conversion of a numerical value to a character string (STRING):
You decide the format of the numeric value to be converted by selecting a data type for the
IN input. A valid tag of the STRING data type must be specified in the OUT output. The
length of the character string after conversion depends on the value at the IN input. The
conversion result is saved as a string starting at the third byte. The first byte of the string
records the maximum length and the second byte the actual length of the character string.
Positive numeric value are output without a sign.
Note
When you convert zero (e.g. INT_TO_STRING(0)), the string will be 6 characters long.
Copying a character string:
If you enter the STRING data type in the input and output parameters of the instruction, the
character string in the IN input will be copied to the OUT output. If the actual length of the
character string in the IN input exceeds the maximum character string length in the OUT
output; only the part of the character string that exactly fits into the character string of OUT
will be copied to IN.
Note
Exponential notation during conversion from floating-point numbers
Do not use exponential notation ("e" or "E") for the conversion from floating-point numbers
with the instruction "S_CONV". Instead, use the instruction "STRG_VAL (Page 2091)" for
the conversion of floating-point numbers with exponential notation. You can use the
FORMAT parameter of the instruction to select exponential notation as input format.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2090 System Manual, 01/2013,
Parameters
The following tables show the parameters of the "S_CONV" instruction, according to the
possible conversions:
Table 9-38 Parameters for converting a character string to a numeric value:
Parameters Declaration Data type Memory area Description
IN Input STRING D, L Value to be converted
OUT Output CHAR, USINT,
UINT, UDINT,
ULINT, SINT, INT,
DINT, LINT,
REAL, LREAL
I, Q, M, D, L Result of the conversion
Table 9-39 Parameters for converting a numeric value to a character string:
Parameter Declaration Data type Memory area Description
IN Input CHAR, USINT,
UINT, UDINT,
ULINT, SINT, INT,
DINT, LINT,
REAL, LREAL
I, Q, M, D, L or constant Value to be converted
OUT Output STRING D, L Result of the conversion
Table 9-40 Parameters for copying a character string:
Parameters Declaration Data type Memory area Description
IN Input STRING D, L Value to be copied
OUT Output STRING D, L Result of the copy operation
For additional information on valid data types, refer to "Overview of the valid data types
(Page 899)".
STRG_VAL: Convert character string to numerical value
Description
The "STRG_VAL" instruction converts a numeric character string to the corresponding integer
or floating-point notation:
You specify the character string to be converted in the IN input parameter.
You define the format of the output value by selecting a data type for the OUT output
parameter. You can query the result in the OUToutput parameter.
Permitted characters for the conversion are the digits "0" to "9", the decimal point, the decimal
comma, notations "E" and "e", and the plus and minus characters. The conversion can be
interrupted by invalid characters.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2091
Parameters
The following table shows the parameters of the "STRG_VAL" instruction:
Parameter Declaration Data type Memory area Description
S7-1200 S7-1500
IN Input STRING STRING D, L Numeric character string to
be converted
FORMAT Input WORD WORD I, Q, M, D, L or
constant
Output format of the
characters
P Input UINT UINT I, Q, M, D, L or
constant
Reference to the first
character to be converted
(first character = 1, the value
"0" or a value > length of the
string is invalid)
OUT Output USINT, SINT,
UINT, INT,
UDINT, DINT,
REAL, LREAL
USINT, SINT,
UINT, INT,
UDINT, DINT,
ULINT, LINT,
REAL, LREAL
I, Q, M, D, L Result of the conversion
For additional information on valid data types, refer to "Overview of the valid data types
(Page 899)".
Parameter FORMAT
You use the FORMAT parameter to specify how the characters of a character string are to be
interpreted. Exponential values can also be converted and represented with the "STRG_VAL"
instruction. Only tags of the USINT data type can be specified in the FORMAT parameter.
The following table shows the possible values of the FORMAT parameter and their meaning:
Value
(W#16#....)
Notation Decimal representation
0000 Decimal fraction "."
0001 ","
0002 Exponential "."
0003 ","
0004 to FFFF Invalid values
Parameter P
The conversion starts at the character whose position you specified in the P parameter. If, for
example, the value "1" is specified in the P parameter, the conversion starts at the first
character of the specified character string.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2092 System Manual, 01/2013,
Example
The following table shows examples of the conversion of a character string to a numeric value:
IN (STRING) FORMAT
(W#16#....)
OUT (data type) OUT (value) ENO status
'123' 0000 INT/DINT 123 1
'-00456' 0000 INT/DINT -456 1
'123.45' 0000 INT/DINT 123 1
'+2345' 0000 INT/DINT 2345 1
'00123AB' 0000 INT/DINT 123 1
'123' 0000 REAL 123.0 1
'-00456' 0001 REAL -456.0 1
'+00456' 0001 REAL 456.0 1
'123.45' 0000 REAL 123.45 1
'123.45' 0001 REAL 12345.0 1
'123,45' 0000 REAL 12345.0 1
'123,45' 0001 REAL 123.45 1
'.00123AB' 0001 REAL 123.0 1
'1.23e-4' 0000 REAL 1.23 1
'1.23E-4' 0000 REAL 1.23 1
'1.23E-4' 0002 REAL 1.23E-4 1
'12,345.67' 0000 REAL 12345.67 1
'12,345.67' 0001 REAL 12.345 1
'3.4e39' 0002 REAL W#16#7F800000 1
'-3.4e39' 0002 REAL W#16#FF800000 1
'1.1754943e-38' 0002 REAL 0.0 1
'12345' -/- SINT 0 0
'A123' -/- -/- 0 0
'' -/- -/- 0 0
'++123' -/- -/- 0 0
'+-123' -/- -/- 0 0
VAL_STRG: Convert numerical value to character string
Description
The "VAL_STRG" instruction is used to convert a numerical value into a character string.
You specify the value to be converted in the IN input parameter. You decide the format of
the numeric value by selecting a data type.
You query the result of the conversion in the OUT output parameter.
Permitted characters for the conversion are the digits "0" to "9", the decimal point, the decimal
comma, notations "E" and "e", and the plus and minus characters. The conversion can be
interrupted by invalid characters.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2093
Parameters
The following table shows the parameters of the "VAL_STRG" instruction:
Parameter Declaration Data type Memory area Description
S7-1200 S7-1500
IN Input USINT, SINT,
UINT, INT,
UDINT, DINT,
REAL, LREAL
USINT, SINT,
UINT, INT,
UDINT, DINT,
ULINT, LINT,
REAL, LREAL
I, Q, M, D, L or
constant
Value to be converted
SIZE Input USINT USINT I, Q, M, D, L or
constant
Number of character
positions
PREC Input USINT USINT I, Q, M, D, L or
constant
Number of decimal places
FORMAT Input WORD WORD I, Q, M, D, L or
constant
Output format of the
characters
P InOut UINT UINT I, Q, M, D, L or
constant
Character starting at which
the result is written.
OUT Output STRING STRING D, L Result of the conversion
For additional information on valid data types, refer to "Overview of the valid data types
(Page 899)".
Parameter P
With the P parameter, you specify the character in the string starting at which the result is
written. If, for example, the value "2" is specified in the P parameter, the converted value is
saved starting at the second character of the string.
Parameter SIZE and P
Use the SIZE parameter to specify how many characters of the character string will be written.
This is counted starting from the character specified in the P parameter. If the output value is
shorter than the specified length, the result is written to the character string right-justified. The
empty character positions are filled with blanks.
Parameter FORMAT
Use the FORMAT parameter to specify how the numerical value is interpreted during
conversion and written to the character string. You can specify only tags of the FORMAT data
type in the USINT parameter.
The following table shows the possible values of the FORMAT parameter and their meaning:
Value
(W#16#....)
Notation Sign Decimal representation
0000 Decimal fraction "-" "."
0001 ","
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2094 System Manual, 01/2013,
Value
(W#16#....)
Notation Sign Decimal representation
0002 Exponential "."
0003 ","
0004 Decimal fraction "+" and "-" "."
0005 ","
0006 Exponential "."
0007 ","
0008 to FFFF Invalid values
Parameter PREC
Use the PREC parameter to define the number of decimal places when converting floating-
point numbers. A maximum precision of seven numbers is supported for numerical values of
the REAL data type. If the value to be converted is an integer, you use the PREC parameter
to specify the position where the decimal point will be placed.
Example
The following table shows examples of the conversion of numeric values to a character string.
IN (value) IN (data type) P SIZE FORMAT (W#16#....) PREC OUT (STRING) ENO status
123 UINT 16 10 0000 0 xxxxxxx123 C 1
0 UINT 16 10 0000 2 xxxxxx0.00 C 1
12345678 UDINT 16 10 0000 3 x12345.678 C 1
12345678 UDINT 16 10 0001 3 x12345.678 C 1
123 INT 16 10 0004 0 xxxxxx+123 C 1
-123 INT 16 10 0004 0 xxxxxx-123 C 1
-0.00123 REAL 16 10 0004 4 xxx-0.0012 C 1
-0.00123 REAL 16 10 0006 4 -1.2300E-3 C 1
-Inf
1)
REAL 16 10 -/- 4 xxxxxx-INF C 0
+Inf
2)
REAL 16 10 -/- 4 xxxxxx+INF C 0
NaN
3)
REAL 16 10 -/- 4 xxxxxxxNaN C 0
12345678 UDINT 16 6 -/- 3 xxxxxxxxxx C 0
"x" represents blanks
1)
-Inf: Floating-point number representing a negative infinite value.
2)
+Inf: Floating-point number representing a positive infinite value.
3)
NaN: Value returned as the result of invalid math operations.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2095
Strg_TO_Chars: Convert character string to Array of CHAR
Description
Use this instruction to copy characters from a character string STRING to a field of several
characters of the data type CHAR or BYTE (Array of CHAR / BYTE).
Specify the character string from which characters are to be copied at the input parameter
STRG.
The characters are written to a data type Array of CHAR or Array of BYTE at the parameter
CHARS. With the PCHARS parameter, you specify the position starting at which the
characters are to be written to the field Array of CHAR / BYTE. The lower limit of the array
is used as standard (example: "1" with Array[1 .. 10] of CHAR).
The number of characters in the field Array of CHAR must be at least as many characters
as are to be copied from the character string STRING.
Only ASCII characters are valid for data types STRING, BYTE and CHAR.
Parameter
The following table shows the parameters of the instruction "Strg_TO_Chars":
Parameter Declaration Data type Memory area Description
STRG Input STRING D, L or constant Source: Character string
PCHARS Input DINT I, Q, M, D, L or constant Position in the destination character string
from which the characters will be written.
CHARS InOut VARIANT D, L Destination: Field in which the characters
will be copied. The characters are copied
to a field of data type Array of CHAR or
Array of BYTE.
CNT Output UINT I, Q, M, D, L Number of copied characters.
For additional information on valid data types, refer to "Overview of the valid data types
(Page 899)".
Chars_TO_Strg: Convert Array of CHAR to character string
Description
Use the instruction "Chars_TO_Strg" to copy characters from a field of multiple characters of
the data type CHAR or BYTE (Array of CHAR / BYTE) to a character string STRING.
Specify the characters of the field Array of CHAR / BYTE to be copied to a character string
at the input parameter CHARS. Use the PCHARS parameter to specify the position starting
at which the characters of the Array are to be copied. The lower limit of the array is used
as standard (example: "1" with Array[1 .. 10] of CHAR).
The characters are written to a data type STRING at the parameter STRG. The number of
characters in the character string STRING must be at least as many characters as are to
be copied from the field Array of CHAR.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2096 System Manual, 01/2013,
Only ASCII characters are valid for data types STRING, CHAR and BYTE.
Parameter
The following table shows the parameters of the instruction "Chars_TO_Strg":
Parameter Declaration Data type Memory area Description
CHARS Input VARIANT D, L Source: Field from which the
characters will be copied.
PCHARS Input DINT I, Q, M, D, L or
constant
Position in the field Array of CHAR /
Array of BYTE from which the
characters will be copied.
CNT Input UINT I, Q, M, D, L or
constant
Number of characters to be copied.
Use "0" to copy all characters.
STRG Output STRING D, L Destination: Character string
For additional information on valid data types, refer to "Overview of the valid data types
(Page 899)".
MAX_LEN: Determine the length of a character string
Description
A tag of the STRING data type contains two lengths: the maximum length and the current
length (this is the number of currently valid characters).
The maximum length of the character string is specified for each tag in the STRING keyword
in square brackets. The number of bytes occupied by a string is 2 greater than the maximum
length.
The current length represents the number of the character places actually used. The current
length must be less than or equal to the maximum length.
You use the "MAX_LEN" instruction to query the maximum length of the character string
specified at the IN input parameter and output this information as a numerical value at the OUT
output parameter.
If errors occur during processing of the instruction, then an empty string will be output.
Note
Reading out the current length
You can also use the LEN (Page 2102) instruction to read out the current length of a string.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2097
Parameter
The following table shows the parameters of the "MAX_LEN" instruction:
Parameter Declaration Data type Memory area Description
IN Input STRING D, L or constant Character string
OUT Return DINT I, Q, M, D, L Maximum number of characters
For additional information on valid data types, refer to "Overview of the valid data types
(Page 899)".
ATH: Convert ASCII string to hexadecimal number
Description
You use the instruction "ATH" to convert the ASCII character string specified at the IN input
parameter into a hexadecimal number. The result of the conversion is output to the OUT output
parameter.
You can reference the following data types using the pointer in the IN parameter (ASCII):
STRING, Array of CHAR, Array of BYTE.
You can reference the following data types using the pointer in the OUT parameter
(hexadecimal): Bit strings, integers, STRING, Array of CHAR, Array of BYTE.
With the N parameter, you specify the number of ASCII characters to be converted. A maximum
of 32767 valid ASCII characters can be converted. Only digits "0" to "9", upper case letters "A"
to "F", and lower case letters "a" to "f" can be interpreted. All other characters are converted
to zeros.
Since 8 bits are required for the ASCII character and only 4 bits for the hexadecimal digit, the
output word length is only half of the input word length. The ASCII characters are converted
and positioned in the output in the same order as they are read in. If there is an odd number
of ASCII characters, the hexadecimal number is padded with zeros in the nibble to the right of
the last converted hexadecimal number.
Parameters
The following table shows the parameters of the "ATH" instruction:
Parameter Declaration Data type Memory area Description
IN Input VARIANT I, Q, M, D, L or
constant
Pointer to ASCII character string
N Input UINT I, Q, M, D, L or
constant
Number of ASCII characters to be
converted
RET_VAL Return WORD I, Q, M, D, L Status of the instruction
OUT Output VARIANT I, Q, M, D, L Hexadecimal number
For additional information on valid data types, refer to "Overview of the valid data types
(Page 899)".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2098 System Manual, 01/2013,
RET_VAL parameter
Error code
(W#16#....)*
Description
0000 No error
0007 Invalid character. Only the following ASCII characters may be used: Digits "0" to "9", upper case letters
"A" to "F", lower case letters "a" to "f".
8101 Invalid pointer in the IN parameter, e.g., because a non-existing data block is referenced.
8182 Input buffer is too small for data in the N parameter.
8120 Invalid format in the IN parameter.
8151 Non-supported data type in the IN parameter.
8401 Invalid pointer in the OUT parameter, e.g., because a non-existing data block is referenced.
8482 Output buffer is too small for data in the N parameter.
8420 Invalid format in the OUT parameter.
8451 Non-supported data type in the OUT parameter.
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
ASCII characters and hexadecimal values
The following table shows the ASCII characters and the corresponding hexadecimal values:
ASCII character ASCII-coded hexadecimal value Hexadecimal digit
"0" 30 0
"1" 31 1
"2" 32 2
"3" 33 3
"4" 34 4
"5" 35 5
"6" 36 6
"7" 37 7
"8" 38 8
"9" 39 9
"A" 41 A
"B" 42 B
"C" 43 C
D 44 D
E 45 E
F 46 F
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2099
Example
The following table shows examples of the conversion of ASCII character strings to
hexadecimal numbers:
IN N OUT ENO status
'0123' 4 16#0123 1
'123AFx1a23' 10 16#123AF01a23 0
HTA: Convert hexadecimal number to ASCII string
Description
You use the instruction "HTA" to convert the hexadecimal number specified at the IN input into
an ASCII character string. The result of the conversion is stored at the address specified in
the OUT parameter.
You can reference the following data types using the pointer in the IN parameter
(hexadecimal): Bit strings, integers, STRING, Array of CHAR, Array of BYTE.
You can reference the following data types using the pointer in the OUT parameter (ASCII):
STRING, Array of CHAR, Array of BYTE.
With the N parameter, you specify the number of hexadecimal bytes to be converted. Since 8
bits are required for the ASCII character and only 4 bits for the hexadecimal digit, the output
value is twice as long as the input value. Each nibble of the hexadecimal number is converted
to a character while maintaining the original order.
A maximum of 32767 characters can be written to the ASCII character string. The result of the
conversion is represented by the digits "0" to "9" and upper-case letters "A" to "F".
If the complete result of the conversion cannot be displayed in the OUT parameter, the result
is will only be partially written to the parameter.
Parameter
The following table shows the parameters of the "HTA" instruction:
Parameter Declaration Data type Memory area Description
IN Input VARIANT I, Q, M, D, L or
constant
Start address of the hexadecimal
digits
N Input UINT I, Q, M, D, L or
constant
Number of hexadecimal bytes to
be converted
RET_VAL Return WORD I, Q, M, D, L Error message
OUT Output VARIANT I, Q, M, D, L Address at which the result is
stored.
For additional information on valid data types, refer to "Overview of the valid data types
(Page 899)".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2100 System Manual, 01/2013,
RET_VAL parameter
Error code*
(W#16#....)
Description
0000 No error
8101 Invalid pointer at the IN parameter, e.g., because a non-existing data block is referenced.
8182 Input buffer is too small for data in the N parameter.
8120 Invalid format in the IN parameter.
8151 Non-supported data type in the IN parameter.
8401 Invalid pointer in the OUT parameter, e.g., because a non-existing data block is referenced.
8482 Output buffer is too small for data in the N parameter.
8420 Invalid format in the OUT parameter.
8451 Non-supported data type in the OUT parameter.
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
ASCII characters and hexadecimal values
The following table shows the ASCII characters and the corresponding hexadecimal values:
Hexadecimal digit ASCII-coded hexadecimal value ASCII character
0 30 "0"
1 31 "1"
2 32 "2"
3 33 "3"
4 34 "4"
5 35 "5"
6 36 "6"
7 37 "7"
8 38 "8"
9 39 "9"
A 41 "A"
B 42 "B"
C 43 "C"
D 44 "D"
E 45 "E"
F 46 "F"
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2101
Example
The following table shows examples of the conversion of hexadecimal numbers to ASCII
character strings:
IN N OUT ENO status
W#16#0123 2 '0123' 1
16#123AF01023 4 '123AF010' 0
Other instructions
LEN: Determine the length of a character string
Description
A tag of the STRING data type contains two lengths: the maximum length and the current
length (this is the number of currently valid characters).
The maximum length of the character string is specified for each tag in the STRING keyword
in square brackets. The number of bytes occupied by a string is 2 greater than the maximum
length.
The current length represents the number of the character places actually used. The current
length must be less than or equal to the maximum length.
You use the instruction "LEN" to query the current length of the character string specified at
the IN input parameter and output this information as a numerical value at the OUT output
parameter. An empty string ('') has the length zero.
If errors occur during processing of the instruction, then an empty string will be output.
Note
Reading out the maximum length
You can also use the MAX_LEN (Page 2097) instruction to read out the current length of a
string.
Parameters
The following table shows the parameters of the "LEN" instruction:
Parameter Declaration Data type Memory area Description
IN Input STRING D, L or constant Character string
OUT Return INT, DINT,
REAL,
LREAL
I, Q, M, D, L Number of valid characters
For additional information on valid data types, refer to "Overview of the valid data types
(Page 899)".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2102 System Manual, 01/2013,
CONCAT: Combine character strings
Description
You use the instruction "CONCAT" to combine the character string at the IN1 input parameter
with the character string at the IN2 input parameter. The result is output in the OUT output
parameter with the STRING format. If the resulting character string is longer than the tag
specified in the OUT output parameter, then the resulting character string will be limited to the
available length.
If errors occur during processing of the instruction and the OUT output parameter can be
written, an empty string will be output.
Parameters
The following table shows the parameters of the "CONCAT" instruction:
Parameter Declaration Data type Memory area Description
IN1 Input STRING D, L or constant Character string
IN2 Input STRING D, L or constant Character string
OUT Return STRING D, L Resulting character string
For additional information on valid data types, refer to "Overview of the valid data types
(Page 899)".
LEFT: Read the left character of a character string
Description
You use the instruction "LEFT" to extract a partial string beginning with the first character of
the string at the IN input parameter. You specify the number of characters to be extracted in
the L parameter. The extracted characters are output in the OUT output parameter with
STRING format.
If the number of characters to be extracted is greater than the current length of the character
string, the OUT output parameter returns the input character string as a result. If the L
parameter contains the value "0" or the input value is an empty string, an empty string will be
returned. If the value in the L parameter is negative, an empty string will be output.
If errors occur during processing of the instruction and the OUT output parameter can be
written, an empty string will be output.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2103
Parameters
The following table shows the parameters of the "LEFT" instruction:
Parameter Declaration Data type Memory area Description
IN Input STRING D, L or constant Character string
L Input BYTE, INT,
SINT, USINT
I, Q, M, D, L or
constant
Number of characters to be
extracted
OUT Return STRING D, L Extracted partial string
For additional information on valid data types, refer to "Overview of the valid data types
(Page 899)".
RIGHT: Read the right characters of a character string
Description
You use this instruction to extract the last L character in a character string in the input parameter
IN. You specify the number of characters to be extracted in the L parameter. The extracted
characters are output in the OUT output parameter with STRING format.
If the number of characters to be extracted is greater than the current length of the character
string, the OUT output parameter returns the input character string as a result. If the L
parameter contains the value "0" or the input value is an empty string, an empty string will be
returned. If the value in the L parameter is negative, an empty string will be output.
If errors occur during processing of the instruction and the OUT output parameter can be
written, an empty string will be output.
Parameters
The following table shows the parameters of the "RIGHT" instruction:
Parameter Declaration Data type Memory area Description
IN Input STRING D, L or constant Character string
L Input BYTE, INT,
SINT, USINT
I, Q, M, D, L or
constant
Number of characters to be
extracted
OUT Return STRING D, L Extracted partial string
For additional information on valid data types, refer to "Overview of the valid data types
(Page 899)".
MID: Read middle characters of a character string
Description
You use this instruction to extract a portion of the character string in the IN input parameter.
With the P parameter, you specify the position of the first character to be extracted. With the
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2104 System Manual, 01/2013,
L parameter, you define the length of the character string to be extracted. The extracted partial
character string is output to the OUT output parameter.
The following rules must be observed when executing the instruction:
If the number of characters to be extracted exceeds the current length of the character
string in the IN input parameter, a partial character string will be output, starting from
character position P and continuing to the end of the character string.
If the character position specified in the P parameter falls outside the current character
string length in the IN input parameter, an empty character string will be output in the OUT
output parameter.
If the value of the P or L parameter equals zero or is negative, an empty character string
will be output in the OUT output parameter.
If errors occur during processing of the instruction and the OUT output parameter can be
written, an empty string will be output.
Parameters
The following table shows the parameters of the "MID" instruction:
Parameter Declaration Data type Memory area Description
IN Input STRING D, L or constant Character string
L Input BYTE, INT,
SINT,
USINT
I, Q, M, D, L or
constant
Length of the string to be extracted
P Input BYTE, INT,
SINT,
USINT
I, Q, M, D, L or
constant
Position of the first character to be
extracted (first character = 1)
OUT Return STRING D, L Extracted partial string
For additional information on valid data types, refer to "Overview of the valid data types
(Page 899)".
DELETE: Delete characters in a character string
Description
You use this instruction to delete a portion of the character string in the IN input parameter.
With the P parameter, you specify the position of the first character to be deleted. You specify
the number of characters to be deleted in the L parameter. The remaining partial character
string is output to the OUT output parameter with STRING format.
The following rules must be observed when executing the instruction:
If the value in the P parameter is less than or equals zero, an empty character string will
be output in the OUT output parameter.
If the value in the P parameter is greater than the current length of the character string in
the IN input, the input character string will be returned in the OUT output parameter.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2105
If the value in the L parameter equals zero, the input character string will be returned in the
OUT output parameter.
If the number of characters to be deleted at the L parameter is greater than the length of
the character string in the IN parameter, an empty character string will be output.
If the value in the L parameter is negative, an empty character string will be output.
If errors occur during processing of the instruction and the OUT output parameter can be
written, an empty string will be output.
Parameter
The following table shows the parameters of the "DELETE" instruction:
Parameter Declaration Data type Memory area Description
IN Input STRING D, L or constant Character string
L Input BYTE, INT,
SINT, USINT
I, Q, M, D, L or
constant
Number of characters to be deleted
P Input BYTE, INT,
SINT, USINT
I, Q, M, D, L or
constant
Position of first character to be
deleted
OUT Return STRING D, L Resulting character string
For additional information on valid data types, refer to "Overview of the valid data types
(Page 899)".
INSERT: Insert characters in a character string
Description
You use this instruction to insert the character string in the IN2 input parameter to the character
string in the IN1 input parameter. With the P parameter, you specify the position of the character
starting at which the characters are inserted. The result is output in the OUT output parameter
with the STRING format.
The following rules must be observed when executing the instruction:
If the value in the P parameter exceeds the current length of the character string in the IN1
input parameter, the character string of the IN2 input parameter will be appended to the
character string of the IN1 input parameter.
If the value at the P parameter is zero, the character string at the IN2 parameter followed
by the character string at the IN1 parameter will be output in the OUT output parameter.
If the value in the P parameter is negative, an empty character string will be output in the
OUT output parameter.
If the resulting character string is longer than the tag specified in the OUT output parameter,
the resulting character string will be limited to the available length.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2106 System Manual, 01/2013,
Parameter
The following table shows the parameters of the "INSERT" instruction:
Parameter Declaration Data type Memory area Description
IN1 Input STRING D, L or constant Character string
IN2 Input STRING D, L or constant String to insert
P Input BYTE,
INT, SINT,
USINT
I, Q, M, D, L or
constant
Insert position
OUT Return STRING D, L Resulting character string
For additional information on valid data types, refer to "Overview of the valid data types
(Page 899)".
REPLACE: Replace characters in a character string
Description
You use this instruction to replace a portion of the character string in the IN1 input with the
character string in the IN2 input. You specify the position of the first character to be replaced
in the P parameter. You specify the number of characters to be replaced in the L parameter.
The result is output in the OUT output parameter with the STRING format.
The following rules must be observed when executing the instruction:
If the value in the P parameter is less than or equals zero, an empty character string will
be output in the OUT output parameter.
If the value in the L parameter is less than zero, an empty character string will be output in
the OUT output parameter.
If the value in the P parameter exceeds the current length of the character string in the IN1
input parameter, the content of the character string in the IN1 parameter will be written to
the OUT output parameter.
If P equals one, the character string in the IN1 input will be replaced beginning with (and
including) the first character.
If the value in the P parameter exceeds the current length of the character string in the IN1
input parameter, the character string of the IN2 input parameter will be appended to the
character string of the IN1 input parameter.
If the resulting character string is longer than the tag specified in the OUT output parameter,
the resulting character string will be limited to the available length.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2107
Parameters
The following table shows the parameters of the "REPLACE" instruction:
Parameter Declaration Data type Memory area Description
IN1 Input STRING D, L or constant String with characters to be
replaced.
IN2 Input STRING D, L or constant String with characters to be
inserted.
L Input BYTE, INT,
SINT, USINT
I, Q, M, D, L or
constant
Number of characters to be
replaced
P Input BYTE, INT,
SINT, USINT
I, Q, M, D, L or
constant
Position of first character to be
replaced
OUT Return STRING D, L Resulting character string
For additional information on valid data types, refer to "Overview of the valid data types
(Page 899)".
FIND: Find characters in a character string
Description
You can use this instruction to search through the character string in the IN1 input parameter
for a specific character or a specific string of characters.
You specify the value to be searched for in the IN2 input parameter. The search is made
from left to right.
The position of the first occurrence is output in the OUT output parameter. If the search
returns no match, the value "0" will be output in the OUT output parameter.
If errors occur during processing of the instruction, an empty string will be output.
Parameters
The following table shows the parameters of the "FIND" instruction:
Parameter Declaration Data type Memory area Description
IN1 Input STRING D, L or constant String searched through
IN2 Input STRING,
CHAR
D, L or constant
(For CHAR also I, Q,
M)
Characters to search for
OUT Return DINT, INT,
LREAL,
REAL
I, Q, M, D, L Character position
For additional information on valid data types, refer to "Overview of the valid data types
(Page 899)".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2108 System Manual, 01/2013,
9.8.3.3 Distributed I/O
RDREC: Read data record
Description
You use the instruction "RDREC" to read the data record with the number INDEX from the
component addressed using the ID. This may be a module in a central rack or a distributed
component (PROFIBUS DP or PROFINET IO).
Use MLEN to specify the maximum number of bytes you want to read. If length "0" is
selected at the parameter MLEN, the complete data record is written at the parameter
RECORD.
The target range RECORD should have at least the length of MLEN bytes.
The value TRUE for the output parameter VALID indicates that the data record was
successfully transferred to the target range RECORD. In this case, the LEN output
parameter contains the length of the read data in bytes.
If an error has occurred during transfer of the data record, this is indicated by the output
parameter ERROR. In this case, the output parameter STATUS contains the error
information.
Note
The interface of the "RDREC" instruction is identical to the "RDREC" FB defined in
"PROFIBUS Guideline PROFIBUS Communication and Proxy Function Blocks according to
IEC 61131-3".
Functional description
"RDREC" works asynchronously, which means its execution extends over multiple calls. You
start the data record transfer by calling "RDREC" with REQ= 1.
The job status is displayed via the output parameter BUSY and the two central bytes of output
parameter STATUS. The two central bytes of STATUS correspond to the RET_VAL output
parameter of the instructions that operate asynchronously.
See also: Meaning of the parameters REQ, RET_VAL and BUSY with asynchronous
instructions (Page 1420).
The transfer of the data record is complete when the output parameter BUSY has the value
FALSE .
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2109
Parameter
The following table shows the parameters of the instruction "RDREC":
Parameter Declaration Data type* Memory area Description
REQ Input BOOL I, Q, M, D, L, T, C or
constant
REQ = 1: Transfer data record
ID Input HW_IO I, Q, M, L or constant Hardware identifier of the hardware
component (DP/PROFINET IO)
The number is assigned automatically and is
stored in the properties of the component or of
the interface in the hardware configuration.
INDEX Input BYTE, DINT,
INT, SINT,
UINT, USINT,
WORD
I, Q, M, D, L or
constant
Data record number
MLEN Input BYTE, UINT,
USINT
I, Q, M, D, L or
constant
Maximum length in bytes of the data record
information to be read
VALID Output BOOL I, Q, M, D, L New data record was received and is valid
BUSY Output BOOL I, Q, M, D, L BUSY = 1: The reading process is not yet
complete.
ERROR Output BOOL I, Q, M, D, L ERROR = 1: An error occurred during the
reading process.
STATUS Output DWORD I, Q, M, D, L Block status or error information
LEN Output UINT I, Q, M, D, L Length of the read data record information
RECORD InOut VARIANT I, Q, M, D, L Target range for the data record read.
* There is no implicit conversion in STL, which is why the range of valid data types may be limited. During programming in
STL, please note the valid data types. These are displayed in the parameter tooltip.
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
Note
If you use "RDREC" to read a data record for PROFINET IO, then negative values in the
INDEX, MLEN, and LEN parameters will be interpreted as an unsigned 16-bit integer.
STATUS parameter
For interpretation of the STATUS parameter, see Parameter STATUS (Page 2118).
See also
Basics of block access (Page 851)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2110 System Manual, 01/2013,
WRREC: Write data record
Description
The instruction "WRREC" is used to transfer the RECORD data record to the component
addressed using ID. This may be a module in a central rack or a distributed component
(PROFIBUS DP or PROFINET IO).
Use LEN to specify the length of the data record to be transmitted in bytes. The selected
length of the source range RECORD should have at least the length of LEN bytes.
The value TRUE at output parameter DONE indicates that the data record has been
successfully transferred.
If an error has occurred during transfer of the data record, this is indicated by the output
parameter ERROR. In this case, the output parameter STATUS contains the error
information.
Note
The interface of the "WRREC" instruction is identical to the "WRREC" FB defined in
"PROFIBUS Guideline PROFIBUS Communication and Proxy Function Blocks according to
IEC 61131-3".
Functional description
"The WRREC" instruction works asynchronously, that is, its execution extends over multiple
calls. You start the data record transfer by calling "WRREC" with REQ = 1.
The job status is displayed via the output parameter BUSY and the two central bytes of output
parameter STATUS. The two central bytes of STATUS correspond to the RET_VAL output
parameter of the instructions that operate asynchronously.
See also: Meaning of the parameters REQ, RET_VAL and BUSY with asynchronous
instructions (Page 1420).
Note that you must assign the same value to the actual parameter of RECORD for all "WRREC"
calls that belong to one and the same job. The same applies to the actual parameters of LEN.
The transfer of the data record is complete when the output parameter BUSY has the value
FALSE.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2111
Parameter
The following table shows the parameters of the instruction "WRREC":
Parameter Declaration Data type Memory area Description
REQ Input BOOL I, Q, M, D, L, T, C or
constant
REQ= 1: Transfer data record
ID Input HW_IO I, Q, M, L or constant ID number of the hardware component (DP/
PROFINET IO)
The number is assigned automatically and is
stored in the properties of the component or of
the interface in the hardware configuration.
INDEX Input DINT I, Q, M, D, L or
constant
Data record number
LEN Input BYTE, UINT,
USINT
I, Q, M, D, L or
constant
(hidden)
Maximum length of the data record to be
transferred in bytes
DONE Output BOOL I, Q, M, D, L Data record was transferred
BUSY Output BOOL I, Q, M, D, L BUSY= 1: The writing process is not yet
complete.
ERROR Output BOOL I, Q, M, D, L ERROR = 1: An error occurred during the
writing process.
STATUS Output DWORD I, Q, M, D, L Block status or error information
For interpretation of the STATUS parameter,
see Parameter STATUS (Page 2118).
RECORD InOut VARIANT I, Q, M, D, L Data record
For additional information on valid data types, refer to "Overview of the valid data types
(Page 899)".
Note
If you use "WRREC" to write a data record for PROFINET IO, negative values in the INDEX
and LEN parameters will be interpreted as an unsigned 16-bit integer.
STATUS parameter
For interpretation of the STATUS parameter, see Parameter STATUS (Page 2118).
GETIO: Read process image
Description
You use the instruction "GETIO" to consistently read out all inputs of a DP standard slave/
PROFINET IO device. The instruction "GETIO" calls the instruction "DPRD_DAT (Page 2142)".
If there was no error during the data transmission, the data that have been read are entered
in the target range indicated by INPUTS .
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2112 System Manual, 01/2013,
The target range must have the same length that you configured for the selected component.
If you read from a DP standard slave with a modular configuration or with several DP identifiers,
you can only access the data of one component/DP identifier at the configured start address
with a "GETIO" call.
Parameter
The following table shows the parameters of the instruction "GETIO":
Parameter Declaration Data type Memory area Description
ID Input HW_SUBMOD
ULE
I, Q, M, D, L or constant Hardware ID of the DP standard slave /
PROFINET IO device.
STATUS Output DWORD I, Q, M, D, L Contains the error information of
"DPRD_DAT (Page 2142)" in the form
DW#16#40xxxx00.
LEN Output INT I, Q, M, D, L Amount of data read in bytes
INPUTS InOut VARIANT I, Q, M, D Target range for the read data. It must have
the same length as the range that you
configured for the selected DP standard
slave / PROFINET IO device. Only the
BYTE data type is permitted.
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
STATUS parameter
See also: DPRD_DAT: Read consistent data of a DP standard slave (Page 2142).
SETIO: Transfer process image
Description
You use the instruction "SETIO" to consistently transfer data from the source range defined
by the parameter OUTPUTS to the addressed DP standard slave / PROFINET IO device,
and, if necessary, to the process image (if you have configured the relevant address area of
the DP standard slave / PROFINET IO device as a consistent range in a process image).
"SETIO" calls the instruction "DPWR_DAT (Page 2143)".
The source range must have the same length that you configured for the selected component.
In the case of a DP standard slave / PROFINET IO device with modular configuration or with
several DP identifiers, you can only access one DP identifier / component per "SETIO" call.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2113
Parameter
The following table shows the parameters of the instruction "SETIO":
Parameter Declaration Data type Memory area Description
ID Input HW_SUBMODU
LE
I, Q, M, D, L or
constant
Hardware ID of the DP standard slave /
PROFINET IO device.
LEN Input INT I, Q, M, D, L or
constant
irrelevant
STATUS Output DWORD I, Q, M, D, L Contains the error information of
"DPWR_DAT (Page 2143)" in the form
DW#16#40xxxx00.
OUTPUTS InOut VARIANT I, Q, M, D Source range for the data to be written. It
must have the same length as the range
that you configured for the selected DP
standard slave / PROFINET IO device.
Only the BYTE data type is permitted.
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
STATUS parameter
See also: DPWR_DAT: Write consistent data of a DP standard slave (Page 2143).
GETIO_PART: Read process image area
Description
You use the instruction "GETIO_PART" to consistently read out a related part of the inputs of
an IO module. "GETIO_PART" calls the instruction "DPWR_DAT (Page 2142)".
Use the ID input parameter to select the IO module by means of the hardware ID.
You use the OFFSET and LEN parameters to specify the portion of the process image area
to be read. If the input area spanned by OFFSET and LEN is not completely covered by the
module, the block returns the error code DW#16#4080B700.
The length of the target range must be larger than or equal to the amount of bytes to be read:
If there was no error during the data transmission, ERROR receives the value FALSE. The
data that are read are written to the target range defined at the INPUTS parameter.
If there was no error during the data transmission, ERROR receives the value TRUE. The
STATUS parameter receives the error information from "DPRD_DAT".
If the target range is greater than LEN, then the first LEN bytes of the target range will be
written. ERROR receives the value FALSE.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2114 System Manual, 01/2013,
Parameter
The following table shows the parameters of the instruction "GETIO_PART":
Parameter Declaration Data type Memory area Description
ID Input HW_SUBMOD
ULE
I, Q, M, D, L or constant Hardware identifier of the module
OFFSET Input INT I, Q, M, D, L or constant Number of the first byte to be read in the
process image for the component
(smallest possible value: 0).
LEN Input INT I, Q, M, D or constant Number of bytes to be read.
STATUS Output DWORD I, Q, M, D, L Contains the error information of
"DPRD_DAT" in the form
DW#16#40xxxx00, if ERROR = TRUE.
ERROR Output BOOL I, Q, M, D, L Error display:
ERROR = TRUE if an error occurs when
"DPRD_DAT" is called.
INPUTS InOut VARIANT I, Q, M, D Target range for read data:
If the target range is greater than LEN, the
first LEN bytes of the target range are
written.
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
STATUS parameter
See "RET_VAL" parameter of the "DPRD_DAT (Page 2142)" instruction.
SETIO_PART: Transfer process image area
Description
You can use the "SETIO_PART" instruction to consistently write data from the source area
spanned by OUTPUTS to the outputs of an IO module. "SETIO_PART" calls the instruction
"DPWR_DAT (Page 2143)".
Use the ID input parameter to select the IO module by means of the hardware ID.
You use the OFFSET and LEN parameters to specify the portion of the process image area
to be written for the components addressed by means of ID. If the output area spanned by
OFFSET and LEN is not completely covered by the module, the block returns the error code
DW#16#4080B700.
The length of the source range must be greater than or equal to the number of bytes to be
written:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2115
If there was no error during the data transmission, ERROR receives the value FALSE.
If there was an error during the data transmission, ERROR receives the value TRUE, and
STATUS receives the error information of "DPWR_DAT".
If the source range is greater than LEN, the first LEN bytes from OUTPUTS are transferred.
ERROR receives the value FALSE.
Parameter
The following table shows the parameters of the instruction "SETIO_PART":
Parameter Declaration Data type Memory area Description
ID Input HW_SUBMO
DULE
I, Q, M, D, L or constant Hardware identifier of the IO module.
OFFSET Input INT I, Q, M, D, L or constant Number of the first byte to be written in the
process image for the component (smallest
possible value: 0).
LEN Input INT I, Q, M, D, L or constant Number of bytes to be written.
STATUS Output DWORD I, Q, M, D, L Contains the error information of
"DPWR_DAT" in the form
DW#16#40xxxx00, if ERROR = TRUE.
ERROR Output BOOL I, Q, M, D, L Error display:
ERROR = TRUE if an error occurs when
"DPWR_DAT" is called.
OUTPUTS InOut VARIANT I, Q, M, D Source range for the data to be written:
If the source range is greater than LEN, the
first LEN bytes are transferred from
OUTPUTS.
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
Parameters STATUS and ERROR
See instruction "DPWR_DAT (Page 2143)".
RALRM: Receive interrupt
Description RALRM
Description
The instruction receives an interrupt with all corresponding information from an I/O module
(centralized structure) or from a DP slave or PROFINET IO device component; it supplies this
information to its output parameters.
The information in the output parameters contains the start information of the called OB as
well as information of the interrupt source.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2116 System Manual, 01/2013,
Call "RALRM" only within the interrupt OB started by the CPU operating system as a result of
the I/O interrupt that is to be examined.
Note
If you call "RALRM" in an OB whose start event is not an I/O interrupt, the instruction will
provide correspondingly reduced information in its outputs.
Make sure to use different instance DBs when you call "RALRM" in different OBs. If you
evaluate data resulting from an "RALRM" call outside of the associated interrupt OB, you
should moreover use a separate instance DB per OB start event.
Note
The interface of the "RALRM" instruction is identical to the "RALRM" FB defined in
"PROFIBUS Guideline PROFIBUS Communication and Proxy Function Blocks according to
IEC 61131-3".
Calling RALRM
"RALRM" can be called in three operating modes (MODE parameter). These are explained in
the table below.
MODE RALRM ...
0 ... shows the component that triggered the interrupt in the ID output parameter and writes TRUE in the NEW
output parameter.
1 ... writes all output parameters, independent of the interrupt triggering component.
2 ... checks whether the component specified in the F_ID input parameter has triggered the interrupt.
If not, NEW = FALSE
If yes, NEW = TRUE and all other output parameters are written.
Parameter
The following table shows the parameters of the instruction "RALRM":
Parameter Declaration Data type Memory area Description
MODE Input BYTE, INT,
SINT, USINT
I, Q, M, D, L or
constant
Mode
F_ID Input HW_IO (WORD) D, L or constant Logical start address of the component (module)
from which interrupts will be received
MLEN Input BYTE, UINT,
USINT
I, Q, M, D, L or
constant
Maximum length of the interrupt information to
be received, in bytes
NEW Output BOOL I, Q, M, D, L A new interrupt was received.
STATUS
(Page 2118)
Output DWORD I, Q, M, D, L Error code of the instruction or DP master
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2117
Parameter Declaration Data type Memory area Description
ID Output HW_IO (WORD) I, Q, M, L or constant Logical start address of the component (module)
from which an interrupt was received
Bit 15 contains the I/O ID: 0 = input address, 1 =
output address.
LEN Output DINT, DWORD,
LREAL, REAL,
UDINT, UINT
I, Q, M, D, L Length of the received interrupt information
TINFO
(Page 2122)
InOut VARIANT I, Q, M, D, L Destination area for OB start and management
information
AINFO
(Page 2125)
InOut VARIANT I, Q, M, D, L Destination area for header information and
additional interrupt information
For AINFO , you should provide a length of at
least MLEN bytes.
For additional information on valid data types, refer to "Overview of the valid data types
(Page 899)".
Note
If you select a target range (Page 2131) TINFO or AINFO that is too short, RALRM cannot
enter the full information.
Parameter STATUS
Description
The STATUS output parameter contains error information. If it is interpreted as
ARRAY[1...4] of BYTE, then error information will have the following structure:
Array element Name Meaning
STATUS[1] Function_Num B#16#00, if no error
Function ID from DPV1-PDU:
In the event of an error, B#16#80 is output (in the event of an error reading a
data record B#16#DE and writing a data record B#16#DF).
If no DPV1 protocol element is used, then B#16#C0 will be output.
STATUS[2] Error_Decode Location of the error ID
STATUS[3] Error_Code_1 Error ID
STATUS[4] Error_Code_2 Manufacturer-specific error ID extension
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2118 System Manual, 01/2013,
Array element STATUS[2]
STATUS[2] can have the following values:
Error_Decode
(B#16#...)
Source Meaning
00 to 7F CPU No error or no warning
80 DPV1 Error according to IEC 61158-6
81 to 8F CPU B#16#8x shows an error in the xth call parameter of the instruction.
FE, FF DP profile Profile-specific error
Array element STATUS[3]
STATUS[3] can have the following values:
Error_Decode
(B#16#...)
Error_Code_1
(B#16#...)
Explanation
according to DVP1
Meaning
00 00 No error, no warning
70 00 reserved, reject Initial call; no active data record transfer
01 reserved, reject Initial call; data record transfer has started
02 reserved, reject Intermediate call; data record transfer already active
80 90 reserved, pass Invalid logical start address
92 reserved, pass Illegal type for VARIANT pointer
93 reserved, pass The DP component addressed via ID or F_ID is not
configured.
96 The "RALRM (Page 2116)" cannot supply the OB start
information, management information, header information,
or additional interrupt information.
For OBs 4x, 55, 56, 57, 82, and 83, you can use the
"DPNRM_DG (Page 2156)" instruction to read the current
diagnostic frame of the relevant DP slave asynchronously
(address information from OB start information).
A0 read error Negative acknowledgment while reading the module
A1 write error Negative acknowledgement when writing
to the module
A2 module failure DP protocol error at layer 2 (e.g., slave failure or bus
problems)
A3 reserved, pass PROFIBUS DP: DP protocol error with Direct-Data-Link-
Mapper or User-Interface/User
PROFINET IO: General CM error
A5 reserved, pass
A7 reserved, pass DP slave or module is occupied (temporary error
A8 version conflict DP slave or module reports non-compatible versions
A9 feature not
supported
Function is not supported by DP slave or module
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2119
Error_Decode
(B#16#...)
Error_Code_1
(B#16#...)
Explanation
according to DVP1
Meaning
AA to AF user specific DP slave or module reports a manufacturer-specific error
in its application. Please check the documentation from the
manufacturer of the DP slave or module.
B0 invalid index Data record not known in module
Illegal data record number 256
B1 write length error The length information in the RECORD parameter is
incorrect
With "RALRM (Page 2116)": length error in AINFO
(Page 2125),
with "RDREC (Page 2109)" and "WRREC (Page 2111)":
length error in MLEN
B2 invalid slot The configured slot is
not assigned.
B3 type conflict Actual module type
does not match
specified module type
B4 invalid area DP slave or module reports access to an invalid area
B5 state conflict DP slave or module not ready
B6 access denied DP slave or module denies access
B7 invalid range DP slave or module reports an invalid range for a parameter
or value
B8 invalid parameter DP slave or module reports an invalid parameter
B9 invalid type DP slave or module reports an invalid type
With "RDREC (Page 2109)": buffer too small (subsets
cannot be read)
With "WRREC (Page 2111)": buffer too small (subsets
cannot be written)
BA to BF user specific DP slave or module reports a manufacturer-specific error
when accessing. Please check the documentation from the
manufacturer of the DP slave or module.
C0 read constrain
conflict
With "WRREC (Page 2111)": the data can only be written
when the CPU is in STOP mode. Note: this means that
writing by the user program is not possible. You can only
write the data online with PG/PC.
With "RDREC (Page 2109)": the module routes the data
record, but either no data is present or the data can only be
read when the CPU is in STOP mode. Note: if data can only
be read when the CPU is in STOP mode, then an evaluation
by the user program is not possible. In this case, you can
only read the data online with PG/PC.
C1 write constrain
conflict
The data of the previous write job on the module for the
same data record have not yet been processed by the
module.
C2 resource busy The module is currently processing the maximum possible
number of jobs for a CPU.
C3 resource unavailable The required operating resources are currently occupied.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2120 System Manual, 01/2013,
Error_Decode
(B#16#...)
Error_Code_1
(B#16#...)
Explanation
according to DVP1
Meaning
C4 Internal temporary error. Job could not be executed.
Repeat the job. If this error occurs often, check your
installation for sources of electrical interference.
C5 DP slave or module not available.
C6 Data record transfer was canceled due to priority class
cancellation
C7 Job aborted due to warm or cold restart on the DP master
C8 to CF DP slave or module reports a manufacturer-specific
resource error. Please check the documentation from the
manufacturer of the DP slave or module.
Dx user specific DP slave specific. Refer to the description of the DP slave.
81 00 to FF Error in the initial call parameter (with "RALRM
(Page 2116)": MODE)
00 Illegal operating mode
82 00 to FF Error in the second call parameter
: : :
88 00 to FF Error in the eighth call parameter (with "RALRM
(Page 2116)": TINFO (Page 2122))
01 Wrong syntax ID
23 Quantity structure exceeded or target range too small
24 Wrong range ID
32 DB/DI no. out of user range
3A DB/DI no. is NULL for area ID DB/DI or specified DB/DI
does not exist
89 00 to FF Error in the ninth call parameter (with "RALRM
(Page 2116)": AINFO (Page 2125))
01 Wrong syntax ID
23 Quantity structure exceeded or target range too small
24 Wrong range ID
32 DB/DI no. out of user range
3A DB/DI no. is NULL for area ID DB/DI or specified DB/DI
does not exist
8A 00 to FF Error in the 10th call parameter
: : :
8F 00 to FF Error in the 15th call parameter
FE, FF 00 to FF Profile-specific error
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2121
Array element STATUS[4]
With DPV1 errors, the DP master passes on STATUS[4] to the CPU and the instruction.
Without DPV1 error, this value is set to 0, with the following exceptions for "RDREC":
STATUS[4] contains the target range length from RECORD, if MLEN > the target range
length from RECORD
STATUS[4]=MLEN, if the actual data record length < MLEN < the target range length from
RECORD
STATUS[4]=0, if STATUS[4]> 255 would have to be set
In PROFINET IO, STATUS[4] has the value "0".
Parameter TINFO
Data structure of the destination area TINFO
Byte Meaning
0 to 19 Start information of the OB in which "RALRM (Page 2116)" was currently called
20 and 21 Address, for exact description, see below
22 to 31 Management information, for exact description, see below
Structure of the address (bytes 20 and 21)
The address contains:
In a central configuration, the rack number (0-31).
Number of the rack
15
0
Bit: 11 12 13 14 10 9 4 0 3 2 1 5 6 7 8
In a distributed configuration with PROFIBUS DP
The DP master system ID (1-31)
The station number (0-127).
DP master system lD Station number
15 14 13 12 11 10 9 8 7 1 2 3 4 5 6 0 Bit:
0
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2122 System Manual, 01/2013,
In a distributed configuration with PROFINET IO:
The last two positions in the PROFINET IO system ID (0-15). To obtain the complete
PROFINET IO system ID, you must add 100 (decimal) to it.
The station number (0-2047).
lO system lD Station number
15 Bit:
0
14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Structure of the management information in bytes 20 to 25
Byte no.
for TINFO
Data type Meaning
20 BYTE central: 0
distributed: PROFIBUS DP: DP master ID: 1 to 31)
PROFINET IO: see above
21 BYTE central: Module rack number (possible values: 0 to 31)
distributed: Number of the DP station (possible values: 0 to 127)
PROFINET IO: see above
22 BYTE central: 0: Data record 0 or data record 1
distributed: Bit 0 to 3: Slave
type
0000:
0001:
0010:
0011:
0100 0111:
1000:
1001 and
higher:
DP (data record 0 structure)
DPS7 (data record 0 or data
record 1 structure)
DPS7 V1 (data record 0 or data
record 1 structure)
DPV1 (structure acc. to
PROFIBUS DP standard)
reserved
PROFINET IO (structure acc. to
PROFINET IO Standard)
reserved
Bit 4 to 7: Profile type Reserved
23 BYTE central: 0
distributed: Bit 0 to 3: Alarm info
type
0000: Transparent, which is always the
case for PROFINET IO
(interrupt originates from a
configured distributed module)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2123
Byte no.
for TINFO
Data type Meaning
0001: Representative
(interrupt originates from a non-
DPV1 slave/non IO device or a slot
that is not configured)
0010: Generated
(interrupt generated in the CPU)
0011 and
higher:
Reserved
Bit 4 to 7: Structure
version
0000:
0001 and
higher:
Initial
Reserved
24 BYTE central: 0
distributed: Flags of the PROFIBUS DP master interface module/PROFINET IO controller
master interface module
Bit 0 = 0: Interrupt originating from an integrated interface
module (PROFINET IO or PROFIBUS DP)
Bit 0 = 1: Interrupt originating from an external interface module
(PROFINET IO or PROFIBUS DP)
Bit 1 to 7: Reserved
25 BYTE central: 0
distributed: Flags of the PROFIBUS DP slave interface module
Bit 0: EXT_DIAG_FLAG from the diagnostics message frame, or 0 if
this bit does not exist in the interrupt
The bit is 1 if the DP slave is faulty.
Bit 1 to 7: Reserved
Flags of the PROFINET IO controller interface module
Bit 0: ARDiagnosisState or 0 if there is no information in the interrupt.
The bit is 1 if the IO device is faulty.
Bit 1 to 7: Reserved
Structure of the management information in bytes 26 to 27 with PROFIBUS and a central configuration
Byte no. for TINFO Data type Meaning
26 and 27 WORD central: 0
WORD distributed: PROFIBUS ID number as unique identifier of the PROFIBUS DP
slave
28 and 29 WORD 0 (Bytes 28 and 29 can be omitted)
30 and 31 WORD 0 (Bytes 30 and 31 can be omitted)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2124 System Manual, 01/2013,
Structure of the management information in bytes 26 to 31 with PROFINET IO
Byte no. for TINFO Data type Meaning
26 and 27 WORD distributed: PROFINET IO device ID number as unique identifier of the
PROFINET IO device
28 and 29 WORD distributed: Manufacturer ID
30 and 31 WORD distributed: ID number of the instance
Parameter AINFO
Data structure of the destination area AINFO with interrupts from PROFIBUS DP or central I/O devices
The information for PROFINET IO is provided below.
Byte Meaning
0 to 3 Header information, for exact description, see below
4 to 199 Additional interrupt information: data for the respective interrupt:
central: ARRAY[0] to ARRAY[195]
distributed: ARRAY[0] to ARRAY[59]
Structure of the header information with interrupts from PROFIBUS DP or central IO devices
Byte Data type Meaning
0 BYTE Length of the received interrupt information in bytes
central:
distributed:
4 to 224
4 to 63
1 BYTE central: Reserved
distributed: ID for the interrupt type
1:
2:
3:
4:
5:
6:
31
Diagnostics interrupt
Process interrupt
Removal interrupt
Insertion interrupt
Status interrupt
Update Interrupt
Failure of an expansion device, DP master system, or DP
station
32 to 126: Manufacturer-specific interrupt
2 BYTE Slot number of the component that triggered the interrupt
3 BYTE central: Reserved
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2125
Byte Data type Meaning
distributed: Specifier
Bits 0 and 1: 0: no further information;
1: Incoming event, faulty slot
2: Outgoing event, slot not faulty anymore
3: Outgoing event, slot still faulty
Bit 2: Add_Ack
Bits 3 to 7: Sequence number
Data structure of the destination area AINFO with interrupts from PROFINET IO
Byte Meaning
0 to 25 Header information, for exact description, see below
26 to 1431 Additional interrupt information: Standardized diagnostics data for the respective interrupt:
ARRAY[0] to ARRAY[1405]
Note: The additional interrupt information may also be omitted.
Structure of the header information with interrupts from PROFINET IO
Byte Data type Meaning
0 and 1 WORD Bits 0 to 7: Block type
Bits 8 to 15: Reserved
2 and 3 WORD Block length
4 and 5 WORD Version:
Bits 0 to 7: low byte
Bits 8 to 15: high byte
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2126 System Manual, 01/2013,
Byte Data type Meaning
6 and 7 WORD ID for interrupt type:
1: Diagnostics interrupt (incoming)
2: Process interrupt
3: Remove module interrupt
4: Insert module interrupt
5: Status interrupt
6: Update interrupt
7: Redundancy interrupt
8: Controlled by supervisor
9: Released by supervisor
10: Configured module not inserted
11: Return of the sub-module
12: Diagnostics interrupt (outgoing)
13: Slave-to-slave connection alarm
14: Neighborhood change alarm
15: Clock synchronization message (bus end)
16: Clock synchronization alarm (device end)
17: Network component alarm
18: Time synchronization alarm (bus end)
19 to 31: Reserved
32 to 127: Manufacturer-specific interrupt
128 to 65535: Reserved
8 to 11 DWORD API (Application Process Identifier)
12 to 13 WORD Slot number of the component triggering the interrupt (range of values 0 to 65535)
14 to 15 WORD Submodule slot number of the component triggering the interrupt (range of values 0 to
65535)
16 to 19 DWORD Module identification; specific information on the source of the interrupt
20 to 23 DWORD Submodule identification; specific information on the source of the interrupt
24 to 25 WORD Interrupt specifier:
Bits 0 to 10: Sequence number (range of values 0 to 2047)
Bit 11: Channel diagnostics:
0: No channel diagnostics available
1: Channel diagnostics information exists
Bit 12: Status of manufacturer-specific diagnostics:
0: No manufacturer-specific status information available
1: Manufacturer-specific status information available
Bit 13: Status of diagnostics for sub-module:
0: No status information available, all errors have been corrected
1: At least one item of channel diagnostics and/or status information is available
Bit 14: Reserved
Bit 15: Application relationship diagnosis state:
0: None of the modules configured within this application relationship reports
diagnostics information
1: At least one of the modules configured in this AR is reporting diagnostics
information
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2127
Structure of additional interrupt information with interrupts from PROFINET IO
The additional interrupt information for PROFINET IO depends on the format identifier. It can
comprise multiple data blocks with the same or different format identifier. The following format
identifiers are available:
W#16#0000 to W#16#7FFF: Manufacturer-specific diagnostics
Byte Data type Meaning
0 to 1 WORD Format identifier for the structure of the following data serving as additional interrupt
information
W#16#0000 to W#16#7FFF: Manufacturer-specific diagnostics
2 to n BYTE See manufacturer's manual.
W#16#8000: Channel diagnostics
Channel diagnostics is output in blocks of 6 bytes each. The additional interrupt information
(without format identifier) is only output for disrupted channels.
Byte Data type Meaning
0 to 1 WORD Format identifier for the structure of the following data serving as additional interrupt
information
W#16#8000: Channel diagnostics
2 to 3 WORD Channel number of the component triggering the interrupt (range of values: 0 to 65535):
W#16#0000 to W#16#7FFF: Channel number of the interface module/sub-module
W#16#8000: The generic substitute for the entire sub-module
W#16#8001 to W#16#FFFF: Reserved
4 BYTE Bits 0 to 2: Reserved
Bits 3 to 4: Type of error:
0: Reserved
1: Incoming error
2: Outgoing error
3: Outgoing error, other errors present
Bits 5 to 7: Type of channel:
0: Reserved
1: Input channel
2: Output channel
3: Input/output channel
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2128 System Manual, 01/2013,
Byte Data type Meaning
5 BYTE Data format:
B#16#00: Free data format
B#16#01: Bit
B#16#02: 2 bits
B#16#03: 4 bits
B#16#04: Byte
B#16#05: Word
B#16#06: Double word
B#16#07: 2 double words
B#16#08 to B#16#FF: Reserved
6 to 7 WORD Type of error:
W#16#0000: Reserved
W#16#0001: Short circuit
W#16#0002: Undervoltage
W#16#0003: Overvoltage
W#16#0004: Overload
W#16#0005: Overtemperature
W#16#0006: Wire break
W#16#0007: High limit exceeded
W#16#0008: Low limit exceeded
W#16#0009: Error
W#16#000A to W#16#000F: Reserved
W#16#0010 to W#16#001F: Manufacturer-specific
W#16#0020 to W#16#00FF: Reserved
W#16#0100 to w#16#7FFF: Manufacturer-specific
W#16#8000: Device diagnostics available
W#16#8001 to W#16#FFFF: Reserved
Not all channels support every error type. For detailed information, refer to the description
of the diagnostics data for the specific device.
Note
The section from "channel number" to "type of error" can occur from 0 to n times.
W#16#8001
W#16#8001: MULTIPLE (different types of diagnostics information are transmitted)
In this case, the additional interrupt information is transmitted as blocks of variable length.
Byte Data type Meaning
0 to 1 WORD Format identifier for the structure of the following data serving as additional interrupt information
W#16#8001: Manufacturer-specific diagnostics and/or channel diagnostics
2 to 3 WORD Block type
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2129
Byte Data type Meaning
4 to 5 WORD Block length
6 BYTE Version: high byte
7 BYTE Version: low byte
8 to 11 DWORD API (only if low byte of version = 1)
12 to 13 WORD Slot number
14 to 15 WORD Subslot number
16 to 17 WORD Channel number
18 to 19 WORD Channel properties
20 to 21 WORD Format identifier:
W#16#0000 to W#16#7FFF: Manufacturer-specific diagnostics
W#16#8000: Channel diagnostics
W#16#8002: Extended channel diagnostics
W#16#8003: Stepped extended channel diagnostics
W#16#8004 to W#16#80FF: Reserved
22 to n BYTE Data depend on the format identifier
Note
The section starting from "block type" can occur from 1 to n times.
W#16#8002
W#16#8002: Extended channel diagnostics
Byte Meaning
0 to 1 Format identifier W#16#8002
2 to 3 Channel number
4 to 5 Channel properties
6 to 7 Error type
8 to 9 Additional error value
10 to 13 Additional error information
W#16#8003
W#16#8003: Stepped extended channel diagnostics
Byte Meaning
0 to 1 Format identifier W#16#8003
2 to 3 Channel number
4 to 5 Channel properties
6 to 7 Error type
8 to 9 Additional error value
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2130 System Manual, 01/2013,
Byte Meaning
10 to 13 Additional error information
14 to 17 Qualified channel qualifier
W#16#8100
W#16#8100: Maintenance information
Byte Meaning
0 to 1 Format identifier W#16#8100
2 to 3 Block type
4 to 5 Block length
6 to 7 Block version
8 to 9 Reserved
10 to 13 Maintenance status
Note
You can find more detailed information about the structure of the additional alarm information
in the Programming Manual SIMATIC PROFINET IO from PROFIBUS DP to PROFINET IO
and the current version of IEC 61158-6-10-1.
Destination area TINFO and AINFO
Destination area TINFO and AINFO
Depending on the respective OB in which "RALRM (Page 2116)" is called, the destination
areas TINFO and AINFO are only partially written. Refer to the table below to find out which
information is entered respectively.
Interrupt type OB TINFO
OB status
information
TINFO
Management
information
AINFO
Header
information
AINFO
Additional interrupt information
Process interrupt 4x Yes Yes Yes central: No
distributed: as supplied by
PROFIBUS DP slave/
PROFINET IO device
Status interrupt 55 Yes Yes Yes Yes Yes
Update interrupt 56 Yes Yes Yes Yes Yes
Manufacturer-specific
interrupt
57 Yes Yes Yes Yes Yes
I/O
redundancy error
70 Yes Yes No No No
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2131
Interrupt type OB TINFO
OB status
information
TINFO
Management
information
AINFO
Header
information
AINFO
Additional interrupt information
Diagnostics interrupt 82 Yes Yes Yes central: Data record 1
distributed: as supplied by
PROFIBUS DP slave/
PROFINET IO device
Insert/remove
interrupt
83 Yes Yes Yes central: No
distributed: as supplied by
PROFIBUS DP slave/
PROFINET IO device
Special form of the
remove module
interrupt:
Controlled by
supervisor
83 Yes Yes Yes PROFINET IO only
Special form of the
insert module interrupt:
Enabled by supervisor
83 Yes Yes Yes PROFINET IO only
Unconfigured module
inserted
83 Yes Yes Yes PROFINET IO only
Rack failure/
station failure
86 Yes Yes No No
... all other OBs Yes No No No
D_ACT_DP: Enable/disable DP slaves
Description
Use the "D_ACT_DP" instruction to specifically deactivate and reactivate configured DP slaves/
PROFINET IO devices. In addition, you can determine whether each assigned DP slave or
PROFINET IO device is currently activated or deactivated.
If you use the instruction to deactivate an IE/PB Link PN IO type of gateway, then all connected
PROFIBUS DP slaves will also cease to function. These failures will be reported.
The instruction cannot be used on PROFIBUS PA field devices that are connected by a DP/
PA link to a DP master system.
Note
As long as one or more "D_ACT_DP" jobs are active, you cannot load a changed configuration
from the programming device to the CPU (within the scope of CiR).
If a changed configuration is being loaded from the programming device to the CPU during
ongoing operation (CiR), the CPU will reject activation of a "D_ACT_DP" job.
Several runs through the cycle control point are required to perform the disabling or enabling
job. Therefore, you cannot wait for the end of such a job in a programmed loop.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2132 System Manual, 01/2013,
Functional description
"D_ACT_DP" works asynchronously, that is, its execution extends over multiple calls. You start
the job by calling D_ACT_DP with REQ = 1.
The output parameters RET_VAL and BUSY indicate the status of the job.
See also: Meaning of the parameters REQ, RET_VAL and BUSY with asynchronous
instructions (Page 1420).
Application
If you configure DP slaves/PROFINET IO devices in a CPU which are not actually present or
not currently required, the CPU will nevertheless continue to access these DP slaves/
PROFINET IO devices at regular intervals. After the slaves are deactivated, further CPU
accessing will stop. With PROFIBUS DP, the fastest possible DP bus cycle can be achieved
in this manner and the corresponding error events no longer occur.
Examples
From a machine OEM's point of view, there are numerous device options possible in series
production of machines. However, each delivered machine includes only one combination of
selected options.
Every one of these possible machine options is configured as a DP slave/PROFINET IO device
by the manufacturer in order to create and maintain a common user program having all possible
options. Use "D_ACT_DP" to deactivate all DP slaves/PROFINET IO devices not present at
machine startup.
A similar situation exists for machine tools having numerous tooling options available but
actually using only a few of them at any given time. These tools are implemented as DP slaves/
PROFINET IO devices. With "D_ACT_DP", the user program activates the tools currently
needed and deactivates those required later.
Identification of a job
If you have started a deactivation or activation job and you call "D_ACT_DP" again before the
job is complete, the behavior of the instruction depends on whether or not the new call involves
the same job: If the input parameter LADDR matches, then the call will be interpreted as a
follow-on call.
Deactivating DP slaves/PROFINET IO devices
When you deactivate a DP slave/PROFINET IO device with "D_ACT_DP", its process outputs
are set to the configured substitute values or to 0 (safe state). The assigned DP master/
PROFINET IO controller does not continue to address this component. Deactivated DP slaves/
PROFINET IO devices are not identified as faulty or missing by the error LEDs on the DP
master/PROFINET IO controller or CPU.
The process image of the inputs of deactivated DP slaves/PROFINET IO devices is updated
with 0, that is, it is handled just as it is for failed DP slaves/PROFINET IO devices.
If you are using your program to directly access the user data of a previously deactivated DP
slave/PROFINET IO device, the I/O access error OB is called, and the corresponding start
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2133
event is entered in the diagnostic buffer. If you attempt to access a deactivated DP slave/
PROFINET IO device via an instruction (such as "RD_REC (Page 2136)"), you will receive the
same error information in RET_VAL as for an unavailable DP slave/PROFINET IO device.
Deactivating a DP slave/PROFINET IO device does not start the program error OB, even if its
inputs or outputs belong to the system-side process image to be updated. Also there is no
entry in the diagnostic buffer.
If a DP station/PNIO station fails after you have deactivated it with "D_ACT_DP", the operating
system does not detect the failure.
Applies to PROFIBUS DP: If you wish to deactivate DP slaves functioning as transmitters in
slave-to-slave communication, we recommend that you first deactivate the receivers (listeners)
that detect which input data the transmitter is transferring to its DP master. Deactivate the
transmitter only after you have performed this step.
Activating DP slaves/PROFINET IO devices
When you reactivate a DP slave/PROFINET IO device with "D_ACT_DP", this component is
configured and assigned parameters by the associated DP master/PROFINET IO controller
(as with the return of a failed DP station/PROFINET IO station). This activation is complete
when the component is able to transfer user data.
Activating a DP slave/PROFINET IO device does not start the program error OB, even if its
inputs or outputs belong to the system-side process image to be updated. Also there is no
entry in the diagnostic buffer.
If you attempt to use "D_ACT_DP" to activate a DP slave that has been deactivated and is
physically separated from the DP bus, the instruction will return the error code W#16#80A2
after approximately one minute and the DP slave will remain deactivated. If the slave is
reconnected to the DP bus at a later time, it must be reactivated with "D_ACT_DP".
If you attempt to activate a PROFINET IO device that is physically separated from the
PROFINET bus, "D_ACT_DP" will remain active. There is no automatic cancellation after a
specific period as with DP slaves. You need to manually cancel the running job.
The instruction also allows the activation of a non-accessible DP slave or a PROFINET IO
device or module. If it is still not accessible after activation by "D_ACT_DP", there is no further
deactivation and the instruction is terminated with the error code 80A7. If the DP slave /
PROFINET IO device is again accessible afterwards or if a module is not inserted until
afterwards, it results in standard system behavior (for example, a call of the OB configured for
this purpose).
Note
Activating a DP slave/PROFINET IO device may be time-consuming. If you wish to cancel a
current activation job, start "D_ACT_DP" again with the same value for LADDR and
MODE = 2. Repeat the call of "D_ACT_DP" with MODE = 2 until successful cancellation of
the activation job is indicated by RET_VAL = 0.
If you wish to activate DP slaves which take part in the slave-to-slave communication, we
recommend that you first activate the transmitters and then the receivers (listeners).
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2134 System Manual, 01/2013,
Parameter
The following table shows the parameters of the instruction "D_ACT_DP":
Parameter Declaration Data type Memory area Description
REQ Input BOOL I, Q, M, D, L Level-triggered control parameter
REQ=1:
Execute activation or deactivation
MODE Input USINT I, Q, M, D, L or
constant
Job identifier
Possible values:
0: Request information on whether the
addressed component is activated or
deactivated (output via RET_VAL
parameter)
1: Activate the DP slave/PROFINET IO
device
2: Deactivate the DP slave/PROFINET IO
device
LADDR Input HW_ANY I, Q, M, D, L or
constant
Address of the DP slave / PROFINET IO device
To address, use the hardware ID of the DP
slave / PROFINET IO device.
RET_VAL Return INT I, Q, M, D, L If an error occurs while the instruction is
being executed, the return value contains an
error code.
BUSY Output BOOL I, Q, M, D, L Active code:
BUSY=1: The job is still active.
BUSY=0: The job was terminated.
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
RET_VAL parameter
Error code*
(W#16#...)
Explanation
0000 Job was executed without errors.
0001 The DP slave/PROFINET IO device is active (this error code is possible only with MODE = 0.)
0002 The DP slave/PROFINET IO device is deactivated (this error code is possible only with MODE = 0.)
7000 First call with REQ=0. The job specified with LADDR is not active; BUSY has the value "0".
7001 First call with REQ=1. The job specified with LADDR was initiated. BUSY has the value "1".
7002 Intermediate call (REQ irrelevant). The activated job is still active; BUSY has the value "1".
8090 You have not configured a module with the address specified in LADDR.
You operate your CPU as I-Slave and you have specified in LADDR an address of this I-Slave.
8092 The deactivation of the currently addressed DP slave/PROFINET IO device (MODE=2) cannot be
canceled by being activated (MODE=1). Activate the component at a later time.
8093 No DP slave / PROFINET IO device that can be activated or deactivated is assigned to the address
specified in LADDR.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2135
Error code*
(W#16#...)
Explanation
8094 You have attempted to activate a device which is potential partner for a tool change port. However, another
device is already activated on this tool change port at this time. The activated device will remain activated.
80A0 Error during the communication between the CPU and the IO controller.
80A1 Parameters could not be assigned for the addressed component. (This error code is only available when
MODE = 1.)
Note: "D_ACT_DP" returns this error information only if the activated slaves/devices of this component
fails again during parameter assignment. If the parameter assignment of a single module was
unsuccessful, "D_ACT_DP" returns the error information W#16#0000.
80A2 The addressed DP slave does not return an acknowledgment. (This error information is not available with
PROFINET IO devices. The process is not time-monitored by PROFINET.)
80A3 The DP master/PROFINET IO controller concerned does not support this function.
80A4 The CPU does not support this function for external DP masters/PROFINET IO controller.
80A6 Slot error in the DP slave/PROFINET IO device; not all user data can be accessed (this error code is only
available when MODE=1).
Note: "D_ACT_DP" returns this error information only if the activated component fails again after
parameter assignment and before the end of "D_ACT_DP". If only a single module is unavailable,
"D_ACT_DP" returns the error information W#16#0000.
80A7 Activation of a non-accessible device or module.
80AA Activation with errors in the DP slave/PROFINET IO device: Differences in the configuration
80AB Activation with errors in the DP slave/PROFINET IO device: Parameter assignment error
80AC Activation with errors in the DP slave/PROFINET IO device: Maintenance required
80C1 "D_ACT_DP" has been started and is being continued with another address (this error code is possible
when MODE=1 and MODE=2).
80C3 Temporary resource error: The CPU is currently processing the maximum possible activation and
deactivation jobs. (This error code is available only when MODE = 1 and MODE = 2.)
The CPU is busy receiving a modified configuration. Currently you can not enable/disable DP slaves/
PROFINET IO devices.
80C5 DP: Jobs not collected by the user are discarded at restart.
80C6 PROFINET: Jobs not collected by the user are discarded at restart.
8xyy General error information
See also: Evaluating errors with output parameter RET_VAL (Page 1422)
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
Others
RD_REC: Read data record from I/O
Description
Use the instruction to read the data record with the number RECNUM from the addressed
module. You start the read process by assigning the value "1" to the input parameter REQ
during the call. If the read process could be executed immediately, the instruction returns the
value "0" at the output parameter BUSY . If BUSY has the value "1", reading is not yet complete.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2136 System Manual, 01/2013,
See also: Meaning of the parameters REQ, RET_VAL and BUSY with asynchronous
instructions (Page 1420). The data record read is entered in the target range spanned by the
RECORD parameter, providing the data transfer was free of errors.
Note
When you read out a data record with a number greater than one from an FM or a CP you
have purchased prior to February 1997 (below referred to as "old modules"), "RD_REC"
responds differently than it does in new modules. This special situation is covered in the
section "Using old S7-300 FMs and CPs with data record numbers >1" (see below).
If a DPV1 slave is configured via GSD file (GSD rev. 3 and higher) and the DP interface of
the DP master is set to "S7 compatible", then you may not read any data records from the I/
O modules in the user program with "RD_REC". In this case, the DP master addresses the
wrong slot (configured slot + 3).
Remedy: Set the interface of the DP master to "DPV1".
Parameter
The following table shows the parameters of the instruction "RD_REC":
Parameter Declaration Data type Memory area Description
REQ Input BOOL I, Q, M, D, L or
constant
REQ = 1: Read request
LADDR Input HW_IO
(WORD)
I, Q, M, D, L or
constant
Hardware identifier of the module.
RECNUM Input BYTE I, Q, M, D, L or
constant
Data record number (permitted values: 0 to 240)
RET_VAL Return INT I, Q, M, D, L If an error occurs while the instruction is
being executed, the return value contains an
error code. In addition: the length of the data
record actually transferred in bytes (possible
values: +1 to +240), if the target range is greater
than the transferred data record and if no error
occurred during the transfer.
BUSY Output BOOL I, Q, M, D, L BUSY = 1: The reading process is not yet
complete.
RECORD Output ANY I, Q, M, D, L Target range for the data record read. With
asynchronous execution of "RD_REC",
make sure that the actual parameters of
RECORD have the same length information
for all calls. Only the BYTE data type is permitted.
Note: Note that for S7-300 CPUs the parameter
RECORD always requires the full specification
of the DB parameters (for example,
P#DB13.DBX0.0 byte 100). The omission of an
explicit DB number is only permitted for S7-300
CPUs and leads to an error message in the user
program.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2137
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
Parameter RECORD
Note
If you want to ensure that the entire data record is always read, select a target range with a
length of 241 bytes. If the data transfer is error-free, RET_VAL contains the actual data record
length.
Using old S7-300 FMs and CPs with data record numbers > 1
If you want to use the instruction "RD_REC" to read out a data record with a number greater
than one from an old S7-300 FM or old S7-300 CP, remember the following points:
If the target range is greater than the actual length of the required data record, no data is
entered in RECORD . RET_VAL is written with W#16#80B1.
If the target range is smaller than the actual length of the required data record, the CPU
reads as many bytes beginning at the start of the record as are specified in the length
information of RECORD and enters this number of bytes inRECORD . RET_VAL has the
value "0".
If the length specified in RECORD is the same as the actual length of the required data
record, the CPU reads the data record and enters it in RECORD . RET_VAL is written with
"0".
RET_VAL parameter
If an error has occurred while the function was being executed, the return value contains
an error code.
If no error occurred during the transfer, RET_VAL contains the following:
0, if the entire target range was filled with data from the selected data record (the data
record can also be incomplete).
The length of the data record actually transferred in bytes (possible values: +1 to +240)
if the target range is greater than the transferred data record.
Note
If the general error W#16#8745 occurs, this only indicates that access to at least one
byte of the process image was blocked. The data record was read by the module
correctly and written to the I/O memory area.
When looking at the "real" error information (error codes W#16#8xyz) in the following table,
we distinguish between two cases:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2138 System Manual, 01/2013,
Temporary errors (error codes W#16#80A2 to 80A3, 80Cx):
This type of error can possibly be eliminated without user action, meaning it is helpful to
call the instruction again (multiple calls, if necessary).
Example of a temporary error: Resources required are currently in use (W#16#80C3).
Permanent errors (error codes W#16#809x, 80A0, 80A1, 80Bx):
This type of error does not correct itself. A new call of the instruction will not be successful
until you have eliminated the error. Example of a permanent error: Wrong length
specification in RECORD (W#16#80B1).
Note
If you transfer data records to a DPV1 slave with "WR_REC (Page 2141)" or if you read
data records from a DPV1 slave with RD_REC and if this DPV1 slave operates in DPV1
mode, the DP master evaluates the error information it received from the slave as follows:
If the error information lies within the range from W#16#8000 to W#16#80FF or
W#16#F000 to W#16#FFFF, the DP master passes the error information to the instruction.
If the error information is outside this range, the DP master passes the value W#16#80A2
to the instruction and suspends the slave.
For a description of the error information originating from DPV1 slaves, refer to STATUS[3]
Parameter STATUS (Page 2118).
Parameter RET_VAL for WR_REC and RD_REC
Error code*
(W#16#...)
Explanation Restriction
0000 No error -
7000 First call with REQ=0: No data transfer active; BUSY has the value
0.
-
7001 First call with REQ=1: Data transfer started; BUSY has the value 1. Distributed I/O
7002 Intermediate call (REQ
irrelevant): Data transfer already active; BUSY has the value 1.
Distributed I/O
8090 Specified logical base address invalid: There is no
assignment in SDB1/SDB2x or there is no base address.
-
8092 A type other than BYTE is specified in the ANY reference. -
8093 This instruction is not permitted for the module selected by means of
LADDR and IOID . (permitted are S7-300 modules for an S7-300,
S7-400 modules for an
S7-400, S7-DP modules for an S7-300 and S7-400).
-
80A0 Negative acknowledgement when reading from the module: Module
was removed during the reading process or is defective
With "RD_REC" only
80A1 Negative acknowledgement when writing to the module: Module was
removed during the writing process or is
defective
With "WR_REC (Page 2141)" only
80A2 DP protocol error at layer 2 (for example, slave failure or bus
problems)
For ET200S, data record cannot be read in DPV0 mode.
Distributed I/O
80A3 DP protocol error with user interface/user Distributed I/O
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2139
Error code*
(W#16#...)
Explanation Restriction
80B0 Instruction not possible for module type.
The module does not recognize the data record.
Data record number 241 not permitted.
With "WR_REC (Page 2141)", data records 0 and 1 are not
permitted.
-
80B1 The length specified in parameter RECORD is incorrect. With "WR_REC (Page 2141)":
Length incorrect
With "RD_REC"
(only when using old
S7-300 FMs and S7-300
CPs): specified length > data
record length
With DPNRM_DG: specified
length < data record length
80B2 The configured slot is
not assigned.
-
80B3 Actual module type does not match the specified module
type in SDB1.
-
80B7 DP slave or module reports an invalid range for a parameter or value. With "RD_REC" only
80C0 With "WR_REC (Page 2141)": the data can only be written when the
CPU is in STOP mode. Note: this means that writing by the user
program is not possible. You can only write the data online with PG/
PC.
With "RD_REC": the module routes the data record, but either no data
is present or the data can only be read when the CPU is in STOP
mode. Note: if data can only be read when the CPU is in STOP mode,
then an evaluation by the user program is not possible. In this case,
you can only read the data online with PG/PC.
With "DPNRM_DG (Page 2156)": There are no diagnostics data
available.
With "WR_REC (Page 2141)" or
"RD_REC" or "DPNRM_DG
(Page 2156)"
80C1 The data of the previous write job on the module for the same data
record have not yet been processed by the module.
-
80C2 The module is currently processing the maximum possible
number of jobs for a CPU.
-
80C3 The required resources (memory, etc.) are currently
occupied.
-
80C4 Internal temporary error. Job could not be executed.
Repeat the job. If this error occurs often, check your installation for
sources of electrical interference.
-
80C5 Distributed I/O not available. Distributed I/O
80C6 Data record transfer stopped due to priority class abort (restart or
background)
Distributed I/O
8xyy General error information
See also: Evaluating errors with output parameter RET_VAL
(Page 1422)
-
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2140 System Manual, 01/2013,
WR_REC: Write data record to I/O
Description
Use the instruction "WR_REC" to transfer the data record RECORD to the addressed module.
You start the writing process by assigning the value "1" to the input parameter REQ during the
call. If the writing process could be executed immediately, the instruction returns the value "0"
at the output parameter BUSY. If BUSY has the value "1", writing is not yet complete.
Note
If a DPV1 slave is configured via GSD file (GSD rev. 3 and higher) and the DP interface of
the DP master is set to "S7 compatible", then you may not write any data records from the I/
O modules to the user program with "WR_REC". In this case, the DP master addresses the
wrong slot (configured slot + 3).
Remedy: set the interface of the DP master to "DPV1".
Parameters
The following table shows the parameters of the instruction "WR_REC":
Parameter Declaration Data type Memory area Description
REQ Input BOOL I, Q, M, D, L or
constant
REQ = 1: Write request
LADDR Input HW_IO
(WORD)
I, Q, M, D, L or
constant
Hardware identifier of the module.
RECNUM Input BYTE I, Q, M, D, L or
constant
Data record number (permitted values: 2 to 240)
RECORD Input ANY I, Q, M, D, L Data record. Only the BYTE data type is
permitted.
Note: Note that for S7-300 CPUs the parameter
RECORD always requires the full specification
of the DB parameters (for example,
P#DB13.DBX0.0 byte 100). The omission of an
explicit DB number is only permitted for S7-300
CPUs and leads to an error message in the user
program.
RET_VAL Output Return I, Q, M, D, L If an error occurs while the instruction is
being executed, the return value contains an
error code.
BUSY Output BOOL I, Q, M, D, L BUSY= 1: The writing process is not yet
complete.
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2141
Parameter RECORD
The data to be transferred are read from the RECORD parameter during the first call. If the
transfer of the data record takes longer than the duration of one call, the contents of the
RECORD parameter are no longer relevant for the subsequent instruction calls (for the same
job).
RET_VAL parameter
See also: RD_REC: Read data record from I/O (Page 2136)
Note
If the general error W#16#8544 occurs, it only indicates that access to at least one byte of
the I/O memory area containing the data record was denied. The data transfer was continued.
DPRD_DAT: Read consistent data of a DP standard slave
Description
You use the "DPRD_DAT" instruction to read out consistent data of a DP standard slave/
PROFINET IO device.
You require "DPRD_DAT" because you can only read out a maximum of four continuous bytes
using the load commands that access the I/O or the process image input table. If required, you
can also read consistent data via the process image of the inputs. Refer to the related
documentation to find out if your CPU supports this functionality. For additional information on
consistent data of a DP standard slave/PROFINET IO device, refer to Section "Data
consistency (Page 2408)".
If necessary, the instruction "DPRD_DAT" can also be used for a data area of 1 byte or larger.
For information on the maximum length of the data, refer to the documentation of your CPU
(e.g. 64 bytes for an S7-1214).
Use the LADDR parameter to select the DP standard slave / PROFINET IO device. If an
access error occurs, the error code W#16#8090 is output.
Use the RECORD parameter to define the target range of the read data:
The target range has to be at least as long as the inputs of the selected module. Only
the inputs are transferred, the other bytes are not considered. If you read from a DP
standard slave with a modular configuration or with several DP identifiers, you can only
access the data of a module of the configured hardware ID per "DPRD_DAT" call. If you
select a target range that is too small, the error code 80B1 is output at the RET_VAL
parameter.
All bit strings and all integers can be used as data type. It is also possible to use these
data types in a data structure of the ARRAY type . The data type STRING is not
supported.
If there was no error during the data transmission, the data that have been read are entered
in the target range defined at the RECORD parameter.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2142 System Manual, 01/2013,
Parameters
The following table shows the parameters of the instruction "DPRD_DAT":
Parameter Declaration Data type Memory area Description
LADDR Input HW_IO I, Q, M, L or
constant
Hardware ID of the DP standard slave /
PROFINET IO device from which it is to be read.
RET_VAL Return DINT, INT,
LREAL, REAL
I, Q, M, D, L If an error occurs while the instruction is
being executed, the return value contains an
error code.
RECORD Output VARIANT I, Q, M, D, L Destination area for the user data that were read.
For additional information on valid data types, refer to "Overview of the valid data types
(Page 899)".
RET_VAL parameter
Error code*
(W#16#...)
Explanation
0000 No error occurred.
8090 You have not configured a module for the specified hardware identifier or
You have ignored the restriction concerning the length of consistent data, or
you have not specified a hardware identifier as an address at parameter LADDR .
8092 A data type other than (Array of) bit string or integer was specified at the RECORD parameter.
8093 No DP module/PROFINET IO device from which you can read consistent data exists for the hardware
identifier specified in LADDR . This error code also occurs if the module addressed by means of LADDR
does not have inputs.
80A0 An access error was detected when accessing the I/O.
80B1 The length of the specified target range at parameter RECORD is shorter than the configured user data
length.
80C0 The data have not been read yet.
8xyy General error information
See also: Evaluating errors with output parameter RET_VAL (Page 1422)
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
See also
Parameter STATUS (Page 2118)
DPWR_DAT: Write consistent data of a DP standard slave
Description
You use the "DPWR_DAT" instruction to consistently transfer the data at the RECORD
parameter to the addressed DP standard slave / PROFINET IO device, and, if applicable, to
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2143
the process image (if you have configured the relevant address area of the DP standard slave
as a consistent range in a process image).
You require "DPWR_DAT" because you can only write a maximum of four continuous bytes
using the transfer commands that access the I/O or process image output. If required, you can
also write consistent data via the process image outputs. Refer to the related documentation
to find out if your CPU supports this functionality. Do not use both possibilities concurrently
when writing consistent data: Either use "DPWR_DAT" or write via the process image output
table. For additional information on consistent data of a DP standard slave/PROFINET IO
device, refer to Section "Data consistency (Page 2408)". If the DP standard slave has a
modular design, you can only access one module of the DP slave.
CAUTION
I/O access
When using "DPWR_DAT", avoid accessing I/O areas that have process image partitions
with OB6x connections (isochronous mode interrupts) assigned to them.
If necessary, the instruction "DPRD_DAT" can also be used for a data area of 1 byte or larger.
For information on the maximum length of the data, refer to the documentation of your CPU
(e.g. 64 bytes for an S7-1214).
Use the LADDR parameter to select the DP standard slave / PROFINET IO device. If an
access error occurs on the addressed module, the error code 8090 is output.
Use the RECORD parameter to define the source range of the data to be written:
The source range has to be at least as long as the outputs of the selected module. Only
the outputs are transferred, the other bytes are not considered. If the source range at
parameter RECORD is longer than the outputs of the configured module, only the data
up to the maximum length of the outputs is transferred. If the source range at parameter
RECORD is shorter than the outputs of the configured module, the error code 80B1 is
output.
All bit strings and all integers can be used as data type. It is also possible to use these
data types in a data structure of the ARRAY type . The data type STRING is not
supported.
The data is transferred synchronously, that is, the write process is completed when the
instruction is completed.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2144 System Manual, 01/2013,
Parameters
The following table shows the parameters of the instruction "DPWR_DAT":
Parameter Declaration Data type Memory area Description
LADDR Input HW_IO I, Q, M, L or constant Hardware ID of the DP standard slave /
PROFINET IO device to those PIQ range it is
to be written.
RECORD Input VARIANT I, Q, M, D, L Source area for the user data to be
written.
RET_VAL Return DINT, INT,
LREAL, REAL
I, Q, M, D, L If an error occurs while the instruction is
being executed, the return value contains an
error code.
For additional information on valid data types, refer to "Overview of the valid data types
(Page 899)".
RET_VAL parameter
Error code*
(W#16#...)
Explanation
0000 No error occurred.
8090 You have not configured a module for the specified hardware identifier or
You have ignored the restriction concerning the length of consistent data, or
you have not specified a hardware identifier at parameter LADDR .
8092 A data type other than (Array of) bit string or integer was specified at the RECORD parameter.
8093 No DP module /PROFINET IO device to which you can write consistent data exists at the HW ID specified
in LADDR . This error code also occurs if the DP standard slave / PROFINET IO device addressed via
LADDR does not have outputs.
80A1 Access error detected while I/O devices were being accessed.
80B1 The length of the specified source range at the RECORD parameter is shorter than the outputs of the
configured DP standard slave / PROFINET IO device.
80C1 The data of the previous write job have not yet been processed by the DP standard slave / PROFINET IO
device.
8xyy General error information
See also: Evaluating errors with output parameter RET_VAL (Page 1422)
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
See also
Parameter STATUS (Page 2118)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2145
iDevice / iSlave
RCVREC: Receive data record
Description
An I-device can receive a data record from a superordinate controller. The receipt takes place
in the user program with the instruction "RCVREC" (receive record).
The instruction has the following operating modes:
Check whether the I-device has a request for a data record receipt.
Make the data record available to the output parameters.
Send an answer to the superordinate controller.
You can determine the operating mode executed by the instruction using the input parameter
MODE (see below).
The I-device must be in the RUN or STARTUP mode.
With MLEN, you specify the maximum number of bytes you want to receive. The selected
length of the target range RECORD should have at least the length of MLEN bytes.
If a data record was received (MODE=1 or MODE=2), the output parameter NEW will indicate
that the data record was stored in RECORD. Note that RECORD has a sufficient length. The
output parameter LEN contains the actual length of the data record received in bytes.
Set CODE1 and CODE2 to zero for the positive answer to the superordinate controller. If the
received data record is to be rejected, enter the negative answer to the superordinate controller
in Error Code 1 of the CODE1 and in Error Code 2 of the CODE2.
Note
If the I-device has received a request for a data record receipt, you must recognize the delivery
of this request within a certain duration. After recognition, you must send an answer to the
superordinate controller within this time period. Otherwise the I-device will experience a
timeout error which causes the operating system of the I-device to send a negative answer
to the superordinate controller. For information on the value for the time period, please refer
to the specifications of your CPU.
The output parameter STATUS receives the error information after the occurrence of an error.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2146 System Manual, 01/2013,
Operating modes
You can determine the operating mode of the instruction "RCVREC" with the input parameter
MODE. This step will be explained in the following table.
MODE Meaning
0 Check whether a request for a data record receipt exists
If a data record from a superordinate controller exists on the I-device, the instruction will only write the output
parameters NEW, SLOT, INDEX and LEN. If you call the instruction several times with MODE=0, then the output
parameter will only refer to one and the same request.
1 Receiving a data record for any subslot of the I-device
If a data record from a superordinate controller exists on the I-device for any subslot of the I-device, the instruction
will write the output parameter and transfer the data record to the parameter RECORD.
2 Receiving a data record for a specific subslot of the I-device
If a data record from a superordinate controller exists on the I-device for a specific subslot of the I-device, the
instruction will write the output parameter and transfer the data record to the parameter RECORD.
3 Sending a positive answer to the superordinate controller
The instruction checks the request of the superordinate controller to receive a data record, accepts the existing
data record and sends a positive acknowledgement to the superordinate controller.
4 Sending a negative answer to the superordinate controller
The instruction checks the request of the superordinate controller to receive a data record, rejects the existing
data record and sends a negative acknowledgement to the superordinate controller. Enter the reason for the
rejection in the input parameters CODE1 and CODE2.
Note
After the receipt of a data record (NEW=1) you must call "RCVREC" twice to ensure complete
processing. You must do this in the following order:
First call with MODE=1 or MODE=2
Second call with MODE=3 or MODE=4
Parameter
The following table shows the parameters of the instruction "RCVREC":
Parameters Declaration Data type Memory area Description
MODE Input INT I, Q, M, D, L or
constant
Mode
F_ID Input HW_SUBMO
DULE
(DWORD)
I, Q, M, D, L or
constant
Subslot in the transfer area of the I-device for
the data record to be received (only relevant
for MODE=2). The high word is always set to
zero.
MLEN Input INT I, Q, M, D, L or
constant
Maximum length of the data record to be
received in bytes
CODE1 Input BYTE I, Q, M, D, L or
constant
Zero (for MODE=3) and/or Error Code 1 (for
MODE=4)
CODE2 Input BYTE I, Q, M, D, L or
constant
Zero (for MODE=3) and/or Error Code 2
(forMODE=4)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2147
Parameters Declaration Data type Memory area Description
NEW Output BOOL I, Q, M, D, L MODE=0: New data record was received
MODE=1 or 2: Data record was transferred
to RECORD
STATUS Output DWORD I, Q, M, D, L Error information
SLOT Output HW_SUBMO
DULE
I, Q, M, D, L Identical to F_ID
SUBSLOT Output HW_SUBMO
DULE
I, Q, M, D, L Identical to F_ID
INDEX Output UINT I, Q, M, D, L Number of the data record received
LEN Output UINT I, Q, M, D, L Length of the data record received
RECORD InOut VARIANT I, Q, M, D, L Target range for the data record received.
Note: Note that for S7-300 CPUs the
parameter RECORD always requires the full
specification of the DB parameters (for
example, P#DB13.DBX0.0 Byte 100). The
omission of an explicit DB number is not
permitted for S7-300 CPUs and results in an
error message in the user program.
For additional information on valid data types, refer to "Overview of the valid data types
(Page 899)".
STATUS parameter
For interpretation of the parameter STATUS refer to section: Parameter STATUS
(Page 2118)
PRVREC: Make data record available
Description
An I-device can receive a request from a superordinate controller to make a data record
available. The I-device makes the data record available in the user program with the instruction
"PRVREC" (provide record).
The instruction has the following operating modes:
Check whether the I-device has a request for making a data record available.
Transfer the requested data record to the superordinate controller.
Sending an answer to the superordinate controller.
You can determine the operating mode executed by the instruction using the input parameter
MODE (see below).
The I-device must be in the RUN or STARTUP mode.
Enter the maximum number of bytes the data record to be sent should have with LEN. The
selected length of the target range RECORD should have at least the length of LEN bytes.
If a request to make a data record available exists, (MODE=0), the output parameter NEW will
be set to TRUE.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2148 System Manual, 01/2013,
If the request for making a data record available is accepted, write RECORD for the positive
answer to the superordinate controller with the requested data record and write zero for CODE1
and CODE2. If the request for making a data record available is to be rejected, enter the
negative answer to the superordinate controller in Error Code 1 of the CODE1 and in Error
Code 2 of theCODE2.
Note
If the I-device has received a request for making a data record available, you must recognize
the delivery of this request within a certain time period. After recognition, you must send an
answer to the superordinate controller within this time period. Otherwise the I-device will
experience a timeout error which causes the operating system of the I-device to send a
negative answer to the superordinate controller. For information on the value for the time
period, please refer to the specifications of your CPU.
The output parameter STATUS receives the error information after the occurrence of an error.
Operating modes
You can determine the operating mode of the instruction "PRVREC" with the input parameter
MODE. This step will be explained in the following table.
MODE Meaning
0 Check whether a request for making a data record available exists
If a request from a superordinate controller for making a data record available exists on the I-device, the instruction
will only write the output parameters NEW, SLOT, INDEX and RLEN. If you call the instruction several times with
MODE=0, then the output parameter will only refer to one and the same request.
1 Receiving a request for making a data record available for any subslot of the I-device
If such a request from a superordinate controller for any subslot of the I-device exists on the I-device, the
instruction will write the output parameter.
2 Receiving a request for making a data record available for a specific subslot of the I-device
If such a request from a superordinate controller for a specific subslot of the I-device exists on the I-device, the
instruction will write the output parameter.
3 Make the data record available and send a positive answer to the superordinate controller
The instruction checks the request of the superordinate controller to make a data record available, makes the
request data record available to RECORD and sends a positive acknowledgement to the superordinate controller.
4 Sending a negative answer to the superordinate controller
The instruction checks the request of the superordinate controller to make a data record available, rejects this
request and sends a negative acknowledgement to the superordinate controller. Enter the reason for the rejection
in the input parameters CODE1 and CODE2.
Note
After the receipt of a request (NEW=1) you must call the instruction twice to ensure complete
processing. You must do this in the following order:
First call with MODE=1 or MODE=2
Second call with MODE=3 or MODE=4
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2149
Parameter
The following table shows the parameters of the instruction "PRVREC":
Parameter Declaration Data type Memory area Description
MODE Input INT I, Q, M, D, L or
constant
Mode
F_ID Input HW_SUBMO
DULE
(DWORD)
I, Q, M, D, L or
constant
Subslot in the transfer area of the I-device for the
data record to be sent (only relevant for
MODE=2). The high word is always set to zero.
CODE1 Input BYTE I, Q, M, D, L or
constant
Zero (for MODE=3) and/or Error Code 1
(forMODE=4)
CODE2 Input BYTE I, Q, M, D, L or
constant
Zero (for MODE=3) and/or Error Code 2
(forMODE=4)
LEN Input UINT I, Q, M, D, L or
constant
Maximum length of the data record to be sent in
bytes
NEW Output BOOL I, Q, M, D, L The new data record was requested by the
superordinate controller.
STATUS Output DWORD I, Q, M, D, L Error information
SLOT Output HW_SUBMO
DULE
I, Q, M, D, L Identical to F_ID
SUBSLOT Output HW_SUBMO
DULE
I, Q, M, D, L Identical to F_ID
INDEX Output UINT I, Q, M, D, L Number of the data record to be sent
RLEN Output UINT I, Q, M, D, L Length of the data record to be sent
RECORD InOut VARIANT I, Q, M, D, L Data record made available
Note: Note that for S7-300 CPUs the parameter
RECORD always requires the full specification of
the DB parameters (for example,
P#DB13.DBX0.0 Byte 100). The omission of an
explicit DB number is not permitted for S7-300
CPUs and results in an error message in the user
program.
For additional information on valid data types, refer to "Overview of the valid data types
(Page 899)".
STATUS parameter
For interpretation of the parameter STATUS refer to section: Parameter STATUS
(Page 2118)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2150 System Manual, 01/2013,
PROFIBUS
DPSYC_FR: Synchronize DP slaves / Freeze inputs
Description
You use the instruction to synchronize one or more groups of DP slaves.
The function involves sending one of the control commands below, or a combination of them,
to the relevant groups:
SYNC (simultaneous output and freezing of output states on the DP slaves)
UNSYNC (cancels the SYNC control command)
FREEZE (freeze the input states on the DP slaves and read in the frozen inputs)
UNFREEZE (cancels the FREEZE control command)
Before you send the control commands listed above, you must assign the DP slaves to groups
per configuration. You must know which DP slave is assigned to which group, with which
number, and know the reactions of the various groups to SYNC/FREEZE.
Note
Note that the control commands SYNC and FREEZE also remain valid when you perform a
warm/cold restart.
Please note also that you may initiate only one SYNC/UNSYNC job or only one FREEZE/
UNFREEZE job at a time.
Functional description
"DPSYC_FR" works asynchronously, that is, its execution extends over multiple calls. You
start the job by calling "DPSYC_FR" with REQ=1.
The output parameters RET_VAL and BUSY indicate the status of the job.
See also: Meaning of the parameters REQ, RET_VAL and BUSY with asynchronous
instructions (Page 1420).
Identification of a job
If you have triggered a SYNC/FREEZE job and called "DPSYC_FR" again before the first job
was completed, the response of the instruction depends on whether the new call is for the
same job. If the input parameters LADDR, GROUP and MODE match, the call is interpreted
as a follow-on call.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2151
Writing outputs of DP modules
The writing of outputs of DP modules is triggered as follows:
By transfer commands to the DP I/O
By writing the process image output table to the modules (by the operating system at the
end of OB 1 or by calling the instruction "UPDAT_PO")
Calling the "DPWR_DAT (Page 2143)" instruction.
In normal operation, the DP master transfers the output bytes cyclically (within the cycle of the
PROFIBUS DP bus) to the outputs of the DP slaves.
If you want to have certain output data (possibly distributed on several slaves) applied to the
outputs to the process at exactly the same time, you can send the SYNC control command to
the relevant DP master using the "DPSYC_FR" instruction.
What are the effects of SYNC?
With the SYNC control command, the DP slaves of the selected groups are switched to Sync
mode. In other words, the DP master transfers the current output data and instructs the DP
slaves involved to freeze their outputs. With the following output message frames, the DP
slaves enter the output data in an internal buffer and the state of the outputs remains
unchanged.
Following each SYNC control command, the DP slaves of the selected groups apply the output
data of their internal buffer to the outputs on the process.
The outputs are only updated cyclically again when you send the UNSYNC control command
using the "DPSYC_FR" instruction.
Note
If the DP slaves of the selected group(s) are not currently connected to the network or have
failed when the control command was sent, they will not be switched to SYNC mode. This
information will not be communicated in the return value of the instruction.
Reading input data of DP modules
The input data of the DP modules are read as follows:
Using load commands to the DP I/O
When the process image input table is updated (by the operating system at the start of OB
1 or by calling the "UPDAT_PI" instruction)
By calling the "DPRD_DAT (Page 2142)" instruction.
In normal operation, the DP master receives this input data cyclically (within the cycle of the
PROFIBUS DP bus) from its DP slaves and makes them available to the CPU.
If you want to have certain input data (possibly distributed on several slaves) to be read from
the process at exactly the same time, send the FREEZE control command to the relevant DP
master using the "DPSYC_FR" instruction.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2152 System Manual, 01/2013,
What are the effects of FREEZE?
With the FREEZE control command, the DP slaves involved are switched to Freeze mode, in
other words the DP master instructs the DP slaves to freeze the current state of the inputs. It
then transfers the frozen data to the input area of the CPU.
Following each FREEZE control command, the DP slaves freeze the state of their inputs again.
The DP master only receives the current state of the inputs cyclically again after you have sent
the UNFREEZE control command with the "DPSYC_FR" instruction.
Note
If the DP slaves of the selected group(s) are not currently connected to the network or have
failed when the control command has been sent, they will not be switched to FREEZE mode.
This information will not be communicated in the return value of the instruction.
Data consistency
Because the DPSYC_FR functions are asynchronous and can be interrupted by higher priority
classes, you should make sure that the process images are consistent with the actual inputs
and outputs of the I/O when using the "DPSYC_FR" instruction.
This is guaranteed if you comply with the following consistency rules:
Define suitable process image partitions for the "SYNC outputs" and the "FREEZE inputs"
(only possible on the S7-400). Call the "UPDAT_PO" instruction immediately before each
first call of a SYNC job. Call the "UPDAT_PI" instruction immediately after the respective
last call of a FREEZE job.
As an alternative: Use only direct I/O access for outputs involved in a SYNC job and for
inputs involved in a FREEZE job. Do not write to these outputs when a SYNC job is active,
and do not read in these inputs when a FREEZE job is active.
Use of DPWR_DAT and DPRD_DAT
If you use the "DPWR_DAT (Page 2143)" instruction, it must be complete before you send a
SYNC job for the outputs involved.
If you use the "DPRD_DAT (Page 2142)" instruction, it must be complete before you send a
FREEZE job for the inputs involved.
Startup and "DPSYC_FR"
The user alone must take responsibility for sending the SYNC and FREEZE control commands
in the startup OBs.
If you want the outputs of one or more groups to be in SYNC mode when the user program
starts, you must initialize these outputs during startup and completely execute the
"DPSYC_FR" instruction with the SYNC control command.
If you want the inputs of one or more groups to be in FREEZE mode when the user program
starts, you must execute the "DPSYC_FR" instruction with the FREEZE control command
completely for these inputs during startup.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2153
Parameter
The following table shows the parameters of the instruction "DPSYC_FR":
Parameters Declaration Data type Memory area Description
REQ Input BOOL I, Q, M, D, L Level-triggered control parameter REQ=1:
Triggering of the SYNC/FREEZE job
LADDR Input HW_DPMAST
ER (WORD)
I, Q, M, D, L or
constant
Logical address of the DP master
GROUP Input BYTE I, Q, M, D, L or
constant
Group selection
Bit 0 = 1: group 1 selected
Bit 1 = 1: group 2 selected
:
Bit 7 = 1: group 8 selected
You can select several groups per job. The value
B#16#0 is invalid.
MODE Input BYTE I, Q, M, D, L or
constant
Job ID (coding complies with EN 50 170 Volume 2,
PROFIBUS)
Bit 0: reserved (value 0)
Bit 1: reserved (value 0)
Bit 2:
= 1: UNFREEZE will be executed
= 0: no meaning
Bit 3:
= 1: FREEZE will be executed
= 0: no meaning
Bit 4:
= 1: UNSYNC will be executed
= 0: no meaning
Bit 5:
= 1: SYNC will be executed
= 0: no meaning
Bit 6: reserved (value 0)
Bit 7: reserved (value 0)
Possible values:
with exactly one ID per job:
B#16#04 (UNFREEZE)
B#16#08 (FREEZE)
B#16#10 (UNSYNC)
B#16#20 (SYNC)
with more than one ID per job:
B#16#14 (UNSYNC, UNFREEZE)
B#16#18 (UNSYNC, FREEZE)
B#16#24 (SYNC, UNFREEZE)
B#16#28 (SYNC, FREEZE)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2154 System Manual, 01/2013,
Parameters Declaration Data type Memory area Description
RET_VAL Return INT I, Q, M, D, L If an error occurs while the instruction is
being executed, the return value contains an error
code.
Make sure that you evaluate RET_VAL each time
the block has been executed.
BUSY Output BOOL I, Q, M, D, L BUSY=1:
The SYNC/FREEZE job is not yet complete.
For additional information on valid data types, refer to "Overview of the valid data types
(Page 899)".
Parameter RET_VAL
Note
If you access DPV1 slaves, error information of these slaves can be forwarded from the DP
master to the instruction. For a description of this error information, refer to STATUS[3],
STATUS (Page 2118) parameter.
Error code*
(W#16#...)
Explanation
0000 Job was executed without errors.
7000 First call with REQ=0. The job specified with LADDR, GROUP and MODE is not active; BUSY has the
value 0.
7001 First call with REQ=1. The job specified with LADDR, GROUP and MODE was triggered; BUSY has the
value 1.
7002 Intermediate call (REQ
irrelevant). The activated SYNC/FREEZE job is still running; BUSY has
the value 1.
8090 The module selected with LADDR is not a DP master.
8093 This instruction is not permitted for the module selected with LADDR (configuration or version of the DP
master).
8094 GROUP parameter is incorrect
8095 MODE parameter is incorrect
80B0 The group selected with GROUP is not configured.
80B1 The group selected with GROUP is not assigned to this CPU.
80B2 The SYNC job specified with MODE is not permitted on the group selected
with GROUP.
80B3 The FREEZE job specified with MODE is not permitted on the group selected
with GROUP .
80C2 Temporary shortage of resources on the DP master: The DP master is
currently processing the maximum number of jobs for a CPU.
80C3 This SYNC/UNSYNC job cannot be activated at present because only one
SYNC/UNSYNC job can be triggered at a time. Check your user
program.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2155
Error code*
(W#16#...)
Explanation
80C4 This FREEZE/UNFREEZE job cannot be activated at present because only one
FREEZE/UNFREEZE job can be triggered at a time. Check your user
program.
80C5 Short circuit directly at DP interface
80C6 Job aborted due to I/O disconnection by CPU
80C7 Job aborted due to warm or cold restart on the DP master
8xyy General error information
See also: Evaluating errors with output parameter RET_VAL (Page 1422)
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
DPNRM_DG: Read diagnostics data from a DP slave
Description
You use the "DPNRM_DG" instruction to read the current diagnostics data of a DP slave in
the form specified in EN 50 170 Volume 2, PROFIBUS.
Refer to the following table for the basic structure of the slave diagnostics data and to the
manuals of the DP slaves for further information.
Byte Meaning
0 Station status 1
1 Station status 2
2 Station status 3
3 Master station number
4 Vendor ID (high byte)
5 Vendor ID (low byte)
6 ... Additional slave-specific diagnostic information
The data that has been read is entered in the target range indicated by RECORD following
error-free data transfer. You start the read process by assigning the value "1" to the REQ input
parameter when the "DPNRM_DG" instruction is called.
Functional description
The reading process is executed asynchronously, in other words, it can extend over several
calls. The output parameters RET_VAL and BUSY indicate the status of the job.
See also: Meaning of the parameters REQ, RET_VAL and BUSY with asynchronous
instructions (Page 1420).
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2156 System Manual, 01/2013,
Parameters
The following table shows the parameters of the instruction "DPNRM_DG":
Parameter Declaration Data type Memory area Description
REQ Input BOOL I, Q, M, D, L or
constant
REQ = 1: Read request
LADDR Input HW_DPSLAVE
(WORD)
D, L or constant Configured diagnostic address of the DP
slave
Note: Address must be specified in hexadecimal
form, for example, diagnostic address 1022 means:
LADDR:=W#16#3FE.
RET_VAL Return DINT, INT,
LREAL, REAL
I, Q, M, D, L If an error occurs while the instruction is
being executed, the return value contains an error
code. If no error has occurred, the length of
the data actually transferred is entered in RET_VAL
.
RECORD Output VARIANT I, Q, M, D, L Destination area for the diagnostics data that were
read. Only the BYTE data type is permitted. The
minimum length of the data record to be read or the
target range is 6. The maximum length of the data
record to be sent is 240. Standard slaves can
provide more than 240 bytes of diagnostics data up
to a maximum of 244 bytes. In this case, the first
240 bytes are transferred to the target range and
the overflow bit is set in the data.
BUSY Output BOOL I, Q, M, D, L BUSY = 1:
The reading process is not yet complete.
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
You will find information on data type conversion in the different programming languages under
"Auto-Hotspot".
Parameter RECORD
The CPU evaluates the actual length of the read diagnostics data:
If the length specified for RECORD
is less than the number of data bytes supplied, the data are discarded and a corresponding
error code is entered in RET_VAL.
is greater than or equal to the number of data bytes supplied, the data are accepted in the
destination area and the actual length is entered in RET_VAL as a positive value.
Note
You must ensure that the actual parameters of RECORD correspond in all calls belonging
to a job.
A job is uniquely identified by the LADDR input parameter.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2157
Standard slaves with more than 240 bytes of diagnostics data
With standard slaves on which the number of standard diagnostics data is between 241 and
244 bytes, note the following points:
If the length specified for RECORD
is less than 240 bytes, the data are discarded and a corresponding error code is entered
in RET_VAL.
If the length specified for RECORD is greater than or equal to 240 bytes, the first 240 bytes
of the standard diagnostics data are transferred to the target range and the overflow bit is
set in the data.
RET_VAL parameter
If an error occurs while the function is being executed, the return value contains an error
code.
If no errors have occurred during data transfer, RET_VAL contains the length of the data
read in bytes as a positive number.
Note
The amount of data read in a DP slave depends on its diagnostics status.
For the evaluation of the error information of the RET_VAL parameter, refer to the following
table.
The general error information of the instructions are described in the following section:
Evaluating errors with output parameter RET_VAL (Page 1422).
Error code
(W#16#...)
Explanation Restriction
7000 First call with REQ = 0: No data transfer active; BUSY has the value "0". -
7001 First call with REQ = 1: Data transfer triggered; BUSY has the value "1". Distributed I/O
7002 Intermediate call (REQ
irrelevant): Data transfer already active; BUSY has the value "1".
Distributed I/O
8090 Specified logical base address invalid: There is no
assignment in SDB1/SDB2x or there is no base address.
-
8093 This instruction is not valid for the module selected with LADDR and
IOID.
-
80A2 DP protocol error at layer 2 (for example, slave failure or bus
problems)
For ET200S, data record cannot be read in DPV0 mode.
Distributed I/O
80A3 DP protocol error with user interface/user Distributed I/O
80B0 Instruction not possible for module type.
The module does not recognize the data record.
Data record number 241 not permitted.
With "WR_REC (Page 2111)", data records 0 and 1 are not
permitted.
-
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2158 System Manual, 01/2013,
Error code
(W#16#...)
Explanation Restriction
80B1 The length specified in parameter RECORD is incorrect. specified length < data record
length
80B2 The configured slot is
not assigned.
-
80B3 Actual module type does not match the specified module
type in SDB1.
-
80C0 There are no diagnostics data available. -
80C1 The data of the previous write job on the module for the same data record
have not yet been processed by the module.
-
80C2 The module is currently processing the maximum possible
number of jobs for a CPU.
-
80C3 The required resources (memory, etc.) are currently
occupied.
-
80C4 Internal temporary error. Job could not be executed.
Repeat the job. If this error occurs often, check your installation for
sources of electrical interference.
-
80C5 Distributed I/O not available. Distributed I/O
80C6 Data record transfer stopped due to priority class abort (restart or
background)
Distributed I/O
8xyy General error information
See also: Evaluating errors with output parameter RET_VAL
(Page 1422)
-
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
DP_TOPOL: Determine topology for DP master system
Description
You use the instruction to trigger the topology determination for a selected DP master system.
Calling the instruction will address all diagnostics repeaters on a DP master system.
Note
The topology can only be determined for one DP master system at a time.
Topology determination is the prerequisite for the detailed display of the error location if line
errors occur. After configuration and after every change to the physical configuration of a DP
master system, you must repeat the topology determination with "DP_TOPOL".
Changes to the physical configuration are:
Changes in line lengths
Adding or removing stations or components with repeater function
Changing station addresses
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2159
If an error is reported by a diagnostics repeater, "DP_TOPOL" writes the DPR and DPRI
outputs for the duration of one "DP_TOPOL pass. If errors are reported by multiple diagnostics
repeaters of the selected DP master system, "DP_TOPOL" writes DPR and DPRI with
information regarding the first diagnostics repeater reporting the error. You can read out the
entire diagnostics information on the programming device or using the "DPNRM_DG
(Page 2156)" instruction. If no diagnostics repeater reports an error, the DPR and DPRI
outputs have the value NULL.
If you want to repeat a topology determination after an error occurs, you must first reset
"DP_TOPOL". This is done by calling "DP_TOPOL" with REQ=0 and R=1.
Functional description
"DP_TOPOL" works asynchronously, that is, its execution extends over multiple calls. You
start determining the bus topology by calling "DP_TOPOL" with REQ=1 . If you want to cancel
the process, call "DP_TOPOL" with R=1 .
The output parameters RET_VAL and BUSY indicate the status of the job.
See also: Meaning of the parameters REQ, RET_VAL and BUSY with asynchronous
instructions (Page 1420).
Note
Determining the topology may take several minutes.
Identification of a job
The input parameter DP_ID uniquely specifies a job.
If you have called "DP_TOPOL" and you call this instruction again before the topology is re-
determined, the manner in which the instruction reacts depends on whether the new call
involves the same job: If the DP_ID parameter matches a job that has not yet been completed,
then the call is interpreted as a follow-up call and the value W#16#7002 will be entered in
RET_VAL. On the other hand, if another job is involved, the CPU rejects it.
Parameters
The following table shows the parameters of the instruction "DP_TOPOL":
Parameter Declaration Data type Memory area Description
REQ Input BOOL I, Q, M, D, L or
constant
REQ=1: Trigger topology determination
R Input BOOL I, Q, M, D, L or
constant
R=1: Cancel topology determination
DP_ID Input HW_IOSYST
EM
I, Q, M, D, L or
constant
DP master system ID of those master systems
for which the topology will be determined
RET_VAL Return INT I, Q, M, D, L If an error occurs while the instruction is
being executed, the return value contains an
error code.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2160 System Manual, 01/2013,
Parameter Declaration Data type Memory area Description
BUSY Output BOOL I, Q, M, D, L BUSY=1: Topology determination is not yet
complete.
DPR Output BYTE I, Q, M, D, L PROFIBUS address of the diagnostics repeater
reporting the error.
DPRI Output BYTE I, Q, M, D, L Measuring segment diagnostics repeater
reporting the error:
Bit 0 = 1: Temporary faults on segment DP2
Bit 1 = 1: Permanent faults on segment DP2
Bit 4 = 1: Temporary faults on segment DP3
Bit 5 = 1: Permanent faults on segment DP3
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
RET_VAL parameter
When looking at the "real" error information (error codes W#16#8xyz) in the following table,
we distinguish between two cases:
Temporary errors (error codes W#16#80A2 to 80A4, 80C3, 80C5):
It is possible to eliminate this type of error without user action; in other words, it is advisable
to call "DP_TOPOL" again (multiple calls, if necessary).
Example of a temporary error: Resources required are currently in use (W#16#80C3).
Permanent errors (error codes W#16#8082, 80B0, 80B2):
This type of error does not correct itself. A new call of "DP_TOPOL" is only advisable after
you have eliminated the error. Example of a permanent error: The DP master/CPU does
not support this service. (W#16#80B0).
Error code*
(W#16#...)
Explanation
0000 Job was executed without errors.
7000 First call with REQ=0. Topology determination is not triggered. BUSY has the value "0".
7001 First call with REQ=1. The request to execute topology determination was sent. BUSY has the value "1".
7002 Intermediate call (REQ
irrelevant): Topology determination is not yet complete. BUSY has the value "1".
7010 You have attempted to cancel topology identification. But there is no running job with the specified DP_ID.
BUSY has the value "0".
7011 First call with R=1. The cancellation of the topology determination was triggered. BUSY has the value
"1".
7012 Intermediate call: The cancellation of the topology determination is not yet complete. BUSY has the value
"1".
7013 Final call: The topology determination was cancelled. BUSY has the value "0".
8082 No DP master system is configured with the specified DP_ID.
80A2 Error during topology determination; for more detailed information, refer to output parameters DPR and
DPRI.
80A3 Error during topology determination: Monitoring time has elapsed (timeout).
80B0 The DP master/CPU does not support this service.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2161
Error code*
(W#16#...)
Explanation
80B2 Error during topology determination: No diagnostics repeater was found at the selected DP master system.
80C3 Resources required are currently in use. Possible cause: You have initiated a second topology
determination (only one topology determination is permitted at one time).
80C5 The DP master system is currently not available.
8xyy General error information
See also: Evaluating errors with output parameter RET_VAL (Page 1422)
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
ASi
ASI_CTRL: Controlling ASi master behavior
Description of ASI_CTRL
Description
Using the instruction "ASI_CTRL", you can control the behavior of the AS-i master from the
user program of the PLC. The instruction processes the command protocol automatically. It
also enables parameter assignment on SIMATIC AS-i masters and reading out information
data. The functions and operation of the command interface are detailed in the manual for the
AS-i master.
Both centrally inserted AS-i masters and distributed AS-i masters via PROFIBUS DP are
supported. Combinations with PROFINET IO (e.g. IE/PB Link PN IO) are also possible.
The schematic diagram below shows the functions of the "ASI_CTRL" instruction:
SlMATlC station AS-i master
Start
command
Start
Write data
record
Status query
Read data
record
Send buffer
Receive buffer
Command no. / job
data
Response data
User program
Command
processing
A
S
-
i
m
a
s
t
e
r
s
t
a
r
t
a
d
d
r
e
s
s
C
o
m
m
a
n
d
i
n
t
e
r
f
a
c
e
STATUS
ASl_CTRL
1
2
3
6
4
5
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2162 System Manual, 01/2013,
Start of processing at the REQ parameter.
The program sends the required command to the AS-i master via the instruction
"RDREC".
The AS-i master processes the command.
The current status of the AS-i master is stored in the input area of the binary data
(logical start address).
The instruction "ASI_CTRL" cyclically queries and evaluates the 4 status bits.
Once command processing is complete, the command job is completed with
"RDREC". Depending on the command, the data field of "RDREC" may contain the
response data for the command or additional status information.
Differences in the command call between IE/ AS-i Link and DP/AS-i Links
There are significant differences in how a controller exchanges commands with an AS-i master.
IE/AS-i Link (PROFINET) used the data record interface. The different commands are
called with either "Write data record" ("WRREC" instruction) or "Read data record"
("RDREC" instruction) by various data record numbers.
DP/AS-i Links (PROFIBUS) use the command interface. All commands are called by data
record number 2 with "Write data record" ("WRREC" instruction) plus "Read data record"
("RDREC" instruction). The type of command is defined by the data content in the write job.
Changes compared to the instruction "ASi_3422".
The instruction "ASI_CTRL" is a revised version of the instruction "ASi_3422" (S7-300/400)
and provides improved functionality and compatibility. The specific changes are as follows:
For writing and reading diagnostic data records, the instructions "WR_REC (Page 2141)"
and "RD_REC (Page 2136)" have been replaced by the instructions "RDREC (Page 2109)"
and "WRREC (Page 2111)". Their function is identical; however, they support data transfer
via PROFINET IO.
The block type of the instruction has been changed from a function (FC) to a function block
(FB). "ASI_CTRL" has an instance data block and is multi-instance-capable.
The designation of the formal parameters of "ASI_CTRL" complies with the SIMATIC
system blocks. There is no STARTUP input parameter. The definition of the STATUS
parameter is based on the instructions "RDREC (Page 2109)" and "WRREC (Page 2111)".
The status identifiers for the parameter DONE and the new parameter BUSY have also
been adjusted.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2163
Operation of the "ASI_CTRL" instruction
The instruction "ASI_CTRL" is an asynchronous function block; in other words, its processing
extends over multiple calls.
A job is started with REQ = TRUE.
The job status is displayed via the BUSY output parameters and the two central bytes of
the output parameter STATUS.
The BUSY parameter is set during job processing. Upon the first call, STATUS is assigned
the value 00700100
H
. Upon all subsequent calls for this job, it is assigned the value
00700200
H
. When the job is complete, the result is output at the parameters DONE or
ERROR.
If no errors have occurred, DONE is set. For jobs with response data from the AS-i
master, this data is provided in the specified receive buffer. In such cases, the STATUS
parameter also displays the volume of data supplied in bytes. For jobs without response
data, the value 00000000
H
is entered in STATUS.
If an error occurs during job processing, ERROR is set. The content of the receive buffer
is invalid in such a case. An error code is entered in the STATUS parameter for a more
detailed description of the error which has occurred.
Number of command calls
If you use the instruction "ASI_CTRL" to send commands, you may not simultaneously send
other commands to the same AS-i master with "RDREC (Page 2109)" or "WRREC
(Page 2111)". This also applies to multiple calls of the instruction for the same AS-i master.
The instruction "ASI_CTRL" cannot be run with interruptions. Calls therefore cannot be
programmed in program priority classes which interrupt each other (for example with calls in
OB 1 and in OB 35).
Parameter
The following table shows the parameters of the instruction "ASI_CTRL":
Parameter Declaration Data type Memory area Description
REQ Input BOOL I, Q, M, D, L, constant REQ = TRUE starts a new job unless a job is
already in progress. No edge evaluation takes
place.
LADDR Input WORD I, Q, M, D, L, constant Start address of the AS-i master in the S7
address space (logical base address). The
start address is defined in the hardware
configuration when the master is configured.
SD Input VARIANT I, Q, M, D, L Send buffer
The parameter refers to a memory area in
which the command is to be specified (see "
ASi commands (Page 2166)").
Example: P#DB101.DBX 0.0 BYTE 223
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2164 System Manual, 01/2013,
Parameter Declaration Data type Memory area Description
RD Input VARIANT I, Q, M, D, L Receive buffer
This buffer is only relevant for commands
which deliver answer data. The parameter
refers to a memory area in which a command
response is stored (see "ASi commands
(Page 2166)").
Example: P#DB102.DBX 224.0 BYTE 221
DONE Output BOOL Q, M, D, L DONE = TRUE: Job completed without errors.
BUSY Output BOOL Q, M, D, L BUSY = TRUE: Job in progress.
ERROR Output BOOL Q, M, D, L ERROR = TRUE: Job aborted with error.
STATUS Output DWORD M, D Job status / error code
See the "STATUS parameter" description.
For additional information on valid data types, refer to "Overview of the valid data types
(Page 899)".
Note
Parameters LADDR, SD, and RD
The parameters LADDR, SD, and RD must not be changed in any block cycle when a job is
in progress: they must remain constant.
STATUS parameter
The following table shows the possible STATUS displays dependent upon DONE and ERROR.
DONE ERROR STATUS Meaning
0 0 00700000
H
First call with REQ = FALSE; no active job.
0 0 00700100
H
First call with REQ = TRUE; job has started.
0 0 00700200
H
Subsequent call (REQ irrelevant); job is still in progress.
1 0 00000000
H
Job completed without errors. No response data.
1 0 0000xx00
H
Job completed without errors. Number of xx bytes of response data.
0 1 C0818400
H
Data type of formal operand RD invalid.
0 1 C0818500
H
Error in communication with AS-i master (incorrect address configured at the LADDR
parameter).
0 1 C0838100
H
Incorrect AS-i slave address.
0 1 C0838200
H
AS-i slave is not enabled (not in LAS).
0 1 C0838300
H
Error at the AS interface (the SD parameter may have been set too small).
0 1 C0838400
H
The command is not valid with the current AS-i master status.
0 1 C0838500
H
There is no AS-i slave with the address "0".
0 1 C0838600
H
The AS-i slave has invalid configuration data (I/O or ID codes).
0 1 C083A100
H
The AS-i slave addressed has not been found at the AS interface.
0 1 C083A200
H
There is no AS-i slave with the address "0".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2165
DONE ERROR STATUS Meaning
0 1 C083A300
H
There is already an AS-i slave with the new address at the AS interface.
0 1 C083A400
H
The AS-i slave address cannot be deleted.
0 1 C083A500
H
The AS-i slave address cannot be set.
0 1 C083A600
H
The AS-i slave address cannot be permanently saved.
0 1 C083A700
H
Error during reading of the extended ID1 code.
0 1 C083A800
H
The target address is not plausible (e.g. a B slave address has been used for a standard
slave).
0 1 C083B100
H
A length error has occurred during string transfer.
0 1 C083B200
H
A protocol error has occurred during string transfer.
0 1 C083F800
H
Unknown job number or job parameter.
0 1 C083F900
H
The AS-i master has detected an EEPROM error.
ASi commands
Description
The command interface allows the controller and AS-i master to exchange parameter
assignment and information data.
These commands
provide the complete functionality of the M4 master profile of the AS-i master specifications.
enable the AS-i master to be completely configured from the controller.
Note
AS-i commands supported
Please see the manual of the relevant AS-i master for the AS-i commands supported and
a detailed description.
General structure of the send buffer
The general structure of the send buffer for commands and job data is set out in the table
below. The area for the command number must always be filled. The number of bytes for the
job data can be found in the description of the command (see AS-i master documentation).
"q" is the start address of the send buffer.
Byte Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
Meaning
q + 0 Command number
q + 1 Job data
q + 2 Job data
q + ... Job data
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2166 System Manual, 01/2013,
General structure of the receive buffer
The general structure of the receive buffer for the command response data is set out in the
table below. The number of bytes for the response data depends on the command. Some
commands do not return response data, and therefore only require the definition of a virtual
receive buffer which is not filled with data. "n" is the start address of the receive buffer.
Byte Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
Meaning
n + 0 Command number (echo)
n + 1 Response data
n + 2 Response data
n + ... Response data
CAUTION
Memory areas can be overwritten
If the receive buffer of the "ASI_CTRL" instruction is too short, neighboring memory areas
may be overwritten. The length specified in the ANY pointer of the RD parameter when the
instruction "ASI_CTRL" is called is irrelevant. The required length for the receive buffer can
be found in the description of the command.
The following applies for command numbers 39
H
, 41
H
, 42
H
, 43
H
and 44
H
:
The receive buffer must be 221 bytes long (bytes 0 to 220), even if the command returns less
data. Depending on the command, the highest bytes in the receive buffer may be overwritten
with zero values by the AS-i master.
AS-i commands
A selection of possible AS-i commands is set out in the table below.
Name Parameter Return Coding
Set_permanent_parameter
(Set_Permanent_Parameter)
Slave address, parameter 00
H
Get_permanent_parameter
(Get_Permanent_Parameter)
Slave address Parameter 01
H
Write_parameter
(Write_Parameter)
Slave address, parameter Parameter echo 02
H
Read_parameter
(Read_Parameter)
Slave address Parameter value 03
H
Store_actual_parameters
(Store_Actual_Parameters)
04
H
Set_configuration_data Slave address,
configuration
25
H
Get_configuration_data Slave address set configuration data 26
H
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2167
Name Parameter Return Coding
Store_actual_configuration
(Store_Actual_Configuration)
07
H
Get_actual_configuration Slave address Actual configuration
data
28
H
Configure_LPS LPS 29
H
Set_offline_mode Mode 0A
H
Select_auto-program Mode 0B
H
Set_mode Mode 0C
H
Change_ASiSlave_address
(Change_ASiSlave_Address)
Address1, Address2 0D
H
Get_AS-iSlave_status Slave address Error record of the AS-i
slave
0F
H
Read_lists_and_flags LDS, LAS, LPS, flags 30
H
Get_overall_configuration Actual configuration
data, current
parameters, LAS, flags
39
H
Set_overall_configuration Overall configuration 3A
H
Write_parameter_list Parameter list 3C
H
Read_parameter_echo_list Parameter echo list 33
H
Write_CTT2_request Slave address
CTT2 string
CTT2 string 44
H
Read_version_identifier Version string 14
H
Read_AS-i_slave Slave address ID code 17
H
Read_AS-i_slave_extended_ID1 Slave address Extended ID1 code 37
H
Write_AS-iSlave_extended_ID1 Extended ID1 code 3F
H
Read_AS-iSlave_extended_ID2 Slave address Extended ID2 code 38
H
Read_AS-iSlave_IO Slave address I/O configuration 18
H
Read_I/O_error_list LPF 3E
H
Write_ASi-slave_parameter_string Slave address, parameter
string
40
H
Read_ASiSlave_parameter_string Slave address Parameter string 41
H
Read_AS-iSlave_ID_string Slave address ID string 42
H
Read_AS-iSlave_diagnostic_string Slave address Diagnostic string 43
H
Read_AS-i_line_error_counter 4A
H
Read_and_clear_AS-i_line_error_counter 4B
H
Read_AS-iSlave_error_counter Slave address 4C
H
Read_and_clear_AS-iSlave_error_counter Slave address 4D
H
Additional command for DP/ AS-i F-Link:
ASi_status/diag_of_F_slaves Status/diagnostics of
all AS-i safe slaves
51
H
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2168 System Manual, 01/2013,
Note
Re-initializing the AS-i master command interface
Another command which is not mentioned in the table is command 77
H
. This call re-initializes
the command interface of the AS-i master. Any command which the AS-i master specified is
currently processing will be terminated.
As of version V2.1.20 of DP/AS-i LINK Advanced, command 0E
H
is also available. This call
enables you to release and block the ground fault monitoring function for a line.
9.8.3.4 Interrupts
ATTACH: Attach an OB to an interrupt event
Description
You use the instruction "ATTACH" to assign an organization block (OB) to an event.
You enter the symbolic or numeric name of the organization block in the OB_NR parameter.
This will then be assigned to the event specified in the EVENT parameter.
If the event in the EVENT parameter occurs following error-free execution of the "ATTACH"
instruction, the organization block in the OB_NR parameter will be called and its program
executed.
With the ADD parameter, you specify whether previous assignments of the organization block
to other events should be canceled or retained. If the ADD parameter has the value "0", the
existing assignments will be replaced by the current assignment.
Parameters
The following table shows the parameters of the "ATTACH" instruction:
Parameter Declaration Data type Memory area Description
OB_NR Input OB_ATT (INT) I, Q, M, D, L or constant Organization block (numbers up to 32767
are supported.)
EVENT Input EVENT_ATT
(DWORD)
D, L or constant Event, e.g., creation of a process event
(failure of a hardware module; read
hardware ID (16#C0xxyyzz) and query at
block)
ADD Input BOOL I, Q, M, D, L or constant Effects on previous assignments:
ADD=0 (default): This event replaces all
previous event assignments for this OB.
ADD=1: This event is added to the
previous event assignments for this OB.
RET_VAL Return INT I, Q, M, D, L Status of the instruction
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2169
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
RET_VAL parameter
Error code*
(W#16#....)
Description
0 No error
8090 OB does not exist
8091 OB is incorrect type
8093 Event does not exist
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
DETACH: Detach an OB from an interrupt event
Description
You use this instruction to cancel the existing assignment of an organization block to one or
more events during runtime.
If you have selected a single event, the assignment of the OB to this event will be cancelled.
All other currently existing assignments remain active. You can select an individual event
using the drop-down list of the operand placeholder at the EVENT parameter.
If you have not selected an event, all currently existing assignments of the organization
block to events will be canceled.
You enter the symbolic or numeric name of the organization block in the OB_NR parameter.
The assignment of this organization block to the event specified in the EVENT parameter will
then be canceled.
Parameters
The following table shows the parameters of the "DETACH" instruction:
Parameter Declaration Data type Memory area Description
OB_NR Input OB_ATT (INT) I, Q, M, D, L or constant Organization block (numbers up to 32768
are supported.)
EVENT Input EVENT_ATT
(DWORD)
D, L or constant Event
RET_VAL Return INT I, Q, M, D, L Status of the instruction
For additional information on valid data types, refer to "Overview of the valid data types
(Page 899)".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2170 System Manual, 01/2013,
Parameter RET_VAL
Error code*
(W#16#....)
Description
0 No error
1 No assignment exists (warning)
8090 OB does not exist
8091 OB has incorrect type
8093 Event does not exist
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
Cyclic interrupt
SET_CINT: Set cyclic interrupt parameters
Description
You use this instruction to set the parameters for a cyclic interrupt OB. The start time for a
cyclic interrupt OB is generated from the respective time interval of the OB and the phase
offset.
The time interval of an OB is the interval at which the OB is periodically called. For example,
if the time interval is 100 s, the OB will be called every 100 s during program execution.
The phase offset is a time interval by which the call of a cyclic interrupt OB is offset. You
can use the phase offset to process low priority organization blocks in a precise time base.
If the OB does not exist or if the time interval used is not supported, a corresponding error
alarm is output in the RET_VAL parameter.
A time interval in the CYCLE parameter of "0" means that the OB will not be called.
Functional description
If a lower priority OB and a higher priority OB are called in the same time interval, the lower
priority OB will only be called once the higher priority OB has been executed. The call time for
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2171
the lower priority OB can be offset according to the length of time to execute the higher-priority
OB.
RUN
t t t t
t t t t
OB
Higher priority
OB
Lower priority
OB call without phase offset
If a phase offset is configured for the lower priority OB and the phase offset is greater than the
current execution time of the respective higher priority OB, then the block will be called in a
fixed time base.
Phase offset
RUN
t t t t
t t t t
OB
Higher priority
OB
Lower priority
OB call with phase offset
Parameters
The following table shows the parameters of the "SET_CINT" instruction:
Parameter Declaration Data type Memory area Description
OB_NR Input OB_CYCLIC I, Q, M, D, L or constant OB number (<32768)
CYCLE Input UDINT I, Q, M, D, L or constant Time interval in microseconds
PHASE Input UDINT I, Q, M, D, L or constant Phase offset
RET_VAL Return INT I, Q, M, D, L Status of the instruction
For additional information on valid data types, refer to "Overview of the valid data types
(Page 899)".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2172 System Manual, 01/2013,
Parameter RET_VAL
Error code*
(W#16#....)
Description
0 No error
8090 OB does not exist or is of the wrong type
8091 Incorrect time interval
8092 Incorrect phase offset
80B2 No event assigned to OB
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
QRY_CINT: Query cyclic interrupt parameters
Description
You can use this instruction to query the current parameters of a cyclic interrupt OB. The cyclic
interrupt OB is identified using the OB_NR parameter.
The values of the queried cyclic interrupt parameters correspond to those at the time the
"QRY_CINT" instruction is executed.
Parameters
The following table shows the parameters of the "QRY_CINT" instruction:
Parameter Declaration Data type Memory area Description
OB_NR Input OB_CYCLIC
(INT)
I, Q, M, D, L or constant OB number (<32768) or symbolic
addressing via the name of the OB (e.g.
OB_MyOB)
CYCLE Output UDINT I, Q, M, D, L Time interval in microseconds
PHASE Output UDINT I, Q, M, D, L Phase offset
STATUS Output WORD I, Q, M, D, L Status of the cyclic interrupt:
Bit 0 to bit 4: see parameter STATUS
Other bits: Always "0"
RET_VAL Return INT I, Q, M, D, L Status of the instruction
For additional information on valid data types, refer to "Overview of the valid data types
(Page 899)".
Parameter STATUS
Bit Value Meaning
0 0 The CPU is in RUN mode.
1 The CPU is in startup.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2173
Bit Value Meaning
1 0 The cyclic interrupt is enabled.
1 The cyclic interrupt is delayed.
2 0 The cyclic interrupt is not enabled or has expired.
1 The cyclic interrupt is enabled.
3 0 -
1 -
4 0 An OB with the specified number does not exist.
1 An OB with the specified number exists.
Other bits Always "0"
Parameter RET_VAL
If an error occurs, the relevant error code will be displayed in the RET_VAL parameter and the
STATUS parameter is set to "0".
Error code*
(W#16#....)
Description
0 No error
8090 OB does not exist or is of the wrong type
80B2 No event assigned to OB
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
Time-of-day interrupt
SET_TINT: Set time-of-day interrupt
Description
With the instruction, you can set the start date and time of the time-of-day interrupt organization
blocks. The seconds and milliseconds of the specified start time are ignored and set to "0".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2174 System Manual, 01/2013,
Parameter
The following table shows the parameters of the instruction "SET_TINT":
Parameter Declaration Data type Memory area Description
OB_NR Input OB_TOD
(INT)
I, Q, M, D, L or
constant
Number of the OB started at the time SDT +
multiple of PERIOD (OB 10 to OB 17).
SDT Input DT D, L Start date and time: the seconds and
milliseconds of the specified start time are
ignored and set to 0.
If you want to set a monthly start of a time-of-
day interrupt OB, you can only use the days 1,
2, ... 28 as a start date.
PERIOD Input WORD I, Q, M, D, L or
constant
Period from starting point SDT onwards:
W#16#0000 = once
W#16#0201 = once every minute
W#16#0401 = once hourly
W#16#1001 = once daily
W#16#1201 = once weekly
W#16#1401 = once monthly
W#16#1801 = once yearly
W#16#2001 = at month's end
RET_VAL Return INT I, Q, M, D, L If an error occurs during execution of the
instruction, the actual parameter of RET_VAL
contains an error code.
For additional information on valid data types, refer to "Overview of the valid data types
(Page 899)".
Parameter RET_VAL
Error code*
(W#16#...)
Description
0000 No error occurred.
8090 Incorrect parameter OB_NR
8091 Incorrect parameter SDT
8092 Incorrect parameter PERIOD
80A1 The set start time is in the past. (This error code occurs only when PERIOD = W#16#0000.)
8xyy General error information
See also: Evaluating errors with output parameter RET_VAL (Page 1422)
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2175
SET_TINTL: Set time-of-day interrupt
Description
The instruction "SET_TINTL" is used to set the start data and time of the time-of-day interrupt
organization blocks from the user program, without having to make settings in the hardware
configuration.
With the SDT parameter, you specify the start date and time-of-day. With the PERIOD
parameter, you can specify the cycle at which the instruction call is to be repeated (e.g., daily,
once per week). If you set the repetition period to "monthly", you may only specify a day
between 1. and 28. for the start date. It is not permitted to assign parameters for day 29 to 31,
as no hardware interrupt would be called, for example, in February. If you want to initiate the
time-of-day interrupt at the end of each month, use the "End of month" function.
With the ACTIVATE parameter, you specify whether the settings made for the organization
block are to be applied directly (ACTIVATE = true) or only after "ACT_TINT (Page 2178)" for
the time-of-day interrupt organization block is called (ACTIVATE = false).
Note
When calling time-of-day interrupt organization blocks with a start time within the second hour
during changeover from daylight saving time to standard time, also use a time-delay interrupt
during the first hour of the time changeover.
Parameters
The following table shows the parameters of the "SET_TINTL" instruction:
Parameters Declaration Data type Memory area Description
OB_NR Input OB_TOD
(INT)
I, Q, M, D, L or
constant
Number of the OB started at time SDT +
multiple of PERIOD (OB10 to OB17).
SDT Input DTL D, L Start date and start time: The seconds and
milliseconds of the specified start time are
ignored and set to "0".
LOCAL Input BOOL I, Q, M, D, L or
constant
LOCAL = true: Use local time
LOCAL = false: Use system time
PERIOD Input WORD I, Q, M, D, L or
constant
Period from starting point SDT onwards:
W#16#0000 = Once
W#16#0201 = Once every minute
W#16#0401 = Once hourly
W#16#1001 = once daily
W#16#1201 = once weekly
W#16#1401 = once monthly
W#16#1801 = once yearly
W#16#2001 = at month's end
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2176 System Manual, 01/2013,
Parameters Declaration Data type Memory area Description
ACTIVATE Input BOOL I, Q, M, D, L or
constant
ACTIVATE = true: Execute instruction
ACTIVATE = false: Execute instruction only
when "ACT_TINT (Page 2178)" is called
RET_VAL Return INT I, Q, M, D, L If an error occurs during execution of the
instruction, the actual parameter of RET_VAL
contains an error code.
For additional information on valid data types, refer to "Overview of the valid data types
(Page 899)".
RET_VAL parameter
Error code*
(W#16#...)
Description
0000 No error occurred.
8090 Incorrect parameter OB_NR
8091 Incorrect parameter SDT
8092 Incorrect parameter PERIOD
80A1 The set start time is in the past. (This error code occurs only when PERIOD = W#16#0000.)
8xyy General error information
See also: Evaluating errors with output parameter RET_VAL (Page 1422)
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
CAN_TINT: Cancel time-of-day interrupt
Description
The instruction "CAN_TINT" is used to delete the start data and start time of a specified time-
of-day interrupt organization block. This deactivates the time-of-day interrupt, and the
organization block is no longer called.
If you want to use the time-of-day interrupt again, you must first reset the start time
("SET_TINTL (Page 2176)" instruction) and then activate the time-of-day interrupt
("ACT_TINT (Page 2178)" interrupt).
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2177
Parameters
The following table shows the parameters of the instruction "CAN_TINT":
Parameters Declaration Data type Memory area Description
OB_NR Input OB_TOD
(INT)
I, Q, M, D, L or constant Number of the OB whose start data and start
time are to be deleted.
RET_VAL Return INT I, Q, M, D, L If an error occurs during execution of the
instruction, the actual parameter of
RET_VAL contains an error code.
For additional information on valid data types, refer to "Overview of the valid data types
(Page 899)".
RET_VAL parameter
Error code*
(W#16#...)
Description
0000 No error occurred.
8090 Incorrect parameter OB_NR
80A0 No start date/time specified for the time-of-day interrupt OB
8xyy General error information
See also: Evaluating errors with output parameter RET_VAL (Page 1422)
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
ACT_TINT: Enable time-of-day interrupt
Description
You use the instruction to activate a time-of-day interrupt organization block.
Parameters
The following table shows the parameters of the instruction "ACT_TINT":
Parameter Declaration Data type Memory area Description
OB_NR Input OB_TOD
(INT)
I, Q, M, D, L or
constant
Number of the OB to be activated.
RET_VAL Return INT I, Q, M, D, L If an error occurs during execution of the
instruction, the actual parameter of RET_VAL
contains an error code.
For additional information on valid data types, refer to "Overview of the valid data types
(Page 899)".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2178 System Manual, 01/2013,
Parameter RET_VAL
Error code*
(W#16#...)
Description
0000 No error occurred.
8090 Incorrect parameter OB_NR
80A0 Start date and time-of day not set for the relevant time-of-day interrupt OB.
80A1 The activated time lies in the past; error occurs for execution "once".
8xyy General error information
See also: Evaluating errors with output parameter RET_VAL (Page 1422)
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
QRY_TINT: Query status of time-of-day interrupt
Description
You can use this instruction to display the status of a time-of-day interrupt organization block
in the STATUS output parameter.
Parameters
The following table shows the parameters of the instruction "QRY_TINT":
Parameter Declaration Data type Memory area Description
OB_NR Input OB_TOD
(INT)
I, Q, M, D, L or constant Number of the OB that will be
queried for status (OB 10 to OB 17).
RET_VAL Return INT I, Q, M, D, L If an error occurs during execution of the
instruction, then the actual parameter of
RET_VAL contains an error code.
STATUS Output WORD I, Q, M, D, L Status of the time-of-day interrupt;
see following table.
For additional information on valid data types, refer to "Overview of the valid data types
(Page 899)".
Parameter STATUS
If an error occurs (see RET_VAL parameter), "0" is output in the STATUS parameter.
Bit Value Meaning
0 0 In Run.
1 During startup.
1 0 The time-of-day interrupt is enabled.
1 The time-of-day interrupt is disabled.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2179
Bit Value Meaning
2 0 Time-of-day interrupt is not activated or has elapsed.
1 The time-of-day interrupt is activated.
4 0 An OB with an OB number as specified at OB_NR parameter does not exist.
1 An OB with an OB number as specified at OB_NR parameter does exist.
6 0 Base for the time-of-day interrupt is the basic time
1 Base for the time-of-day interrupt is the local time
Other Always "0"
Parameter RET_VAL
Error code*
(W#16#...)
Description
0000 No error occurred.
8090 Incorrect parameter OB_NR
8xyy General error information
See also: Evaluating errors with output parameter RET_VAL (Page 1422)
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
Time-delay interrupt
Using time-delay interrupts
Definition
After you have called the "SRT_DINT (Page 2182)" instruction, the operating system generates
an interrupt after the specified delay time has elapsed, in other words, the assigned time-delay
interrupt OB is called.
Prerequisites for the call
Before a time-delay interrupt can be called by the operating system, the following conditions
must be met:
The time-delay interrupt OB must be started by the "SRT_DINT (Page 2182)" instruction.
The time-delay interrupt OB must not be deselected during configuration.
The time-delay interrupt OB must exist in the CPU.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2180 System Manual, 01/2013,
Purpose of the instructions "SRT_DINT", "CAN_DINT" and "QRY_DINT"
You use the instructions to
Start time-delay interrupts ("SRT_DINT (Page 2182)")
Cancel time-delay interrupts ("CAN_DINT (Page 2183)")
Query time-delay interrupts ("QRY_DINT (Page 2183)")
Effects on the time-delay interrupt
The following table lists a number of different situations and explains the effect they have on
a time-delay interrupt.
If ... and ... Then ...
A time-delay interrupt is
started (by calling
"SRT_DINT (Page 2182)")
The time-delay interrupt has
already started,
The delay time is overwritten; the
time-delay interrupt is started
again.
The time-delay interrupt OB
does
not exist at the time of the
call,
The operating system generates
a priority class error (calls OB 85). If OB
85 does not exist, the CPU
changes to STOP.
The interrupt is started in a
startup
OB and the delay time
elapses
before the CPU changes to
RUN,
The call of the time-delay interrupt
OB is delayed until the CPU is in
RUN mode.
The delay time has elapsed, A previously started time-
delay
interrupt OB is still being
executed,
The operating system generates a
time error (calls OB 80). If OB 80
does not exist, the CPU changes
to STOP.
Response to warm restart and cold restart
During a warm restart or a cold restart, all the time-delay interrupt settings made in the user
program by means of instructions are cleared.
Starting in a startup OB
A time-delay interrupt can be started in a startup OB. Two conditions must be satisfied to call
the time-delay OB:
The delay time must have elapsed.
The CPU must be in the RUN mode.
If the delay time has elapsed and the CPU is not yet in the RUN mode, the time-delay interrupt
OB call is delayed until the CPU is in RUN mode. The time-delay interrupt OB is then called
before the first instruction in OB Main [OB 1] is executed.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2181
SRT_DINT: Start time-delay interrupt
Description
The instruction "SRT_DINT" is used to start a time-delay interrupt, which calls a time-delay
interrupt OB after the expiry of the delay time specified at the parameter DTIME. The delay
time is started when a negative edge is generated in the EN enable input. The signal state of
enable input EN must be "0" during delay time countdown. If the delay time countdown is
interrupted, the OB configured in the OB_NR parameter is not executed.
Accuracy
The maximum time between the "SRT_DINT" instruction call and the start of the time-delay
interrupt OB is one millisecond less than the assigned delay time, provided that no interruption
events delay the call.
Parameters
The following table shows the parameters of the instruction "SRT_DINT":
Parameters Declaration Data type Memory area Description
OB_NR Input OB_DELAY
(INT)
I, Q, M, D, L or constant Number of the OB to be executed after a
delay time
DTIME Input TIME I, Q, M, D, L or constant Delay time (1 to 60000 ms)
You can realize longer times, for example,
by using a counter in a time-delay
interrupt OB.
SIGN Input WORD I, Q, M, D, L or constant Identifier that appears when the time-
delay interrupt OB is called in the start
event information of the OB.
RET_VAL Return INT I, Q, M, D, L Status of the instruction
For additional information on valid data types, refer to "Overview of the valid data types
(Page 899)".
RET_VAL parameter
Error code*
(W#16#...)
Description
0000 No error
8090 Incorrect parameter OB_NR
8091 Incorrect parameter DTIME
8xyy General error information
See also: Evaluating errors with output parameter RET_VAL (Page 1422)
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2182 System Manual, 01/2013,
CAN_DINT: Cancel time-delay interrupt
Description
You use this instruction to cancel a started time-delay interrupt and, thus, also cancel the call
of the time-delay interrupt OB that is to be executed after the assigned delay time. You specify
the number of the organization block whose call is to be canceled in the OB_NR parameter.
Parameters
The following table shows the parameters of the "CAN_DINT" instruction:
Parameter Declaration Data type Memory area Description
OB_NR Input OB_DELAY
(INT)
I, Q, M, D, L or constant Number of the OB whose call will be
canceled
RET_VAL Return INT I, Q, M, D, L Status of the instruction
For additional information on valid data types, refer to "Overview of the valid data types
(Page 899)".
Parameter RET_VAL
Error code*
(W#16#...)
Description
0000 No error
8090 Incorrect OB_NR parameter
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
QRY_DINT: Query time-delay interrupt status
Description
The instruction "QRY_DINT" is used to query the status of the time-delay interrupt.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2183
Parameters
The following table shows the parameters of the instruction "QRY_DINT":
Parameters Declaration Data type Memory area Description
OB_NR Input OB_DELAY
(INT)
I, Q, M, D, L or
constant
Number of the OB whose status is being
queried.
RET_VAL Return INT I, Q, M, D, L If an error occurs during execution of the
instruction, the actual parameter of RET_VAL
contains an error code. The value "0" is
displayed in the STATUS parameter.
STATUS Output WORD I, Q, M, D, L Status of the time-delay interrupt, see
following table.
For additional information on valid data types, refer to "Overview of the valid data types
(Page 899)".
STATUS parameter
Bit Value Meaning
0 0 Operating system in RUN
1 Operating system in startup
1 0 Time-delay interrupt is enabled by the operating system.
1 Time-delay interrupt is disabled.
2 0 Time-delay interrupt is not activated or has elapsed.
1 Time-delay interrupt is activated.
3 - -
4 0 Time-delay interrupt OB with the specified number does not exist.
1 Time-delay interrupt OB with the specified number exists.
Other bits Always "0"
RET_VAL parameter
Error code*
(W#16#...)
Description
0000 No error occurred.
8090 Incorrect information in the OB_NR parameter
8xyy General error information
See also: Evaluating errors with output parameter RET_VAL (Page 1422)
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2184 System Manual, 01/2013,
Synchronous errors
Mask synchronous error events
Introduction
Synchronous errors are programming and access errors. Such errors occur as a result of
programming with incorrect operand areas or numbers, or incorrect addresses. Masking these
synchronous errors means the following:
Masked synchronous errors do not trigger an error OB call and do not lead to a programmed
alternative reaction.
The CPU "records" the masked errors that have occurred in an error status register.
Masking is carried out by calling the "MSK_FLT (Page 2191)" instruction.
Unmasking errors means canceling a previously set mask and clearing the corresponding bit
in the event status register of the current priority class. Masking is canceled as follows:
By calling the "DMSK_FLT (Page 2192)" instruction.
Once the current priority class has been completed.
If an error event occurs after it has been unmasked, then the operating system will start the
associated error OB. You program OB 121 for the reaction to programming errors and OB 122
for the reaction to access errors.
You can use the "READ_ERR (Page 2193)" instruction to read the masked errors that have
occurred.
Note
With the S7-300 (except CPU 318), regardless of whether an error is masked or unmasked,
the error is entered in the diagnostic buffer and the group error LED of the CPU is illuminated.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2185
Handling errors in general
If programming and access errors occur in a user program, you can react to them in different
ways:
You can program an error OB that is called by the operating system when the corresponding
error occurs.
You can disable the error OB call individually for each priority class. In this case, the CPU
does not change to STOP when an error of this type occurs in the particular priority class.
The CPU enters the error in an error register. From this entry, however, you cannot
recognize when or how often the error occurred.
Synchronous error
Error masked?
No YES
Disabling the call of an
error OB. (CPU does not
go to STOP mode when
an error occurs.)
Calling of an error OB.
(CPU goes to STOP mode
if the error OB is not
programmed.
The desired reaction to an
error is programmed in
the OB.
An error will be entered in
the error register.
Error filter
Synchronous errors are assigned to a particular bit pattern known as the error filter. You can
find this error filter in the input and output parameters of the "MSK_FLT (Page 2191)",
"DMSK_FLT (Page 2192)", and "READ_ERR (Page 2193)" instructions.
Synchronous errors are divided into programming and access errors that you can mask using
two error filters. The error filters are illustrated in the following figures.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2186 System Manual, 01/2013,
Programming error filter
The following figure shows the bit pattern of the error filter for programming errors. The error
filter for the programming errors is available in the "PRGFLT_..." parameters (see below
"Programming errors, Low-Word" or "Programming errors, High-Word").
Bit no.
Legend:
Bit no.
BCD conversion error
Area length error when reading
Area length error when writing
Range error when reading
Range error when writing
Timer number error
Counter number error
Alignment error when reading
Alignment error when writing
Not relevant
Write error data block
Write error instance data block
Block number error DB
Block number error Dl
Block number error FC
Block number error FB
DB not loaded
FC not loaded
SFC not loaded
FB not loaded
SFB not loaded
31 24 23 16
X X X X X
X X X X X X X
15 8 7 0
X
Non-relevant bits
In the figure above, x means ...
... Input parameters For "MSK_FLT (Page 2191)", "DMSK_FLT
(Page 2192)", "READ_ERR (Page 2193)"
= "0"
... Output parameters For "MSK_FLT (Page 2191)", "DMSK_FLT (Page 2192)" = "1" for S7-300
= "0" for S7-400
For "READ_ERR (Page 2193)" = "0"
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2187
Access error filter for all CPUs
The following figure shows you the bit pattern of the error filter for access errors. The filter for
access errors is in the parameters ACCFLT_... For an explanation of the access errors, refer
to the table "Possible causes of errors for all CPUs 31x except CPU 318" or "Possible causes
of errors for all CPUs 41x and CPU 318".
Bit no.
Legend:
Bit no.
l/O access error when reading
l/O access error when writing
Not relevant
31 24 23 16
X X X
X X X X X X X
15 8 7 0
X
X X X X X X X
X X X X X X X X X X X X X
Example
The following figure shows the low word of the error filter for access errors with all masked
errors for all CPUs.
As input parameters for "MSK_FLT (Page 2191)"
As output parameters for "MSK_FLT (Page 2191)"
Bit no.
Legend:
Bit no.
Masked errors
Not relevant
Masked errors
Not masked
Masked
lnput
parameter
Output
parameter
0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1
X X X X X X X X X X X X X X 1 1
X
0
1
15 8 7 0
15 8 7 0
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2188 System Manual, 01/2013,
Programming error low word
The following table lists the errors assigned to the low word of the error filter for programming
errors. The possible causes of the errors are also listed.
Possible causes of programming errors, low word
Error Event ID
(W#16#...)
Error occurs ...
BCD conversion error 2521 ... when the value to be converted is not a BCD number
(for
example, 5E8).
Area length error when
reading
2522 ... when an addressed operand is being used that is not
completely
within the possible operand area.
Example: MW 320 should be read although the memory
area
is only 256 bytes long.
Area length error when
writing
2523 ... when an addressed operand is being used that is not
completely
within the possible operand area.
Example: A value should be written to MW 320 although
the
memory area is only 256 bytes long.
Range error when reading 2524 ... when an incorrect area identifier is specified for the
operand when using indirect, area-overlapping
addressing.
Example:
Correct: LAR1 P#E 12.0
L W[AR1, P#0.0]
Incorrect: LAR1 P#12.0
L W[AR1, P#0.0]
For this operation
the area length error is signaled.
Range error when writing 2525 ... when an incorrect area identifier is specified for the
operand when using indirect, area-overlapping
addressing.
Example:
Correct: LAR1 P#E 12.0
T W[AR1, P#0.0]
Incorrect: LAR1 P#12.0
T W[AR1, P#0.0]
For this operation
the area length error is signaled.
Timer number error 2526 ... when a non-existent timer is accessed.
Example: SP T [MW 0] where MW 0 = 129; timer 129
should
be started although there are only 128 timers available.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2189
Error Event ID
(W#16#...)
Error occurs ...
Counter number error 2527 ... when a non-existent counter is accessed.
Example: CU C [MW 0] where MW 0 = 600; counter 600
must be accessed although there are only 512 counters
available (CPU 416-1).
Alignment error when
reading
2528 ... when a byte, word, or double word operand is
addressed
with a bit address 0.
Example: Correct: LAR1 P#M12.0
L B[AR1, P#0.0]
Incorrect: LAR1 P#M12.4
L B[AR1, P#0.0]
Alignment error when
writing
2529 ... when a byte, word, or double word operand is
addressed
with a bit address 0.
Example:
Correct: LAR1 P#M12.0
T B[AR1, P#0.0]
Incorrect: LAR1 P#M12.4
T B[AR1, P#0.0]
Programming error high word
The following table lists the errors assigned to the high word of the error filter for programming
errors. The possible causes of the errors are also listed.
Possible causes of programming errors, high word
Error Event ID
(W#16#...)
Error occurs ...
Write error data block 2530 ... when the data block to be written to is read-only.
Write error instance data block 2531 ... when the instance data block to be written to is read-
only.
Block number error DB 2532 ... when a data block must be opened whose number
is
higher than the highest permitted number.
Block number error DI 2533 ... when an instance data block must be opened
whose
number is higher than the highest permitted number.
Block number error FC 2534 ... when a function is called whose number is higher
than the
highest permitted number.
Block number error FB 2535 ... when a function block is called whose number is
higher
than the highest permitted number.
DB not loaded 253A ... when the data block to be opened is not loaded.
Instruction not loaded 253C to 253F ... when the called instruction is not loaded.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2190 System Manual, 01/2013,
Access error
The following table lists the errors assigned to the error filter for access errors for all CPUs.
The possible causes of the errors are also listed.
Error Event ID
(W#16#...)
Error occurs ...
I/O access error
when reading
2942 ... when a signal module is not assigned to the
address in the
I/O area.
Or
... when access to this I/O area is not acknowledged
within
the specified module monitoring time (timeout).
I/O access error
when writing
2943 ... when a signal module is not assigned to the
address in the
I/O area.
Or
... when access to this I/O area is not acknowledged
within
the specified module monitoring time (timeout).
MSK_FLT: Mask synchronous error events
Description
You use the instruction to control the reaction of the CPU to synchronous errors. This is done
by masking the respective synchronous errors (for error filters, see Mask synchronous error
events (Page 2185)). When you call "MSK_FLT", you mask the synchronous errors in the
current priority class.
If you set individual bits of the synchronous error filter to "1" in the input parameters, other bits
that were set previously retain their value of "1". You obtain new error filters that you can read
out using the output parameters. The synchronous errors you have masked do not call an OB
but are simply entered in an error register. You can read the error register with the
"READ_ERR (Page 2193)" instruction.
Parameter
The following table shows the parameters of the instruction "MSK_FLT":
Parameters Declaration Data type Memory area Description
PRGFLT_SET_MASK Input DWORD I, Q, M, D, L or constant Programming error to be
masked
ACCFLT_SET_MASK Input DWORD I, Q, M, D, L or constant Access error to be masked
RET_VAL Return INT I, Q, M, D, L Error information
PRGFLT_MASKED Output DWORD I, Q, M, D, L Masked programming errors
ACCFLT_MASKED Output DWORD I, Q, M, D, L Masked access errors
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2191
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
RET_VAL parameter
Error code*
(W#16#...)
Description
0000 None of the errors were already masked.
0001 At least one of the errors was already masked. Nevertheless the other errors will be masked.
8xyy General error information
See also: Getting error ID locally with GetErrorID (Page 2030)
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
See also
Evaluating errors with output parameter RET_VAL (Page 1422)
DMSK_FLT: Unmask synchronous error events
Description
You use the instruction to unmask the errors masked with "MSK_FLT (Page 2191)". To do
this, you must set the corresponding bits of the error filter to "1" in the input parameters. With
the "DMSK_FLT" call, you unmask the corresponding synchronous errors of the current priority
class. At the same time, the queried entries are cleared in the error register. You can read out
the new error filters using the output parameters.
Parameter
The following table shows the parameters of the instruction "DMSK_FLT":
Parameter Declaration Data type Memory area Description
PRGFLT_RESET_
MASK
Input DWORD I, Q, M, D, L or constant Programming errors to be
unmasked
ACCFLT_RESET_
MASK
Input DWORD I, Q, M, D, L or constant Access errors to be
unmasked
RET_VAL Return INT I, Q, M, D, L Error information
PRGFLT_MASKE
D
Output DWORD I, Q, M, D, L Still masked programming
errors
ACCFLT_MASKE
D
Output DWORD I, Q, M, D, L Still masked access errors
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2192 System Manual, 01/2013,
RET_VAL parameter
Error code*
(W#16#...)
Description
0000 All specified errors were unmasked.
0001 At least one of the errors was not masked. Nevertheless the other errors will be unmasked.
8xyy General error information
See also: Getting error ID locally with GetErrorID (Page 2030)
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
READ_ERR: Read out event status register
Description
You use the instruction to read the error register. The structure of the error register corresponds
to that of the programming and access error filters, which you can program as input parameters
with "MSK_FLT (Page 2191)" and "DMSK_FLT (Page 2192)".
In the input parameters, you enter the synchronous errors you want to read from the error
register. When you call "READ_ERR", you read the required entries from the error register and
at the same time clear these entries.
The error register contains information that tells you which of the masked synchronous errors
in the current priority class occurred at least once. If a bit is set, this means that the
corresponding masked synchronous error occurred at least once.
Parameter
The following table shows the parameters of the instruction "READ_ERR":
Parameter Declaration Data type Memory area Description
PRGFLT_QUERY Input DWORD I, Q, M, D, L or constant Query programming error
ACCFLT_QUERY Input DWORD I, Q, M, D, L or constant Query access error
RET_VAL Return INT I, Q, M, D, L Error information
PRGFLT_CLR Output DWORD I, Q, M, D, L Programming errors that occurred
ACCFLT_CLR Output DWORD I, Q, M, D, L Access errors that occurred
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2193
RET_VAL parameter
Error code*
(W#16#...)
Description
0000 All queried errors are masked.
0001 At least one of the queried errors is not masked.
8xyy General error information
See also: Getting error ID locally with GetErrorID (Page 2030)
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
See also
Evaluating errors with output parameter RET_VAL (Page 1422)
Asynchronous error event
DIS_IRT: Disable interrupt event
Description
The instruction "DIS_IRT" is used to disable the processing of new interrupts and
asynchronous error events. Disabling means that if an interrupting event occurs, the operating
system of the CPU reacts as follows:
It neither calls an interrupt OB nor an asynchronous error OB,
nor does it trigger the normal reaction if an interrupt OB or asynchronous error OB is not
programmed.
If you disable interrupts and asynchronous error events, this remains in effect for all priority
classes. The disable can only be canceled with the "EN_IRT (Page 2196)" instruction or by a
warm or a cold restart.
Whether the operating system writes interrupts and asynchronous error events to the
diagnostics buffer when they occur depends on the input parameter setting you select for
MODE.
Note
Remember that when you program the "DIS_IRT" instruction, all interrupts that occur will be
discarded.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2194 System Manual, 01/2013,
Parameter
The following table shows the parameters of the instruction "DIS_IRT":
Parameter Declaration Data type Memory area Description
MODE Input BYTE I, Q, M, D, L or constant Specifies which interrupts and
asynchronous
errors are disabled.
OB_NR Input INT I, Q, M, D, L or constant OB number
RET_VAL Return INT I, Q, M, D, L If an error occurs while the instruction is
being executed, the return value contains
an error code.
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
MODE parameter
MODE
(B#16#...)
Meaning
00 All newly occurring interrupts and asynchronous error events are disabled. (Synchronous errors
are not disabled.) Assign the value "0" to the OB_NR parameter. Entries continue to be made in the
diagnostics buffer.
01 All newly occurring events belonging to a specified interrupt class are disabled. Identify the interrupt class
by specifying it as follows:
Time-of-day interrupts: 10
Time-delay interrupts: 20
Cyclic interrupts: 30
Process interrupts: 40
Interrupts for DPV1: 50
Multicomputing interrupt: 60
Redundancy error interrupts: 70
Asynchronous error interrupts: 80
Entries continue to be made in the diagnostics buffer.
02 All new occurrences of a specified interrupt are disabled. You designate the interrupt
using the OB number. Entries continue to be made in the diagnostics buffer.
RET_VAL parameter
Error code*
(W#16#...)
Description
0000 No error occurred.
8090 The OB_NR input parameter contains an invalid value.
8091 The MODE input parameter contains an invalid value.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2195
Error code*
(W#16#...)
Description
8xyy General error information
See also: Evaluating errors with output parameter RET_VAL (Page 1422)
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
EN_IRT: Enable interrupt event
Description
You use the instruction to enable the processing of new interrupts and asynchronous error
events that you have previously disabled with the "DIS_IRT (Page 2194)" instruction. This
means that if an interrupting event occurs, the operating system of the CPU reacts in one of
the following ways:
It calls an interrupt OB or asynchronous error OB.
Or
It triggers the standard reaction if the interrupt OB or asynchronous error OB is not
programmed.
Parameters
The following table shows the parameters of the instruction "EN_IRT":
Parameters Declaration Data type Memory area Description
MODE Input BYTE I, Q, M, D, L or constant Specifies which interrupts and
asynchronous error events will be
enabled.
OB_NR Input INT I, Q, M, D, L or constant OB number
RET_VAL Return INT I, Q, M, D, L If an error occurs while the instruction is
being executed, the return value
contains an error code.
For additional information on valid data types, refer to "Overview of the valid data types
(Page 899)".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2196 System Manual, 01/2013,
Parameter MODE
MODE Meaning
0 All newly occurring interrupts and asynchronous error events are enabled.
1 All newly occurring events belonging to a specified interrupt class are enabled. Identify the interrupt class by
specifying it as follows:
Time-of-day interrupts: 10
Time-delay interrupts: 20
Cyclic interrupts: 30
Process interrupts: 40
Interrupts for DPV1: 50
Multicomputing interrupt: 60
Redundancy error interrupts: 70
Asynchronous error interrupts: 80
2 All newly occurring events of a specified interrupt are enabled. You designate the interrupt
using the OB number.
Parameter RET_VAL
Error code*
(W#16#...)
Description
0000 No error occurred.
8090 The OB_NR input parameter contains an invalid value.
8091 The MODE input parameter contains an invalid value.
8xyy General error information
See also: Evaluating errors with output parameter RET_VAL (Page 1422)
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
DIS_AIRT: Delay execution of higher priority interrupts and asynchronous error events
Description
You use "DIS_AIRT" to delay the processing of interrupt OBs whose priority are higher than
the priority of the current organization block.
You can call "DIS_AIRT" multiple times in an organization block. The "DIS_AIRT" calls are
counted by the operating system. Processing is delayed more and more each time "DIS_AIRT"
is executed. To cancel a delay, you must execute the "EN_AIRT (Page 2198)" instruction. To
cancel all delays, the number of "EN_AIRT (Page 2198)" executions must be equal to the
number of "DIS_AIRT" calls.
You can query the number of delays in the RET_VAL parameter of the "DIS_AIRT" instruction.
If the value in the RET_VAL parameter is "0", there are no delays.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2197
Parameters
The following table shows the parameters of the "DIS_AIRT" instruction:
Parameter Declaration Data type Memory area Description
RET_VAL Return INT I, Q, M, D, L Number of delays
For additional information on valid data types, refer to "Overview of the valid data types
(Page 899)".
EN_AIRT: Enable execution of higher priority interrupts and asynchronous error events
Description
You use "EN_AIRT" to enable processing of organization blocks when interrupts occur that
have been delayed by the "DIS_AIRT (Page 2197)" instruction.
When "EN_AIRT" is executed, you cancel a processing delay that was registered by the
operating system when "DIS_AIRT (Page 2197)" was called. To cancel all delays, the number
of "EN_AIRT" executions must be equal to the number of "DIS_AIRT (Page 2197)" calls. If, for
example, you have called "DIS_AIRT (Page 2197)" five times and thereby also delayed the
processing five times, you must call the "EN_AIRT" instruction five times in order to cancel all
five delays.
You can query the number of interrupt delays that have not yet been enabled after the
execution of "EN_AIRT" in the RET_VAL parameter of the "EN_AIRT" instruction. The value
"0" in the RET_VAL parameter means that all delays enabled by "DIS_AIRT (Page 2197)" have
been cancelled.
Parameters
The following table shows the parameters of the "EN_AIRT" instruction:
Parameter Declaration Data type Memory area Description
RET_VAL Return INT I, Q, M, D, L Number of configured delays
For additional information on valid data types, refer to "Overview of the valid data types
(Page 899)".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2198 System Manual, 01/2013,
9.8.3.5 Diagnostics
RD_SINFO: Read current OB start information
Description
You use the instruction "RD_SINFO" to read the start information
of the last OB called that has not yet been completely executed, and
of the last startup OB started.
There is no time stamp in either case. If the call is in OB 100, OB 101 or OB 102, two identical
start information messages will be returned.
Parameter
The following table shows the parameters of the "RD_SINFO" instruction:
Parameter Declaration Data type Memory area Description
RET_VAL Return INT I, Q, M, D, L Error information
TOP_SI Output VARIANT D, L Start information of the current OB
START_UP_SI Output VARIANT D, L Start information of the startup OB
last started
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
SDTs of the TOP_SI parameter
The following table shows the possible SDTs for the TOP_SI parameter:
Organization blocks (OB) System data types (SDT) System data type numbers
Any SI_classic 592
SI_none 593
ProgramCycleOB SI_ProgramCycle 594
TimeOfDayOB SI_TimeOfDay 595
TimeDelayOB SI_Delay 596
CyclicOB SI_Cyclic 597
ProcessEventOB SI_HWInterrupt 598
ProfileEventOB
StatusEventOB
UpdateEventOB
SI_Submodule 601
SynchronousCycleOB SI_SynchCycle 602
IOredundancyErrorOB SI_IORedundancyError 604
CPUredundancyErrorOB SI_CPURedundancyError 605
TimeErrorOB SI_TimeError 606
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2199
Organization blocks (OB) System data types (SDT) System data type numbers
DiagnosticErrorOB SI_DiagnosticInterrupt 607
PullPlugEventOB SI_PlugPullModule 608
PeripheralAccessErrorOB SI_AccessError 609
RackStationFailureOB SI_StationFailure 610
ServoOB SI_Servo 611
IpoOB SI_Ipo 612
StartupOB SI_Startup 613
ProgrammingErrorOB
IOaccessErrorOB
SI_ProgIOAccessError 614
SDTs of the START_UP_SI parameter
The following table shows the possible SDTs for the START_UP_SI parameter:
System data types (SDT) System data type numbers
SI_classic 592
SI_none 593
SI_Startup 613
Structures
The following tables set out the meaning of the structure elements of the individual structures:
Table 9-41 SI_classic structure
Structure element Data type Description
EV_CLASS BYTE Bits 0 to 3: Event ID
Bits 4 to 7: Event class
EV_NUM BYTE Event number
PRIORITY BYTE Priority class number
(Meaning of B#16#FE: OB not available or disabled or cannot be started in
current operating mode)
NUM BYTE OB number
TYP2_3 BYTE Data ID 2_3:
Identifies the information entered in ZI2_3
TYP1 BYTE Data ID 1:
Identifies the information entered in ZI1
ZI1 WORD Additional information 1
ZI2_3 DWORD Additional information 2_3
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2200 System Manual, 01/2013,
Table 9-42 SI_none structure
Structure element Data type Description
SI_Format USINT 16#FF = No information
16#FE = Optimized start information
OB_Class USINT OB class for "No information" or "Optimized start information"
OB_Nr UINT OB number (1 ... 32767)
Table 9-43 SI_ProgramCycle structure
Structure element Data type Description
SI_Format USINT 16#FF = No information
16#FE = Optimized start information
OB_Class USINT := 1 OB class for "No information" or "Optimized start information"
OB_Nr UINT OB number (1 ... 32767)
Initial_Call BOOL For OB_Class = 1, 30, 52, 61, 65
Remanence BOOL For OB_Class = 1
Table 9-44 SI_TimeOfDay structure
Structure element Data type Description
SI_Format USINT 16#FF = No information
16#FE = Optimized start information
OB_Class USINT := 10 OB class for "No information" or "Optimized start information"
OB_Nr UINT OB number (1 ... 32767)
CaughtUp BOOL For OB_Class = 10
SecondTime BOOL For OB_Class = 10
Table 9-45 SI_Delay structure
Structure element Data type Description
SI_Format USINT 16#FF = No information
16#FE = Optimized start information
OB_Class USINT := 20 OB class for "No information" or "Optimized start information"
OB_Nr UINT OB number (1 ... 32767)
Sign WORD For OB_Class = 20
Table 9-46 SI_Cyclic structure
Structure element Data type Description
SI_Format USINT 16#FF = No information
16#FE = Optimized start information
OB_Class USINT := 30 OB class for "No information" or "Optimized start information"
OB_Nr UINT OB number (1 ... 32767)
Initial_Call BOOL For OB_Class = 1, 30, 52, 61, 65
Event_Count INT For OB_Class = 30, 51, 52, 61, 65, 91, 92
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2201
Table 9-47 SI_HWInterrupt structure
Structure element Data type Description
SI_Format USINT 16#FF = No information
16#FE = Optimized start information
OB_Class USINT := 40 OB class for "No information" or "Optimized start information"
OB_Nr UINT OB number (1 ... 32767)
LADDR HW_IO For OB_Class = 40, 51, 55, 56, 57, 70, 82, 83, 85, 86, 91, 92
USI WORD For OB_Class = 40
IChannel USINT For OB_Class = 40
EventType BYTE For OB_Class = 40
Table 9-48 SI_Submodule structure
Structure element Data type Description
SI_Format USINT 16#FF = No information
16#FE = Optimized start information
OB_Class USINT OB class for "No information" or "Optimized start information"
OB_Nr UINT OB number (1 ... 32767)
LADDR HW_IO For OB_Class = 40, 51, 55, 56, 57, 70, 82, 83, 85, 86, 91, 92
Slot UINT For OB_Class = 55, 56, 57
Specifier WORD For OB_Class = 55, 56, 57
Table 9-49 SI_SynchCycle structure
Structure element Data type Description
SI_Format USINT 16#FF = No information
16#FE = Optimized start information
OB_Class USINT := 61 OB class for "No information" or "Optimized start information"
OB_Nr UINT OB number (1 ... 32767)
Initial_Call BOOL For OB_Class = 1, 30, 52, 61, 65
PIP_Input BOOL For OB_Class = 61, 91, 92
PIP_Output BOOL For OB_Class = 61, 91, 92
IO_System USINT For OB_Class = 61, 91, 92
Event_Count INT For OB_Class = 30, 51, 52, 61, 65, 91, 92
SyncCycleTime LTIME Calculated cycle time
Table 9-50 SI_IORedundancyError structure
Structure element Data type Description
SI_Format USINT 16#FF = No information
16#FE = Optimized start information
OB_Class USINT := 70 OB class for "No information" or "Optimized start information"
OB_Nr UINT OB number (1 ... 32767)
LADDR HW_ANY For OB_Class = 40, 51, 55, 56, 57, 70, 82, 83, 85, 86, 91, 92
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2202 System Manual, 01/2013,
Structure element Data type Description
Event_Class BYTE For OB_Class = 70, 83, 85, 86
Fault_ID BYTE For OB_Class = 70, 80, 83, 85, 86
Table 9-51 SI_CPURedundancyError structure
Structure element Data type Description
SI_Format USINT 16#FF = No information
16#FE = Optimized start information
OB_Class USINT := 72 OB class for "No information" or "Optimized start information"
OB_Nr UINT OB number (1 ... 32767)
Switch_Over BOOL For OB_Class = 72
Table 9-52 SI_TimeError structure
Structure element Data type Description
SI_Format USINT 16#FF = No information
16#FE = Optimized start information
OB_Class USINT := 80 OB class for "No information" or "Optimized start information"
OB_Nr UINT OB number (1 ... 32767)
Fault_ID BYTE For OB_Class = 70, 80, 83, 85, 86
Csg_OBnr OB_ANY For OB_Class = 80
Csg_Prio UINT For OB_Class = 80
Table 9-53 SI_DiagnosticInterrupt structure
Structure element Data type Description
SI_Format USINT 16#FF = No information
16#FE = Optimized start information
OB_Class USINT := 82 OB class for "No information" or "Optimized start information"
OB_Nr UINT OB number (1 ... 32767)
IO_State WORD For OB_Class = 82
LADDR HW_ANY For OB_Class = 40, 51, 55, 56, 57, 70, 82, 83, 85, 86, 91, 92
Channel UINT For OB_Class = 82
MultiError BOOL For OB_Class = 82
Table 9-54 SI_PlugPullModule structure
Structure element Data type Description
SI_Format USINT 16#FF = No information
16#FE = Optimized start information
OB_Class USINT := 83 OB class for "No information" or "Optimized start information"
OB_Nr UINT OB number (1 ... 32767)
LADDR HW_IO For OB_Class = 40, 51, 55, 56, 57, 70, 82, 83, 85, 86, 91, 92
Event_Class BYTE For OB_Class = 70, 83, 85, 86
Fault_ID BYTE For OB_Class = 70, 80, 83, 85, 86
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2203
Table 9-55 SI_AccessError structure
Structure element Data type Description
SI_Format USINT 16#FF = No information
16#FE = Optimized start information
OB_Class USINT := 85 OB class for "No information" or "Optimized start information"
OB_Nr UINT OB number (1 ... 32767)
LADDR HW_IO For OB_Class = 40, 51, 55, 56, 57, 70, 82, 83, 85, 86, 91, 92
Event_Class BYTE For OB_Class = 70, 83, 85, 86
Fault_ID BYTE For OB_Class = 70, 80, 83, 85, 86
IO_Addr UINT For OB_Class = 85
IO_LEN UINT For OB_Class = 85
Table 9-56 SI_StationFailure structure
Structure element Data type Description
SI_Format USINT 16#FF = No information
16#FE = Optimized start information
OB_Class USINT := 86 OB class for "No information" or "Optimized start information"
OB_Nr UINT OB number (1 ... 32767)
LADDR HW_IO For OB_Class = 40, 51, 55, 56, 57, 70, 82, 83, 85, 86, 91, 92
Event_Class BYTE For OB_Class = 70, 83, 85, 86
Fault_ID BYTE For OB_Class = 70, 80, 83, 85, 86
Table 9-57 SI_Servo structure
Structure element Data type Description
SI_Format USINT 16#FF = No information
16#FE = Optimized start information
OB_Class USINT := 91 OB class for "No information" or "Optimized start information"
OB_Nr UINT OB number (1 ... 32767)
Initial_Call BOOL For OB_Class = 1, 30, 52, 61, 65
PIP_Input BOOL For OB_Class = 61, 91, 92
PIP_Output BOOL For OB_Class = 61, 91, 92
IO_System USINT For OB_Class = 61, 91, 92
Event_Count INT For OB_Class = 30, 51, 52, 61, 65, 91, 92
Synchronous BOOL
Table 9-58 SI_Ipo structure
Structure element Data type Description
SI_Format USINT 16#FF = No information
16#FE = Optimized start information
OB_Class USINT := 92 OB class for "No information" or "Optimized start information"
OB_Nr UINT OB number (1 ... 32767)
Initial_Call BOOL For OB_Class = 1, 30, 52, 61, 65
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2204 System Manual, 01/2013,
Structure element Data type Description
PIP_Input BOOL For OB_Class = 61, 91, 92
PIP_Output BOOL For OB_Class = 61, 91, 92
IO_System USINT For OB_Class = 61, 91, 92
Event_Count INT For OB_Class = 30, 51, 52, 61, 65, 91, 92
Reduction UINT For OB_Class = 92
Table 9-59 SI_Startup structure
Structure element Data type Description
SI_Format USINT 16#FF = No information
16#FE = Optimized start information
OB_Class USINT := 100 OB class for "No information" or "Optimized start information"
OB_Nr UINT OB number (1 ... 32767)
LostRetentive BOOL For OB_Class = 100
LostRTC BOOL For OB_Class = 100
Table 9-60 SI_ProgIOAcessError structure
Structure element Data type Description
SI_Format USINT 16#FF = No information
16#FE = Optimized start information
OB_Class USINT OB class for "No information" or "Optimized start information"
OB_Nr UINT OB number (1 ... 32767)
BlockNr UINT For OB_Class = 121, 122
Reaction USINT For OB_Class = 121, 122
Fault_ID BYTE For OB_Class = 121, 122
BlockType USINT For OB_Class = 121, 122
Area USINT For OB_Class = 121, 122
DBNr DB_ANY For OB_Class = 121, 122
Csg_OBNr OB_ANY For OB_Class = 121, 122
Csg_Prio USINT For OB_Class = 121, 122
Width USINT For OB_Class = 121, 122
Note
The structure elements specified for the SI_classic structure are identical in content to the
temporary tags of any OB created with the block property "Default".
Please note, however, that temporary tags of the individual OBs can have different names
and different data types. Also note that the call interface of each OB includes additional
information regarding the date and the time of the OB request.
Bits 4 to 7 of the EV_CLASS structure element contain the event class. The following values
are possible here:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2205
1: Start events from standard OBs
2: Start events from synchronous error OBs
3: Start events from asynchronous error OBs
The PRIORITY structure element supplies the priority class belonging to the current OB.
Apart from these two elements, NUM is also relevant. NUM contains the number of the current
OB or the startup OB that was started last.
RET_VAL parameter
The following table shows the meaning of the values of the RET_VAL parameter:
Error code*
(W#16#...)
Explanation
8080 Start information of the current OB does not correspond to the specified user-defined data type
8081 Start information of the current OB does not correspond to the specified system data type
8082 Start information of the last startup OB started does not correspond to the specified user-defined data type
8083 Start information of the last startup OB started does not correspond to the specified system data type
Example
OB 80 is the OB that was called last and that has not yet been completely processed and OB
100 is the start-up OB that was started last.
The following table shows the assignment between the structure elements of the TOP_SI
parameter of the "RD_SINFO" instruction and the associated local tags of OB 80.
TOP_SI
structure element
Data type OB 80 - Associated local tag Data type
EV_CLASS BYTE OB80_EV_CLASS BYTE
EV_NUM BYTE OB80_FLT_ID BYTE
PRIORITY BYTE OB80_PRIORITY BYTE
NUM BYTE OB80_OB_NUMBR BYTE
TYP2_3 BYTE OB80_RESERVED_1 BYTE
TYP1 BYTE OB80_RESERVED_2 BYTE
ZI1 WORD OB80_ERROR_INFO WORD
ZI2_3 DWORD OB80_ERR_EV_CLASS BYTE
OB80_ERR_EV_NUM BYTE
OB80_OB_PRIORITY BYTE
OB80_OB_NUM BYTE
The following table shows the assignment between the structure elements of the
START_UP_SI parameter of the "RD_SINFO" instruction and the associated local tags of
OB 100.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2206 System Manual, 01/2013,
START_UP_SI
structure element
Data type OB 100 - Local tag Data type
EV_CLASS BYTE OB100_EV_CLASS BYTE
EV_NUM BYTE OB100_STRTUP BYTE
PRIORITY BYTE OB100_PRIORITY BYTE
NUM BYTE OB100_OB_NUMBR BYTE
TYP2_3 BYTE OB100_RESERVED_1 BYTE
TYP1 BYTE OB100_RESERVED_2 BYTE
ZI1 WORD OB100_STOP WORD
ZI2_3 DWORD OB100_STRT_INFO DWORD
See also
Evaluating errors with output parameter RET_VAL (Page 1422)
LED: Read LED status
Description
You can use the "LED" instruction to read out the status (e.g., "On" or "Off") of a particular
module LED.
With the LADDR parameter, you address the CPU or the interface.
With the LED parameter, you select the module LED whose current status is to be read out
using the instruction.
The RET_VAL parameter outputs the status of the selected LED when the instruction is
called. Depending on the LED selected, only certain status information may be displayed.
For example, some LEDs have only color information. Refer to the hardware documentation
of the respective module for the available status information of a particular LED.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2207
Parameters
The following table shows the parameters of the "LED" instruction:
Parameter Declaration Data type Memory area Description
LADDR Input HW_IO I, Q, M, L or constant Identification number of the CPU or interface.
The number is automatically assigned and
stored in the CPU properties or the interface
in the hardware configuration.
LED Input UINT I, Q, M, D, L or
constant
Identification number of the LED:
1: STOP/RUN
2: ERROR
3: MAINT (maintenance)
4: Redundant
5: Link (green)
6: Rx/Tx (yellow)
RET_VAL Return INT I, Q, M, D, L Status of LED
For additional information on valid data types, refer to "Overview of the valid data types
(Page 899)".
Parameter RET_VAL
RET_VAL Description
0 to 9 LED status:
0 = LED does not exist
1 = Permanently switched off
2 = Color 1 (e.g., for LED STOP/RUN: green) permanently ON
3 = Color 2 (e.g., for LED STOP/RUN: orange) permanently ON
4 = Color 1 flashing at 2 Hz
5 = Color 2 flashing at 2 Hz
6 = Colors 1 and 2 flashing alternately at 2 Hz
7 = LED is active, color 1
8 = LED is active, color 2
9 = LED exists, but status information not available
8091 Module addressed with the LADDR parameter does not exist.
8092 A module that does not support LEDs was addressed with the LADDR parameter.
8093 The identification number specified in the LED parameter is not defined.
80Bx The CPU specified in the LADDR parameter does not support the "LED" instruction.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2208 System Manual, 01/2013,
GET_NAME: Reading the name of a module
Description
The instruction "GET_NAME" reads the name of a module. The name of the module is
displayed in the network view and in the module properties.
The module is selected using the number of the PROFINET IO system (LADDR parameter)
and the hardware identifier of the module (STATION_NR parameter).
Once the instruction has been executed, the name of the module is written to the area
addressed with the DATA parameter.
The length of the module name is output at the LEN parameter. If the name of the module is
longer than the area addressed with the DATA parameter, only that section of the module
name which corresponds to the maximum length of the area addressed will be written.
Parameter
The following table shows the parameters of the "GET_NAME" instruction:
Parameter Declaration Data type Memory area Description
LADDR Input HW_IOSYSTEM I, Q, M, D, L or
constant
Number of the PROFINET IO system. The
number from the PROFINET IO system
properties can be applied in the network view.
STATION_NR Input UINT I, Q, M, D, L or
constant
Hardware identifier of the module. The number
from the module properties can be applied in
the network view.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2209
Parameter Declaration Data type Memory area Description
DATA InOut VARIANT I, Q, M, D, L Pointer to the area to which the name of the
module is written.
DONE Output BOOL I, Q, M, D, L The instruction was executed successfully.
Name of the module transferred to the area at
the DATA parameter.
BUSY Output BOOL I, Q, M, D, L 0: Execution of the instruction complete.
1: Execution of the instruction not yet
complete.
ERROR Output BOOL I, Q, M, D, L 0: No error.
1: An error occurred during execution of the
instruction.
Detailed information is output via the STATUS
parameter.
LEN Output DINT I, Q, M, D, L Length of the module name (number of
characters).
STATUS Output WORD I, Q, M, D, L Status parameter
The parameter is only set for the duration of
one call. To display the status, you should
therefore copy STATUS to a free data area.
STATUS has the following meaning,
depending on the ERROR bit:
ERRROR=FALSE:
STATUS has the value W#16#0000:
Neither warning nor error
STATUS has the value <>
W#16#0000: Warning, STATUS
supplies detailed information.
ERROR=TRUE:
An error has occurred, STATUS
supplies detailed information on the
type of error.
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
STATUS parameter
Error code*
(W#16#...)
Explanation
0 No error
8090 The LADDR input parameter contains an invalid value. Possible causes:
No PROFINET IO system has been configured for the specified number.
You have not specified a number at the LADDR parameter.
8092 The value at the LADDR parameter does not address a PROFINET IO system.
8093 Instruction does not support data type at the DATA parameter.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2210 System Manual, 01/2013,
Error code*
(W#16#...)
Explanation
8095 Station number (STATION_NR parameter) does not exist in the selected PROFINET IO system.
80B1 The CPU used does not support the instruction.
8852 The area specified at the DATA parameter is too short for the full module name. As much of the module
name as possible (maximum area length) is written.
To read the full name, use a longer data area at the DATA parameter. The area must have at least as many
characters as there are at the LEN parameter.
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
DeviceStates: Read module status information of an IO system
Description
You use the "DeviceStates" instruction to output the status of the modules of an IO system.
The status information is selected with the LADDR and MODE parameters:
With the LADDR parameter, you select the IO system.
With the MODE parameter, you select which status information is to be output.
The module status read out with the "DeviceStates" instruction is also displayed in the
Diagnostics view of the modules.
Parameters
The following table shows the parameters of the "DeviceStates" instruction:
Parameter Declaration Data type Memory area Description
LADDR Input HW_IOSYSTEM I, Q, M, L or constant Identification number of the IO system
MODE Input UINT I, Q, M, D, L or constant Selection of status information to be read
RET_VAL Return INT I, Q, M, D, L Status of instruction (see table parameter
MODE)
STATE InOut VARIANT I, Q, M, D, L Buffer for the IO system status;
The pointer can refer to the following data
types: BOOL, BYTE, WORD, DWORD,
LWORD or an Array of [...] of these data
types.
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2211
MODE parameter
With the MODE parameter, you select which status information is to be output based on the
following numbers.
MODE Description
1 Configuration of module/device is active or not yet complete
2 Module defective
3 Module disabled
4 Module exists
5 There is a problem in the module.
Parameter STATE
With the STATE parameter, the status of the modules selected with the MODE parameter is
output. The status information is output as a bit character string. The length of the bit character
string depends on the I/O system:
For PROFIBUS-DP the length of the character string is 128 bits.
For PROFINET-IO the length of the character string is 1024 bits.
If the status selected using MODE applies to a module, the corresponding bit of the module is
set to "1". For example, if an error has occurred in the third module, the third bit is set to "1".
The "0" bit of the bit character string summarizes the status information for all modules of an
I/O system:
Bit 0 = 0: No errors have occurred in any module/all bits of the bit character string are set
to "0".
Bit 0 = 1: An error has occurred in at least one module/at least one bit of the bit character
string was set to "1".
RET_VAL parameter
Error code*
(W#16#...)
Description
0 No error
8091 LADDR does not exist
8092 LADDR does not address an IO system
8093 Invalid data type at the STATE parameter.
80B1 The module specified in the "LADDR " parameter does not support the "DeviceStates" instruction.
80B2 The selected MODE parameter is not supported by the module selected via LADDR.
8452 The complete status information does not fit in the tag configured in the STATE parameter. The result is
only output up to the byte length of the tag used.
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2212 System Manual, 01/2013,
ModuleStates: Read module status information of a module
Description
You use the "ModuleStates" instruction to read out the status information of a module. You
select the status information with the LADDR and MODE parameters:
Use the LADDR parameter to select the module.
Use the MODE parameter to select which information is to be output.
The STATE parameter indicates the status of the module selected with the MODE
parameter.
Parameters
The following table shows the parameters of the "ModuleStates" instruction:
Parameter Declaration Data type Memory area Description
LADDR Input HW_DEVICE I, Q, M, L or constant Identification number of the module
MODE Input UINT I, Q, M, D, L or
constant
Selection of status information to be read
RET_VAL Return INT I, Q, M, D, L Status of the instruction
STATE InOut VARIANT I, Q, M, D, L Buffer for the status of the module
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
MODE parameter
With the MODE parameter, you select which status information is to be output based on the
following numbers.
MODE Description
1 Configuration of module is active or not yet complete
2 Module defective
3 Module disabled
4 Module exists
5 There is a problem in the module.
Parameter STATE
Any bit string (BOOL, BYTE, WORD) or an Array of a bit string can be used as a data type
(e.g. Array of BYTE). The length of the bit string depends on the device you use. The maximum
length is 128 bit. If the status selected using MODE applies to a module, the corresponding
bit of the module sub-module is set to "1". For example, if an error has occurred for the sub-
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2213
module in the third slot of the module, the third bit is set to "1". The "0" bit of the bit character
string summarizes the status information for all devices:
Bit 0 = 0: An error did not occur for any module. All the bits of the bit character string are
set to "0".
Bit 0 = 1: An error occurred for at least one sub-module of the module. At least one bit of
the bit character string was set to "1".
RET_VAL parameter
Error code*
(W#16#...)
Description
0 No error
8091 LADDR does not exist
8092 LADDR does not address an IO module
8093 Invalid data type at the STATE parameter.
80B1 The module specified in the "LADDR" parameter does not support the "ModuleStates" instruction.
80B2 The selected MODE parameter is not supported by the module selected via LADDR.
8452 The complete status information does not fit in the tag configured in the STATE parameter. The result is
only output up to the bit length of the tag used.
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
GEN_DIAG: Generate diagnostics information
Description
The "GEN_DIAG" instruction generates diagnostics information for hardware components from
other manufacturers for use in TIA Portal diagnostics. The GSD(GSDL/GSDML) file supplied
by the manufacturer must first be installed before the instruction can be used.
The instruction generates all diagnostic events (including those for maintenance). If a
corresponding OB was created for a diagnostic event, this OB is called (for example: diagnostic
interrupt following a power supply or battery backup error).
Use the LADDR parameter to select the hardware component for which you want to
generate a diagnostic event.
Use the MODE parameter to specify whether the event is to be outgoing or incoming.
Use the DiagEvent parameter to define the diagnostic event in the DiagnosticDetail
structure. The structure is created automatically in the local interface of the block when you
define a tag at the DiagEvent parameter.
The diagnostics information is provided synchronously. Diagnostics information transfer and
alarm output are asynchronous.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2214 System Manual, 01/2013,
NOTICE
Failsafe-specific errors messages are not valid
If you define failsafe-specific diagnostics information at the DiagEvent parameter, the
instruction will check this information and output the error code 80A1.
Parameter
The following table shows the parameters of the "GEN_DIAG" instruction:
Parameter Declaration Data type Memory area Description
LADDR Input HW_ANY I, Q, M, D, L or
constant
Identification number of the hardware
component
MODE Input UINT I, Q, M, D, L or
constant
Selection of incoming/outgoing information:
1: The diagnostic event specified is an
incoming event
2: The diagnostic event specified is an
outgoing event
3: All diagnostic events are outgoing.
There are therefore no hardware
component faults (green diagnostics
symbol). The DiagEvent parameter is not
evaluated when MODE = 3.
DiagEvent InOut DiagnosticDetail L Specifies the diagnostic event (see
"DiagEvent parameter").
RET_VAL Return INT I, Q, M, D, L Status of instruction / error message (see
"RET_VAL parameter")
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
DiagEvent parameter
The structure DiagnosticDetail is a system data type for specifying the diagnostic event. Its
structure is as follows:
Parameter Data type Description
DiagnosticDet
ail
Struct
ChannelI
nfo
WORD Channel properties (0...7)
ALID UINT Local ID of the alarm. The ID uniquely identifies the alarm.
TextID UINT ID of an alarm text in a text list.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2215
Parameter Data type Description
Channel
Number
UINT Manufacturer-specific channel number (0x0000 0x7FFF)
Addval_0 DWORD Placeholder for additional information The value / list of values depends on the connection
error.
TextID2 UINT Texts for CPU response (mode, OB calls, etc.).
LADDR HW_ANY Identical to the LADDR parameter.
TextListI
d
UINT 0: No text list
0: ID of the text list
Channel
Direction
UINT 000: Manufacturer-specific
001: Input
002: Output
003: Input/Output
004 - 007: Reserved
Addval_1 DWORD Placeholder for additional information on the channel error (depends on the GSD file).
For channel error types, see also: IEC 61158 (PROFINET IO Type 10 and PROFIBUS
DP Type 3).
RET_VAL parameter
Error code*
(W#16#...)
Explanation
0 No error
1 Event has already been generated.
8080 Value in the MODE parameter is not supported.
8090 Identification for hardware component not available at the LADDR parameter.
8091 Diagnostics information cannot be generated for the hardware component addressed at the LADDR
parameter.
8092 The hardware component addressed does not support the structure of the diagnostics information to be
generated.
80A1 Content of the DiagnosticsDetail structure at the DiagEvent parameter is invalid or inconsistent.
Failsafe-specific diagnostics information defined at the DiagEvent parameter (not valid).
80A2 Outgoing event that was not previously detected with the property "incoming".
80A3 Event cannot be detected due to overflow in the hardware component addressed.
80A4 Hardware component addressed cannot be accessed.
80C1 Insufficient resources for parallel execution.
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2216 System Manual, 01/2013,
GET_DIAG: Read diagnostic information
Description
You can use the "GET_DIAG" instruction to read out the diagnostic information of a hardware
object. The hardware object is selected using the parameter LADDR. With the MODE
parameter, you select which diagnostic information is to be read out.
Parameter
The following table shows the parameters of the instruction "GET_DIAG":
Parameter Declaration Data type Memory area Description
MODE Input UINT I, Q, M, D, L or constant Use the MODE parameter to select which
diagnostic data is to be output.
LADDR Input HW_ANY
(WORD)
I, Q, M, L or constant Hardware ID of the device.
RET_VAL Output INT I, Q, M, D, L Status of the instruction
CNT_DIAG Output UINT I, Q, M, D, L Number of output diagnostic details
DIAG InOut VARIANT I, Q, M, D, L Diagnostics information corresponds with
the selected mode.
DETAIL InOut VARIANT I, Q, M, D, L Diagnostics details correspond with the
selected mode.
Parameter is hidden (only used for
MODE = 3).
For additional information on valid data types, refer to "Overview of the valid data types
(Page 899)".
MODE parameter
Depending on the value at the MODE parameter, different diagnostics data is output at the
DIAG, CNT_DIAG and DETAIL output parameters.
MODE Description DIAG CNT_DIAG DETAIL
0 Output of all supported
diagnostic information for a
module as DWORD, where Bit
X=1 indicates that mode X is
supported.
Bit string of the supported
modes as DWORD, where
Bit X=1 indicates that mode
X is supported.
0 -
1 Output of the inherent status
of the addressed hardware
object.
Diagnostics status.
Output of the inherent status
of the addressed hardware
object in accordance with
the DIS structure.
0 -
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2217
MODE Description DIAG CNT_DIAG DETAIL
2 Output of the status of all
subordinate modules of the
addressed hardware object.
Diagnostics status. Output
in accordance with the DNN
structure.
0 -
3 Output of the inherent status
of the addressed hardware
object and detailed
information on channel
diagnostics.
Output of the inherent status
of the addressed hardware
object in accordance with
the DIS structure.
Number of module
status information.
Module status
information in
accordance with the
DiagnosticDetail
structure.
DIS structure
With parameter MODE = 1, the diagnostic information is output in accordance with the DIS
structure. The following table shows the meaning of the individual parameter values.
Parameter Data type Value Description
MaintenanceState DWORD Enum
0 No maintenance required
1 The module or device is disabled.
2 -
3 -
4 -
5 Maintenance required
6 Maintenance demanded
7 Error
8 Status unknown / error in subordinate module
9 -
10 Inputs/outputs are not available.
ComponentStateD
etail
DWORD Bit array Status of the module sub-modules:
Bit 0 to 15: Status message of the module
Bit 16 to 31: Status message of the CPU
0 to 2
(enum)
Additional information:
Bit 0: No additional information
Bit 1: Transfer not permitted
3 Bit 3 = 1: At least one channel supports qualifiers for diagnostics
4 Bit 4 = 1: Maintenance required for at least one channel or one
component.
5 Bit 5 = 1: Maintenance demanded for at least one channel or one
component.
6 Bit 6 = 1: Error in at least one channel or one component.
7 to 10 Reserved (always = 0)
11 to 14 Bit 11 = 1: PNIO - sub-module correct
Bit 12 = 1: PNIO - replacement module
Bit 13 = 1: PNIO - incorrect module
Bit 14 = 1: PNIO - module disconnected
15 Reserved (always = 0)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2218 System Manual, 01/2013,
Parameter Data type Value Description
16 to 31 Status information for modules generated by the CPU:
Bit 16 = 1: Module disabled
Bit 17 = 1: CiR operation active
Bit 18 = 1: Input not available
Bit 19 = 1: Output not available bit
20 = 1: Overflow diagnostics buffer bit
21 = 1: Diagnostics not available bit
22 - 31: Reserved (always 0)
OwnState UINT Enum The value of the parameter Ownstate describes the maintenance status
of the module.
0 No fault
1 The module or device is disabled.
2 Maintenance required
3 Maintenance demanded
4 Error
5 The module or the device cannot be reached from the CPU (valid for
modules and devices below a CPU).
6 Inputs/outputs are not available.
7 -
IOState WORD Bit array I/O status of the module
0 Bit 0 = 1: No maintenance required
1 Bit 1 = 1: The module or device is disabled.
2 Bit 2 = 1: Maintenance required
3 Bit 3 = 1: Maintenance demanded
4 Bit 4 = 1: Error
5 Bit 5 = 1: The module or the device cannot be reached from the CPU
(valid for modules and devices below a CPU).
6 Inputs/outputs are not available.
7 Qualifier; bit 7 = 1, if bit 0, 2, or 3 are set
8 to 15 Reserved (always = 0)
OperatingState UINT Enum
0 -
1 In STOP / Firmware update
2 In STOP / reset memory
3 In STOP / self start
4 In STOP
5 Memory reset
6 In START
7 In RUN
8 -
9 In HOLD
10 -
11 -
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2219
Parameter Data type Value Description
12 Module defective
13 -
14 No power
15 CiR
16 In STOP / without ODIS
17 In
18
19
20
DNN structure
With parameter MODE = 2, the diagnostic information details are output in accordance with
the DNN structure. The following table shows the meaning of the individual parameter values.
Parameter Data type Value Description
SubordinateState UINT Enum Status of the subordinate module (see parameter OwnState of the
DIS structure)
SubordinateIOState WORD Bitarray Status of the inputs and outputs of the subordinate module (see
parameter IO State of the DIS structure)
DNNmode WORD Bitarray Bit 0 = 0: Diagnostics enabled
Bit 0 = 1: Diagnostics disabled
Bit 1 to 15: Reserved
DiagnosticDetail structure
With parameter MODE = 3, the diagnostic information details are output in accordance with
the DiagnosticDetail structure. The following table shows the meaning of the individual
parameter values.
Parameter Data type Description
ChannelInfo WORD Channel properties (0...7)
ALID UInt Identification ID of alarm
TextID UNIT ID of an alarm text in a text list.
ChannelNumber UINT Manufacturer-specific channel number (0x0000 0x7FFF)
Addval_0 DWORD Placeholder for additional information The value / list of values depends on the
connection error.
TextID2 UInt Texts for CPU response (mode, OB calls, etc.).
LADDR HW_ANY Identical to the LADDR parameter.
TextListId UInt 0: No text list
0: ID of the text list
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2220 System Manual, 01/2013,
Parameter Data type Description
ChannelDirection UInt 000: Manufacturer-specific
001: Input
002: Output
003: Input/Output
004 - 007: Reserved
AddVal_1 DWORD Placeholder for additional information on the channel error (depends on the GSD
file).
For channel error types, see also: IEC 61158 (PROFINET IO Type 10 and
PROFIBUS DP Type 3).
RET_VAL parameter
Error code*
(W#16#...)
Description
0 No error
n The data area at the DETAIL parameter is too small. Not all details of the diagnostic data can be output.
8080 Value in the MODE parameter is not supported.
8081 Type at the DIAG parameter is not supported with the selected mode (parameter MODE).
8082 Type at the DETAIL parameter is not supported by the selected mode (parameter MODE).
8090 LADDR does not exist
8091 Channel does not exist.
80C1 Insufficient resources for parallel execution.
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
9.8.3.6 Pulse
CTRL_PWM: Pulse-width modulation
Description
You can use the "CTRL_PWM" instruction to enable and disable a pulse output supported by
the CPU using the software.
Note
Pulse output parameters are assigned exclusively in the device configuration and not using
the "CTRL_PWM" instruction. Any change of parameters that is intended to have an effect
on the CPU must therefore be made while the CPU is in STOP mode.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2221
You enter the hardware ID of the pulse output you want to control with the instruction in the
PWM input. Error-free execution of the instruction is possible only when the specified pulse
output is enabled in the hardware configuration.
Only tags of "HW_PWM" data type can be specified in the PWM input. The hardware data type
HW_PWM has a length of one WORD.
The pulse output is enabled when the bit in the ENABLE input of the instruction is set. If
ENABLE has the value TRUE, the pulse output generates pulses that have the properties
defined in the device configuration. When the bit in the ENABLE input is reset or the CPU
changes to STOP, the pulse output is disabled and no more pulses are generated.
The "CTRL_PWM " instruction is only executed if the signal state in the EN input is "1".
Since the S7-1200 enables the pulse output when the "CTRL_PWM" instruction is executed,
BUSY at S7-1200 always has the value FALSE.
The ENO enable output is set only when the EN enable input has signal state "1" and no errors
have occurred during execution of the instruction.
Note
Use of the force table for PWM and PTO
Digital inputs and outputs that are used for PWM and PTO cannot be forced. Digital inputs
and outputs that were assigned via device configuration cannot be controlled by either the
force table or the monitoring table.
Parameters
The following table shows the parameters of the "CTRL_PWM" instruction:
Parameter Declaration Data type Memory area Description
PWM Input HW_PWM
(WORD)
I, Q, M, L or constant Hardware ID of the pulse generator
ENABLE Input BOOL I, Q, M, D, L or
constant
The pulse output is enabled when ENABLE =
TRUE and disabled when ENABLE = FALSE.
BUSY Output BOOL I, Q, M, D, L Processing status
STATUS Output WORD I, Q, M, D, L Status of the instruction
For additional information on valid data types, refer to "Overview of the valid data types
(Page 899)".
Parameter STATUS
Error code*
(W#16#...)
Description
0 No error
80A1 Hardware ID of the pulse generator is invalid
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2222 System Manual, 01/2013,
9.8.3.7 Recipes and data logging
Recipe functions
RecipeExport: Exporting recipes
Description
The "RecipeExport" instruction exports the recipe data from a data block to a CSV file on the
memory card of the CPU.
The export is triggered by the "REQ" parameter. The BUSY parameter is set to "1" during the
export. During the export, the CSV file is created in the "Recipes" folder in the main directory
of the memory card. The name of the data block is used as file name of the created CSV file.
If a CSV file with an identical name already exists, it is overwritten during the export.
After the execution of the instruction, BUSY is reset to "0" and the completion of the operation
is indicated with "1" at the DONE parameter. If an error occurs during execution, this is signaled
by the parameters ERROR and STATUS.
Parameter
The following table shows the parameters of the "RecipeExport" instruction:
Parameter Declaration Data type Memory area Description
REQ Input BOOL I, Q, M, D, L, T, C or
constant
Control parameter REQUEST: Activates the
export on a positive edge.
RECIPE_DB InOut VARIANT Pointer to the recipe data block. For
information on the structure of the data block,
refer to: Structure of a recipe DB (Page 2226)
DONE Output BOOL I, Q, M, D, L Status parameter
0: Job not yet started or still executing.
1: Job executed without errors.
BUSY Output BOOL I, Q, M, D, L Status parameter
0: The instruction is not executed.
1: The instruction is executed.
ERROR Output BOOL I, Q, M, D, L Status parameter
0: Neither warning nor error.
1: An error has occurred. STATUS
supplies detailed information on the type of
error.
STATUS Output WORD I, Q, M, D, L Status parameter
See the "STATUS" parameter table.
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2223
STATUS parameter
Error code*
(W#16#...)
Explanation
0 No error occurred
8090 File name of the CSV file contains invalid characters. The file name of the CSV file is identical to the name
of the data block.
80B3 Insufficient memory space on the memory card or the internal load memory.
80B4 The memory card is write-protected.
80C0 CSV files is temporarily locked.
80C1 Data block temporarily locked.
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
RecipeImport: Importing recipes
Description
The "RecipeImport" instruction imports the recipe data from a CSV file on the memory card
into the data block at the RECIPE_DB parameter. The values in the data block are overwritten
in the process.
Note the following when importing the CSV file:
The CSV file must be located in the "Recipes" directory of the memory card.
The name of the CSV file must match the name of the data block at the RECIPE_DB
parameter.
The first line (header) of the CSV file contains the name of the recipe components (see
also: Structure of a recipe DB (Page 2226)). The first line is ignored during import. The
names of the recipe components in the CSV file and the data block are not reconciled during
import.
In each case the first value in each line of the CSV file is the index number of the recipe.
The individual recipes are imported in the order of the index. For this, the index in the CSV
file has to be in ascending order and may contain no gaps (if this is not the case, the error
message 80B0 is output at the STATUS parameter.
The CSV file may not contain more recipe data records than provided for in the data block.
The maximum number of data records is indicated by the array limits in the data block.
The import is triggered by the "REQ" parameter. The BUSY parameter is set to "1" during the
import. After the execution of the instruction, BUSY is reset to "0" and the completion of the
operation is indicated with "1" at the DONE parameter. If an error occurs during execution,
this is signaled by the parameters ERROR and STATUS.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2224 System Manual, 01/2013,
Parameter
The following table shows the parameters of the "RecipeImport" instruction:
Parameter Declaration Data type Memory area Description
REQ Input BOOL I, Q, M, D, L, T, C or
constant
Control parameter REQUEST: Activates the
import on a rising edge.
RECIPE_DB InOut VARIANT D Pointer to the recipe data block. For
information on the structure of the data block,
refer to:
DONE Output BOOL I, Q, M, D, L Status parameter
0: Job not yet started or still executing.
1: Job executed without errors.
BUSY Output BOOL I, Q, M, D, L Status parameter
0: The instruction is not executed.
1: The instruction is executed.
ERROR Output BOOL I, Q, M, D, L Status parameter
0: Neither warning nor error.
1: An error has occurred. STATUS
supplies detailed information on the type of
error.
STATUS Output WORD I, Q, M, D, L Status parameter
See the "STATUS" parameter table.
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
STATUS parameter
Error code*
(W#16#...)
Explanation
0 No error occurred
8090 The file name contains invalid characters.
8092 No matching CSV file found for the import. Possible cause: The name of the CSV file does not match the
name of the recipe DB.
80C0 CSV file is temporarily locked.
80C1 Data block is temporarily locked.
80B0 Numbering in the index of the CSV file is not continuous, not ascending or exceeds the maximum number
(array limit) in the data block.
80B1 Structure of the recipe data block and the CSV file do not match: The CSV file contains too many fields.
80B2 Structure of the recipe data block and the CSV file do not match: The CSV file contains too few fields.
80D0 +n Structure of the recipe data block and the CSV file do not match: Data type in field n does not match (n<=46).
80FF Structure of the recipe data block and the CSV file do not match: Data type in field n does not match (n>46).
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2225
Structure of a recipe DB
Introduction
The following sections describes the structure of a recipe DB based on a simple example. The
recipe DB consists of five data records, three of which are used. The fourth and fifth data
records are left free for later expansions. Each data record contains one recipe, which is made
up of the recipe name and eight ingredients.
product
name
water barley wheat hops yeast waterT
mp
mashT
mp
mashTi
me
QTest
Pils 10 9 3 280 39 40 30 100 0
Lager 10 9 3 150 33 50 30 120 0
BlackBe
er
10 9 3 410 47 60 30 90 1
Not_use
d
0 0 0 0 0 0 0 0 0
Not_use
d
0 0 0 0 0 0 0 0 0
Structure of the recipe data block
The recipe data are implemented as follows in a global data block:
The template for all recipes is the PLC data type "Beer_Recipe" with the recipe components
"procutname", "water", etc. with the corresponding data types.
In a global data block, the PLC data type is used as Array [1.. 5] of "Beer_Recipe". The
array limits (1 to 5 in this case) indicate the maximum number of recipes that the DB may
contain.
The values for the recipe components are added as start value in the data block.
The global DB is interconnected with the instruction via the InOut parameter RECIPE_DB.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2226 System Manual, 01/2013,
Exporting to CSV file
After the execution of the "RecipeExport (Page 2223)" instruction the data of the DB are written
to a CSV file with the following structure:
Recipe_DB.csv
index,productname,water,barley,wheat,hops,yeast,waterTmp,mashTmp,mashTime,QTest
1,Pils,10,9,3,280,39,40,30,100,0
2,Lager,10,9,3,150,33,50,30,120,0
3,BlackBeer,10,9,3,410,47,60,30,90,1
4,Not_used,0,0,0,0,0,0,0,0,0
5,Not_used,0,0,0,0,0,0,0,0,0
The CSV file can be uploaded to the PC/programming device by means of the Web browser
and edited:
If the data are to be reloaded in the DB, not changes may be made to the structure (for
example, by adding ingredients in a new column).
If you add data records to the file, make sure when importing into the data block that the
array limits through which you specify the maximum number of data records correspond to
at least the number of data records.
An index is automatically generated during export to the CSV file. If you create additional
data records, add consecutive index numbers accordingly.
After editing, the modified file can be reloaded in the CPU. The original CSV file is overwritten
in the process. You can use the "RecipeImport (Page 2224)" instruction to re-import the
modified data from the CSV file into the data block.
Display in Excel
The CSV file can be opened in Excel to make reading and editing easier. If the commas are
not recognized as decimal separators, use the Excel import function to output the data in
structured form.
Data logging
Data logging - Overview
Saving process values
The data logging instructions are used in the user program to save process values to data
logs. Data logs can be saved on the Memory Card (MC) or in the internal load memory. The
data logs are saved in CSV format (Comma Separated Value).
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2227
The data logging instructions are used in your program to create or open a data log, to write
an entry and to close the data log file.
You decide by the creation of the data buffer which program values are stored in the data log
during the creation of the data buffer. The data buffer is used as a memory for new data log
entries. New values have to be written to the buffer before "DataLogWrite (Page 2238)" is
called. During execution of the "DataLogWrite (Page 2238)" instruction, data is written from
the buffer to a data log record.
Webbrowser
Data logs
CPU
PLC
DATA
Process values
Memory
card
csv
Web server
Download
Data log
instructions
Data log files can be copied to the PC as follows:
If the PROFINET interface is connected to the PC, you use a Web browser to access the
data logs via the Web server. The CPU can be in RUN or STOP mode for this. If the CPU
is in "RUN" mode, the program continues running while the Web server is transferring data.
If there is a memory card in the CPU, you can remove this card and insert it into a standard
slot for SD (Secure Digital) cards or MMC (MultiMediaCard) cards on a PC or programming
device. Use File Manager to transfer the data log files from the memory card to the PC.
The CPU goes to "STOP" when you remove the memory card.
Properties of the data log
Writing of the data records of a data log is carried out in accordance with the principle of a ring
buffer. New data records are added until the maximum number of data records is reached
(RECORD parameter). The next data record then overwrites the "oldest" data record of the
data log.
If you want to prevent data records from being overwritten, use the "DataLogNewFile
(Page 2243)" instruction to create a new data log file based on the current data log. New data
records are then written into the new data log.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2228 System Manual, 01/2013,
Creating data logs
With the "DataLogCreate (Page 2230)" instruction, you can create a new data log file in the
""\DataLogs" directory of the load memory.
The name assigned at the NAME parameter is the designation for the data log and is also
used the file name for the CSV file. The file is stored in the directory "DataLogs".
The block parameter DATA specifies the data buffer for the new data log object and the
columns and data types in the data log. The columns and data types of a data record in
the data log are generated by the elements in the structure declaration or the array
declaration of this data buffer. Each element of a structure or of an array corresponds to a
column in a line in the data log.
You can use the HEADER block parameter to assign a header text in the header to each
column.
The "DataLogCreate (Page 2230)" instruction returns an ID. This ID is used by the other
data logging instructions as a reference for the created data log.
Opening data logs
You use the instructions "DataLogOpen" (S7-1200) and "DataLogTypedOpen" (S7-1500) to
open an existing data log on the memory card. A data log must be open before you can write
new data records to it.
The data log opens automatically when you execute the instructions "DataLogCreate
(Page 2230)" and "DataLogNewFile (Page 2243)".
Up to 10 data logs can be open simultaneously. You can select the data log to be opened
using the ID or name of the data log.
If you specify the ID and the name of the data log in the ID and NAME parameters,
respectively, the data log will be identified based on the ID. The data log name will not be
compared.
If you select the data log using the NAME parameter and no ID is specified, the ID will be
displayed in the ID parameter when the data log is opened.
If you select the data log using the ID parameter and no name is specified, the name will
be displayed in the NAME parameter when the data log is opened.
You use the MODE parameter to specify whether the data records of the data log are to be
deleted upon opening.
Writing to data logs
A data log must be open ("DataLogOpen (Page 2233)" instruction) before a data record can
be written to a data log. The "DataLogWrite (Page 2238)" instruction writes a data record to
the data log.
Closing data logs
You use the "DataLogClose (Page 2240)" instruction to close an open data log. You select the
data log using the ID parameter.
The data log is closed automatically when the CPU switches to STOP and upon restart.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2229
Deleting data logs
You use the instruction "DataLogDelete (Page 2241)" (S7-1500) to delete a data log file from
the memory card. The data log and the data records it contains can only be deleted if the log
was created with the instruction "DataLogCreate (Page 2230)".
Select the data log to be deleted using the NAME and ID parameters. The ID parameter is
evaluated first. If there is a data log with the relevant ID, the NAME parameter will not be
evaluated. If the value "0" is used at the ID parameter, a value with the data type STRING
must be used at the NAME parameter.
Clearing data logs
You use the instruction "DataLogClear (Page 2237)" (S7-1500) to delete all the data records
in an existing data log. The instruction does not delete the optional header of the CSV file (see
the description of the HEADER parameter of the instruction "DataLogCreate (Page 2230)").
You use the ID parameter to select the data log whose data records are to be deleted. Before
you can delete data records, the data log must be open.
New file for data logs
You use the instruction "DataLogNewFile (Page 2243)" (S7-1200) or "DataLogTypedNewFile
(Page 2244)" (S7-1500) to create a new data log with the same properties as an existing data
log. This allows you to retain the contents of an existing data log.
When called, the instruction creates a new data log on the memory card or in the internal load
memory with the name defined at the NAME parameter. You use the ID parameter to specify
the ID of the old data log whose properties you want to apply to the new data log. The ID of
the new data log is then output via the ID parameter.
You specify the file size of the new data log with the RECORDS parameter of the instruction.
You can run a consistency check for "DataLogTypedNewFile (Page 2244)" (S7-1500).
DataLogCreate: Create data log
Description
You use the "DataLogCreate" instruction to create a data log. The data log is saved to the
memory card / the internal load memory in the "\DataLogs" folder. You can use the data logging
instructions to save the process data. The amount of data that can be stored in a data log
depends on the memory space available on the memory card or the available internal load
memory of the CPU used.
You specify the maximum number of data records that can be stored in a data log in the
RECORDS parameter. If the specified maximum number of data records in the data log is
reached, the oldest data record will be overwritten. To avoid overwriting of existing data
records, use the "DataLogNewFile (Page 2243)" instruction. The instruction can be used to
create a new data log with the same structure when the number specified at the RECORDS
parameter is reached (return value 1 at the STATUS parameter of the "DataLogWrite
(Page 2238)" instruction). The data records are then saved in the new data log.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2230 System Manual, 01/2013,
You can specify the name for the data log in the NAME parameter. The data log is created in
CSV (Comma Separated Value) format. With the HEADER parameter, you can create an
(optional) header for the data log. A comma has to be used as the separator.
Once the data log is created, it is opened automatically.
Parameter
The following table shows the parameters of the "DataLogCreate" instruction:
Parameter Declaration Data type Memory area Description
REQ Input BOOL I, Q, M, L, D, T, C or
constant
Execution of the instruction upon a rising edge.
RECORDS Input UDInt I, Q, M, L, D or
constant
Number of data records in the data log
FORMAT Input UInt I, Q, M, L, D or
constant
Data format:
0: Internal (not supported)
1: CSV (Comma separated values)
TIMESTAMP Input UInt I, Q, M, L, D or
constant
Time stamp:
0: No time stamp
1: Date and time
With the time stamp, an additional header is not
required for the data log.
NAME Input VARIANT I, Q, M, L, D Name of the data log. The specified name is also
used as a file name for the csv file.
The restrictions for Windows file names apply when
assigning the name. The following characters must
not be used:
"\", "/", ":", "*", "?", "<", ">", "|", "space"
ID InOut DWORD I, Q, M, L, D Object ID of the data log (output only). The ID of the
data log is required for the additional data logging
instructions.
HEADER InOut VARIANT I, Q, M, L, D Header of the CSV file (optional). The parameter is
hidden once the instruction has been inserted.
DATA InOut VARIANT I, Q, M, L, D Data buffer for a data log data record.
DONE Output BOOL I, Q, M, L, D The instruction was executed successfully.
BUSY Output BOOL I, Q, M, L, D Creation of the data log is not yet complete.
ERROR Output BOOL I, Q, M, L, D 0: No error.
1: An error occurred during execution of the
instruction.
Detailed information is output via the STATUS
parameter.
STATUS Output WORD I, Q, M, L, D Status parameter
The parameter is only set for the duration of one
call. To display the status, you should therefore
copy the STATUS parameter to a free data area.
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2231
Parameter HEADER
The HEADER parameter is a VARIANT pointer to a data block that defines a header for the
CSV file (header). The header is always the first line in the CSV file representation. When
creating a header, remember that the individual columns must be separated by a comma
(S7-1200) or a semicolon (S7-1500). A STRING, Array of BYTE, or Array of CHAR data type
can be used for the individual column names. A longer character string is possible with the
Array [...] of type data type than with the STRING data type. When the STRING data type is
used, the length is limited to 254 bytes.
If no header is to be created, do not specify a value in the HEADER parameter.
Parameter DATA
The DATA parameter is a VARIANT pointer to a structure or an array in a data block. An
element of a structure or an array corresponds to a column in the data log with a specific data
type.
Note the following when creating the data block:
The number of columns must correspond to the number of columns defined in the HEADER
parameter.
If the STRUCT data type is used, structure nestings (STRUCT in STRUCT) may not be
used.
Arrays (only 1-dimensional) can be configured as a single element or as a structure
component. Each element in the array generates a separate column in the data log.
The tags of the data block can be set as retentive or non-retentive tags. However, the
retentive setting must be the same for all tags of the data block.
STATUS (S7-1200) parameter
Error code*
(W#16#...)
Description
0 No errors.
7000 No job processing active.
7001 Start of job processing. Parameter BUSY = 1, DONE = 0
7002 Intermediate call (REQ
irrelevant): Instruction already active; BUSY has the value "1".
8070 Complete internal instance memory is assigned.
8090 Invalid file name (see description of the NAME parameter).
8093 Data log already exists.
8097 File length exceeds the file system limit.
80B3 Load memory not sufficient.
80B4 Memory card is write-protected.
80C1 Too many files open.
8453 Invalid format selection.
8553 Invalid time stamp.
8B51 Invalid data type at HEADER parameter.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2232 System Manual, 01/2013,
Error code*
(W#16#...)
Description
8C20 String with length specification other than 254 used.
8C51 Invalid data type at DATA parameter.
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
STATUS (S7-1500) parameter
Error code*
(W#16#...)
Description
0 No errors.
7000 No job processing active.
7001 Start of job processing. Parameter BUSY = 1, DONE = 0
8070 Complete internal instance memory is assigned.
8090 Invalid file name (see description of the NAME parameter).
8091 "NAME" parameter is not a string.
8093 Data log already exists.
8097 File length exceeds the file system limit.
80B3 Load memory not sufficient.
80B4 Memory card is write-protected.
80C0 Access currently not possible.
80C1 Too many files open.
8253 Invalid value at RECORDS parameter.
8353 Invalid format selection.
8453 Invalid time stamp.
8B51 Invalid data type at HEADER parameter.
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
See also
Data logging - Overview (Page 2227)
DataLogOpen: Open data log
DataLogOpen: Open data log
Description
You use the "DataLogOpen" instruction to open an existing data log on the memory card. A
data log must be open before you can write new data records to it.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2233
Data log opens automatically when you execute the instructions "DataLogCreate (Page 2230)"
and "DataLogNewFile (Page 2243)".
Up to 10 data logs can be open simultaneously. You can select the data log to be opened
using the ID or name of the data log.
If you specify the ID and the name of the data log in the ID and NAME parameters,
respectively, the data log will be identified based on the ID. The data log name will not be
compared.
If you select the data log using the NAME parameter and no ID is specified, the ID will be
displayed in the ID parameter when the data log is opened.
If you select the data log using the ID parameter and no name is specified, the name will
be displayed in the NAME parameter when the data log is opened.
You use the MODE parameter to specify whether the data records of the data log are to be
deleted upon opening.
Parameter
The following table shows the parameters of the "DataLogOpen" instruction:
Parameter Declaration Data type Memory area Description
REQ Input BOOL I, Q, M, L, D, T, C or
constant
Execution of the instruction upon a rising edge.
MODE Input UInt I, Q, M, L, D or
constant
Mode for opening the data log:
MODE= "0"
Data records of the data log are retained
MODE= "1"
Data records of the data log are deleted, but the
header is retained
NAME Input VARIANT I, Q, M, L, D (File) name of the data log.
ID InOut DWORD I, Q, M, L, D Object ID of the data log.
DONE Output BOOL I, Q, M, L, D Instruction was executed successfully.
BUSY Output BOOL I, Q, M, L, D Execution of instruction not yet complete.
ERROR Output BOOL I, Q, M, L, D 0: No error.
1: An error occurred during execution of the
instruction.
Detailed information is output via the STATUS
parameter.
STATUS Output WORD I, Q, M, L, D Status parameter
The parameter is only set for the duration of one
call. To display the status, you should therefore
copy the STATUS parameter to a free data area.
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2234 System Manual, 01/2013,
STATUS parameter
Error code*
(W#16#...)
Description
0 No errors.
2 Warning: Data log file has already been opened by this application.
7000 No job processing active.
7001 Start of job processing. Parameter BUSY = 1, DONE = 0
7002 Intermediate call (REQ
irrelevant): Instruction already active; BUSY has the value "1".
8070 Complete internal instance memory is assigned.
8090 There are inconsistencies between the data log definition and existing data log data.
8091 A data type other than String was used at the NAME parameter.
8092 Data log does not exist.
80B4 Memory card is write-protected.
80C0 The data log file is locked.
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
See also
Data logging - Overview (Page 2227)
DataLogOpen: Open data log
Description
You use the "DataLogTypedOpen" instruction to open an existing data log on the memory
card. A data log must be open before you can write new data records to it.
Data log opens automatically when you execute the instructions "DataLogCreate (Page 2230)"
and "DataLogNewFile (Page 2243)".
Up to 10 data logs can be open simultaneously. You can select the data log to be opened
using the ID or name of the data log.
If you specify the ID and the name of the data log in the ID and NAME parameters,
respectively, the data log will be identified based on the ID. The data log name will not be
compared.
If you select the data log using the NAME parameter and no ID is specified, the ID will be
displayed in the ID parameter when the data log is opened.
If you select the data log using the ID parameter and no name is specified, the name will
be displayed in the NAME parameter when the data log is opened.
You use the MODE parameter to specify whether the data records of the data log are to be
deleted upon opening.
You can check consistency between the data log definition and existing data log files with the
DATA parameter.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2235
Parameter
The following table shows the parameters of the "DataLogTypedOpen" instruction:
Parameter Declaration Data type Memory area Description
REQ Input BOOL I, Q, M, L, D, T, C or
constant
Execution of the instruction upon a rising edge.
MODE Input UInt I, Q, M, L, D or
constant
Mode for opening the data log:
MODE= "0"
Data records of the data log are retained
MODE= "1"
Data records of the data log are deleted, but the
header is retained
NAME Input VARIANT I, Q, M, L, D (File) name of the data log.
ID InOut DWORD I, Q, M, L, D Object ID of the data log.
DATA InOut VARIANT I, Q, M, L, D Data type for consistency check
DONE Output BOOL I, Q, M, L, D Instruction was executed successfully.
BUSY Output BOOL I, Q, M, L, D Execution of instruction not yet complete.
ERROR Output BOOL I, Q, M, L, D 0: No error.
1: An error occurred during execution of the
instruction.
Detailed information is output via the STATUS
parameter.
STATUS Output WORD I, Q, M, L, D Status parameter
The parameter is only set for the duration of one
call. To display the status, you should therefore
copy the STATUS parameter to a free data area.
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
STATUS parameter
Error code*
(W#16#...)
Description
0 No errors.
2 Warning: Data log file has already been opened by this application.
7000 No job processing active.
7001 Start of job processing. Parameter BUSY = 1, DONE = 0
8070 Complete internal instance memory is assigned.
8090 There are inconsistencies between the data log definition and existing data log data.
8091 A data type other than String was used at the NAME parameter.
8092 Data log does not exist.
80B4 Memory card is write-protected.
80C1 Too many files open.
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2236 System Manual, 01/2013,
See also
Data logging - Overview (Page 2227)
DataLogClear: Empty data log
Description
The "DataLogClear" instruction deletes all data records in an existing data log. The instruction
does not delete the optional header of the CSV file (see the description of the HEADER
parameter of the instruction "DataLogCreate (Page 2230)").
You use the ID parameter to select the data log whose data records are to be deleted.
Requirement
Before you can delete data records, the data log must be open (see "DataLogOpen
(Page 2233) instruction").
Parameter
The following table shows the parameters of the "DataLogClear" instruction:
Parameter Declaration Data type Memory area Description
REQ Input BOOL I, Q, M, L, D, T, C or
constant
Execution of the instruction upon a rising edge.
ID InOut DWORD I, Q, M, D, L Object ID of the data log
DONE Output BOOL I, Q, M, D, L Instruction was executed successfully.
BUSY Output BOOL I, Q, M, D, L 0: Deletion of the data log is not yet
complete / has not yet been started.
1: Deleting of the data log has been
completed.
ERROR Output BOOL I, Q, M, D, L 0: No error.
1: An error occurred during execution of the
instruction.
Detailed information is output at the STATUS
parameter.
STATUS Output WORD I, Q, M, D, L Status parameter
The parameter is only set for the duration of
one call. To display the status, you should
therefore copy the STATUS parameter to a
free data area.
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2237
STATUS parameter
Error code*
(W#16#...)
Explanation
0000 No error.
0700 No job processing active.
7001 Start of job processing. Parameter BUSY = 1, DONE = 0
8080 Data log file does not correspond to instruction.
8092 Data log does not exist.
80B0 Data log is not open.
80B4 The memory card is write-protected.
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
See also
Data logging - Overview (Page 2227)
DataLogWrite: Write data log
Description
The instruction "DataLogWrite" is used to write a data record to an existing data log. The ID
parameter is used to select the data log to which the data record is to be written. To create a
new data record, the data log must be open. The instruction creates a new data record in the
format that was specified in the DATA parameter when the data log was created.
Before calling the "DataLogWrite" instruction transfer the data to the variable that you
interconnected at the DATA parameter of the "DataLogCreate" instruction. When the
"DataLogWrite" instruction is executed, the transferred data are copied to the data log.
NOTICE
Data log data loss when the power supply to the CPU is interrupted
If the power supply is interrupted during execution of the "DataLogWrite" instruction, the data
record to be transferred is lost.
Parameter
The following table shows the parameters of the "DataLogWrite" instruction:
Parameter Declaration Data type Memory area Description
REQ Input BOOL I, Q, M, L, D, T, C or
constant
Execution of the instruction upon a rising edge.
ID InOut DWORD I, Q, M, L, D Object ID of the data log
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2238 System Manual, 01/2013,
Parameter Declaration Data type Memory area Description
DONE Output BOOL I, Q, M, L, D Instruction was executed successfully.
BUSY Output BOOL I, Q, M, L, D Execution of the instruction not yet complete.
ERROR Output BOOL I, Q, M, L, D 0: No error.
1: An error occurred during execution of the
instruction.
Detailed information is output via the STATUS
parameter.
STATUS Output WORD I, Q, M, L, D Status parameter
The parameter is only set for the duration of one
call. To display the status, you should therefore
copy the STATUS parameter to a free data area.
For additional information on valid data types, refer to "Overview of the valid data types
(Page 899)".
STATUS (S7-1200) parameter
Error code*
(W#16#...)
Description
0 No errors
0001 Last possible data record created at the end of the file. Creating another data record will overwrite an
older data record.
7000 No job processing active.
7001 Start of job processing. Parameter BUSY = 1, DONE = 0
7002 Intermediate call (REQ
irrelevant): Instruction already active; BUSY has the value "1".
8070 Complete internal instance memory is assigned.
8092 Data log does not exist.
80B0 Data log is not open.
80B4 Memory card is write-protected.
80C0 Data log file is locked.
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
STATUS (S7-1500) parameter
Error code*
(W#16#...)
Description
0 No errors
0001 Last possible data record created at the end of the file. Creating another data record will overwrite an
older data record.
7000 No job processing active.
7001 Start of job processing. Parameter BUSY = 1, DONE = 0
8070 Complete internal instance memory is assigned.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2239
Error code*
(W#16#...)
Description
8092 Data log does not exist.
80B0 Data log is not open.
80B4 Memory card is write-protected.
80C0 Data log file is locked.
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
See also
Data logging - Overview (Page 2227)
DataLogClose: Close data log
Description
You use the "DataLogClose" instruction to close an open data log. You select the data log
using the ID parameter.
Note
Closing data logs automatically
The data log is closed automatically when the CPU goes to STOP or if there is a restart.
Parameter
The following table shows the parameters of the "DataLogClose" instruction:
Parameter Declaration Data type Memory area Description
REQ Input BOOL I, Q, M, L, D, T, C or
constant
Execute function on a rising edge.
ID InOut DWORD I, Q, M, L, D Object ID of the data log
DONE Output BOOL I, Q, M, L, D Instruction was executed successfully.
BUSY Output BOOL I, Q, M, L, D Execution of the instruction not yet complete.
ERROR Output BOOL I, Q, M, L, D 0: No error.
1: An error occurred during execution of the
instruction.
Detailed information is output via the STATUS
parameter.
STATUS Output WORD I, Q, M, L, D Status parameter
The parameter is only set for the duration of one
call. To display the status, you should therefore
copy the STATUS parameter to a free data area.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2240 System Manual, 01/2013,
For additional information on valid data types, refer to "Overview of the valid data types
(Page 899)".
STATUS (S7-1200) parameter
Error code*
(W#16#...)
Description
0 No errors
1 Data log is not open
7000 No job processing active.
7001 Start of job processing. Parameter BUSY = 1, DONE = 0
7002 Intermediate call (REQ
irrelevant): Instruction already active; BUSY has the value "1".
8092 Data log does not exist.
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
STATUS (S7-1500) parameter
Error code*
(W#16#...)
Description
0 No errors
1 Data log is not open
7000 No job processing active.
7001 Start of job processing. Parameter BUSY = 1, DONE = 0
8092 Data log does not exist.
80B4 Memory card is write-protected.
80C0 Access currently not possible.
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
DataLogDelete: Delete data log
Description
You use the "DataLogDelete" instruction to delete a data log file from the memory card. The
data log and the data records it contains can only be deleted if the log was created with the
instruction "DataLogCreate (Page 2230)".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2241
Parameter
The following table shows the parameters of the "DataLogDelete" instruction:
Parameter Declaration Data type Memory area Description
REQ Input BOOL I, Q, M, L, D, T, C or
constant
Execution of the instruction upon a rising edge.
NAME Input VARIANT D File name of the data log
DELFILE Input BOOL I, Q, M, D, L 0: Data log is retained.
1: Data log is deleted.
Detailed information is output at the STATUS
parameter.
ID InOut DWORD I, Q, M, D, L Object ID of the data log
DONE Output BOOL I, Q, M, D, L Instruction was executed successfully.
BUSY Output BOOL I, Q, M, D, L Deletion of the data log is not yet complete.
ERROR Output BOOL I, Q, M, D, L 0: No error.
1: An error occurred during execution of the
instruction.
Detailed information is output at the STATUS
parameter.
STATUS Output WORD I, Q, M, D, L Status parameter
The parameter is only set for the duration of
one call. To display the status, you should
therefore copy the STATUS parameter to a
free data area.
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
Parameters NAME and ID
Select the data log to be deleted using the NAME and ID parameters. The ID parameter is
evaluated first. If there is a data log with the relevant ID, the NAME parameter will not be
evaluated. If the value "0" is used at the ID parameter, a value with the data type STRING
must be used at the NAME parameter.
RET_VAL parameter
Error code*
(W#16#...)
Explanation
0 No error.
7000 No job processing active.
7001 Start of job processing. Parameter BUSY = 1, DONE = 0
8091 A data type other than STRING is being used at the NAME parameter.
8092 Data log does not exist.
80A2 Write error
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2242 System Manual, 01/2013,
Error code*
(W#16#...)
Explanation
80B4 The memory card is write-protected.
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
DataLogNewFile: Data log in new file
DataLogNewFile: Data log in new file
Description
You use the "DataLogNewFile" instruction to create a new data log with the same properties
as an existing data log. This allows the contents of an existing data log to be retained.
When called, the instruction creates a new data log on the memory card or in the internal load
memory with the name defined at the NAME parameter. You use the ID parameter to specify
the ID of the old data log whose properties you want to apply to the new data log. The ID of
the new data log is then output via the ID parameter.
You specify the file size of the new data log with the RECORDS parameter of the instruction.
Parameter
The following table shows the parameters of the "DataLogNewFile" instruction:
Parameter Declaration Data type Memory area Description
REQ Input BOOL I, Q, M, L, D, T, C or
constant
Execution of the instruction upon a rising edge.
RECORDS Input UDInt I, Q, M, L, D or
constant
Number of data records in the data log.
NAME Input VARIANT I, Q, M, L, D File name of the new data log.
ID InOut DWORD I, Q, M, L, D Object ID of the data log
In: ID of the existing data log
Out: ID of the new data log
DONE Output BOOL I, Q, M, L, D Instruction was executed successfully.
BUSY Output BOOL I, Q, M, L, D Execution of the instruction not yet complete.
ERROR Output BOOL I, Q, M, L, D 0: No error.
1: An error occurred during execution of the
instruction.
Detailed information is output via the STATUS
parameter.
STATUS Output WORD I, Q, M, L, D Status parameter
The parameter is only set for the duration of one call.
To display the status, you should therefore copy the
STATUS parameter to a free data area.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2243
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
STATUS parameter
Error code*
(W#16#...)
Description
0 No errors.
7000 No job processing active.
7001 Start of job processing. Parameter BUSY = 1, DONE = 0
7002 Intermediate call (REQ
irrelevant): Instruction already active; BUSY has the value "1".
8070 Complete internal instance memory is assigned.
8090 Invalid file name.
8091 Path does not exist.
8092 Source data log does not exist.
8093 New data log already exists.
8097 File length exceeds the file system limit.
80B3 Load memory not sufficient.
80B4 The memory card is write-protected.
80C1 Too many files open.
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
DataLogNewFile: Data log in new file
Description
You use the "DataLogTypedNewFile" instruction to create a new data log with the same
properties as an existing data log. This allows the contents of an existing data log to be retained.
When called, the instruction creates a new data log on the memory card or in the internal load
memory with the name defined at the NAME parameter. You use the ID parameter to specify
the ID of the old data log whose properties you want to apply to the new data log. The ID of
the new data log is then output via the ID parameter.
You specify the file size of the new data log with the RECORDS parameter of the instruction.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2244 System Manual, 01/2013,
Parameter
The following table shows the parameters of the "DataLogTypedNewFile" instruction:
Parameter Declaration Data type Memory area Description
REQ Input BOOL I, Q, M, L, D, T, C or
constant
Execution of the instruction upon a rising edge.
RECORDS Input UDInt I, Q, M, L, D or
constant
Number of data records in the data log.
NAME InOut VARIANT I, Q, M, L, D File name of the new data log.
ID InOut DWORD I, Q, M, L, D Object ID of the data log
In: ID of the existing data log
Out: ID of the new data log
DATA InOut VARIANT I, Q, M, L, D Data type for consistency check
DONE Output BOOL I, Q, M, L, D Instruction was executed successfully.
BUSY Output BOOL I, Q, M, L, D Execution of the instruction not yet complete.
ERROR Output BOOL I, Q, M, L, D 0: No error.
1: An error occurred during execution of the
instruction.
Detailed information is output via the STATUS
parameter.
STATUS Output WORD I, Q, M, L, D Status parameter
The parameter is only set for the duration of one call.
To display the status, you should therefore copy the
STATUS parameter to a free data area.
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
STATUS parameter
Error code*
(W#16#...)
Description
0 No errors.
7000 No job processing active.
7001 Start of job processing. Parameter BUSY = 1, DONE = 0
7002 Intermediate call (REQ
irrelevant): Instruction already active; BUSY has the value "1".
8070 Complete internal instance memory is assigned.
8090 Invalid file name.
8091 Path does not exist.
8092 Source data log does not exist.
8093 New data log already exists.
8097 File length exceeds the file system limit.
80A0 Data types inconsistent
80B3 Load memory not sufficient.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2245
Error code*
(W#16#...)
Description
80B4 Memory card is write-protected.
80C0 Access currently not possible.
80C1 Too many files open.
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
9.8.3.8 Data block functions
CREATE_DB: Create data block
Description
The instruction "CREATE_DB" is used to create a new data block in the load and/or work
memory.
The instruction "CREATE_DB" does not change the checksum of the user program.
Number of the data block
The data block created is assigned a number from the range defined at the LOW_LIMIT (low
limit) and UP_LIMIT (high limit) parameters. "CREATE_DB" assigns the smallest possible
number from the specified range to the DB. You cannot assign the numbers of the DBs already
contained in the user program.
To create a DB with a specific number, enter the same number for the high and low limit of the
range to be specified. If a DB with the same number already exists in the work memory and/
or load memory, or if the DB exists as a copied version, the instruction will be terminated and
an error message will be generated at the RET_VAL parameter.
Start values of the data block
Using the SRCBLK parameter, you can define start values for the DB to be created. The
SRCBLK parameter is a pointer to a DB or a DB area from which you apply the start values.
The DB addressed at the SRCBLK parameter must have been generated with standard access
("Optimized block access" attribute disabled).
If the area specified at the SRCBLK parameter is larger than the DB generated, the values
up to the length of the DB generated will be applied as start values.
If the area specified at the SRCBLK parameter is smaller than the DB generated, the
remaining values will be filled with "0".
To ensure data consistency, you must not change this data area while "CREATE_DB" is being
executed (which means as long as the BUSY parameter has the value TRUE).
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2246 System Manual, 01/2013,
Parameter
The following table shows the parameters of the instruction "CREATE_DB":
Parameter Declaration Data type Description
REQ Input BOOL REQ= 1: Request to create the DB
LOW_LIMIT Input UINT Low limit of the area ### used by "CREATE_DB" to assign a number
to your DB 60000)
UP_LIMIT Input UINT High limit of the area ### used by "CREATE_DB" to assign a
number to your DB (largest possible DB number: 60999)
COUNT Input UDINT The count value specifies the number of bytes which you want to
reserve for the DB generated. The number of bytes must be an even
number. The maximum length is 65534 bytes.
ATTRIB Input BYTE The first 4 bits of the byte at the ATTRIB parameter define the
properties of the data block:
Bit 0 = 0: DB only in the work memory
Bit 0 = 1: DB only in the load memory
Bit 1 = 0: DB is not write-protected.
Bit 1 = 1: DB is write-protected
Bit 2 = 0: DB is retentive (only for DBs generated in the load
memory)
Bit 2 = 1: DB is not retentive
Bit 3= 0: DB generated either in load or in work memory
Bit 3= 1: DB generated both in load and in work memory
To ensure compatibility with STEP7 V5.x, bits 1 and 3 must be used
in combination:
Bit0 Bit3 DB generation
0 0 In work memory only
1 0 In load memory only
0 1 Work and load memory
1 1 Work and load memory
Bit 4 = 0 - No start values specified (input values at the SRCBLK
parameter will be ignored).
Bit 4 = 1 - Specify start values (values correspond to the DB
addressed by the SRCBLK parameter).
SRCBLK Input VARIANT Pointer to the data block whose values will be used to initialize the
data block to be generated.
RET_VAL Return INT Error information
BUSY Output BOOL BUSY= 1: The process is not yet complete.
DB_NUM Output DB_DYN
(UINT)
Number of the DB created.
For additional information on valid data types, refer to "Overview of the valid data types
(Page 899)".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2247
RET_VAL parameter
Error code*
(W#16#...)
Description
0000 No error
0081 The target range is greater than the source range.
The complete source range is written to the target range. The remaining bytes of the target range are
filled with 0.
7000 First call with REQ=0: No data transfer active; BUSY has the value "0".
7001 First call with REQ=1: Data transfer triggered; BUSY has the value "1".
7002 Intermediate call (REQ
irrelevant): Data transfer already active; BUSY has the value "1".
8081 The source range is larger than the target range.
The complete target range is written. The remaining bytes of the source range are ignored.
8091 You have called "CREATE_DB" as a nested instruction.
8092 The "Create data block" function is currently unavailable because
The "Compress user memory" function is currently active.
The maximum number of blocks on your CPU has already been reached.
8093 No data block or a data block that is not in the work memory is specified for the SRCBLK parameter.
8094 A not yet supported attribute was specified for the ATTRIBparameter.
80A1 DB number error:
The number is "0"
Low limit > high limit
80A2 DB length error:
The length is "0"
The length is an odd number
The length is greater than permitted by the CPU
80A3 The data block at the SRCBLK parameter was not created with standard access.
80B1 There is no DB number free.
80B2 Not enough work memory.
80B4 The memory card is write-protected.
80BB Not enough load memory.
80C0 The destination is currently being processed by another instruction or a communication function.
80C1 A DB with this DB number is currently being deleted.
80C3 The maximum number of simultaneously active "CREATE_DB" instructions has already been reached.
8xyy General error codes, for example:
Source DB does not exist or it is only available as a copied version
Source range in DB does not exist
See Evaluating errors with the output parameter RET_VAL (Page 1422).
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2248 System Manual, 01/2013,
See also
Meaning of the parameters REQ, RET_VAL and BUSY with asynchronous instructions
(Page 1420)
READ_DBL: Read from data block in the load memory
Description
With the instruction you copy a DB or an area of a DB in load memory (Micro Memory Card)
to the data area of a destination DB. The destination DB must be relevant for execution; that
is, it must not be created with the attribute UNLINKED. The content of the load memory is not
changed during the copy process.
To ensure data consistency, you must not change the target range while "READ_DBL" is being
executed (i.e., as long as the BUSY parameter has the value TRUE).
The following restrictions apply to the SRCBLK and DSTBLK parameters (source and
destination blocks):
You must be able to divide the length of the VARIANT pointer by eight.
For a VARIANT pointer of type STRING, the length must be equal to 1.
The source and destination block must have been created with the same block access, i.e.
both must use either the access type "Optimized" or "Standard - compatible with
S7-300/400".
Note
""READ_DBL" is processed asynchronously. Therefore, it is not suitable for frequent (or
cyclical) reading of tags in the load memory.
Once started, a job is always completed. If the maximum number of simultaneously active
"READ_DBL" instructions is reached and you call "READ_DBL" once again at this time in
a priority class having higher priority, error code W#16#80C3 will be returned.
Consequently it does not make sense to restart the high-priority job right away.
Functional description
The "READ_DBL" instruction works asynchronously, that is, its execution extends over multiple
calls. You start the job by calling "READ_DBL" with REQ = 1.
The output parameters RET_VAL and BUSY indicate the status of the job.
See also: Meaning of the parameters REQ, RET_VAL and BUSY with asynchronous
instructions (Page 1420)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2249
Parameter
The following table shows the parameters of the instruction "READ_DBL":
Parameter Declaration Data type Memory area Description
REQ Input BOOL I, Q, M, D, L or
constant
REQ = 1: Read request
SRCBLK Input VARIANT D Pointer to data block in the load memory that
is to be read from
RET_VAL Return INT I, Q, M, D, L Error information
BUSY Output BOOL I, Q, M, D, L BUSY = 1: The reading process is not yet
complete.
DSTBLK Output VARIANT D Pointer to the data block in the work memory
that is to be written to
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
RET_VAL parameter
Error code*
(W#16#...)
Description
0000 No error
0081 The target range is greater than the source range. The source range is written completely to the target
range; the remaining bytes of the target range will not be changed.
7000 First call with REQ=0: No data transfer active; BUSY has the value "0".
7001 First call with REQ=1: Data transfer triggered; BUSY has the value "1".
7002 Intermediate call (REQ
irrelevant): Data transfer already active; BUSY has the value "1".
8081 The source range is larger than the target range.
The complete target range is written. The remaining bytes of the source range are ignored.
8082 Destination DB type different from source DB type (optimized/non-optimized access).
8093 No data block or a data block that is not in the work memory is specified for the DSTBLK parameter.
80B1 No data block is specified for the SRCBLK parameter, or the data block specified there is not a load
memory object.
80B4 DB with F-attribute must not be read.
80C3 The maximum number of simultaneously active "READ_DBL" instructions has already been reached.
80C0 The destination DB is currently being processed by another instruction or a communication function.
8xyy General error codes
See also: Getting error ID locally with GetErrorID (Page 2030)
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2250 System Manual, 01/2013,
WRIT_DBL: Write to data block in the load memory
Description
The instruction "WRIT_DBL" is used to transfer the contents of a DB or a DB area from the
work memory to a DB or a DB area in the load memory (Micro Memory Card). The source DB
must be relevant for execution, which means it must not be created with the attribute
UNLINKED.
To ensure data consistency, it is not permitted to change the source range while "WRIT_DBL"
is being executed (i.e., as long as the BUSY parameter has the value TRUE).
The following restrictions apply to the SRCBLK and DSTBLK parameters (source and
destination blocks):
For a VARIANT pointer of type BOOL, the length must be divisible by 8.
For a VARIANT pointer of type STRING, the length must be equal to 1.
The source and destination block must have been created with the same block access,
i.e. both must use either the access type "Optimized" or "Standard - compatible with
S7-300/400".
The "WRIT_DBL" instruction does not change the checksum of the user program if you write
a DB that was created using an instruction. However, when a loaded DB is written, the first
entry in this DB changes the checksum of the user program.
Note
"WRIT_DBL" is not suitable for frequent (or cyclical) writing of tags in the load memory. This
is because the Micro Memory Card technology limits the number of write accesses that can
be made to a Micro Memory Card.
Functional description
The "WRIT_DBL" instruction works asynchronously, that is, its execution extends over multiple
calls. You start the job by calling "WRIT_DBL" with REQ=1.
The output parameters RET_VAL and BUSY indicate the status of the job.
See also: Meaning of the parameters REQ, RET_VAL and BUSY with asynchronous
instructions (Page 1420).
Parameter
The following table shows the parameters of the instruction "WRIT_DBL":
Parameter Declaration Data type Memory area Description
REQ Input BOOL I, Q, M, D, L or
constant
REQ = 1: Write request
SRCBLK Input VARIANT D Pointer to the DB in the work memory that is
to be read from
RET_VAL Return INT I, Q, M, D, L Error information
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2251
Parameter Declaration Data type Memory area Description
BUSY Output BOOL I, Q, M, D, L BUSY= 1: The writing process is not yet
completed.
DSTBLK Output VARIANT D Pointer to the data block in the load memory
that is to be written to
For additional information on valid data types, refer to "Overview of the valid data types
(Page 899)".
RET_VAL parameter
Error code*
(W#16#...)
Description
0000 No error
0081 The target range is greater than the source range. The source range is written completely to the target
range; the remaining bytes of the target range will not be changed.
7000 First call with REQ=0: No data transfer active; BUSY has the value "0".
7001 First call with REQ=1: Data transfer triggered; BUSY has the value "1".
7002 Intermediate call (REQ
irrelevant): Data transfer already active; BUSY has the value "1".
8081 The source range is larger than the target range.
The complete target range is written. The remaining bytes of the source range are ignored.
8082 Destination DB type different from source DB type (optimized/non-optimized access).
8092 Incorrect operating mode: While "WRIT_DBL" was active, the CPU went into STOP mode. This error code
is supplied at the next transition to RUN. Call "WRIT_DBL" again.
8093 No data block or a data block that is not in the work memory is specified for the SRCBLK parameter.
80B1 No data block has been specified for the DSTBLK parameter, or the data block specified there is not a
load memory object.
80B4 DB with F-attribute must not be read.
80C3 The maximum number of simultaneously active "WRIT_DBL" instructions has already been reached.
80C0 The destination DB is currently being processed by another instruction or a communication function.
8xyy General error codes
See also: Getting error ID locally with GetErrorID (Page 2030)
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
See also
Evaluating errors with output parameter RET_VAL (Page 1422)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2252 System Manual, 01/2013,
ATTR_DB: Read data block attribute
Description
You use the instruction "ATTR_DB" to obtain information about a data block located in the
work memory of the CPU. The instruction determines the attributes set at the ATTRIB
parameter for the DB selected.
The length cannot be read out for data blocks with optimized access, the DB_LENGH
parameter contains the length "0".
Data blocks for Motion Control cannot be read out with the "ATTR_DB" instruction. The error
code 80B2 is output for this.
Parameter
The following table shows the parameters of the "ATTR_DB" instruction:
Parameter Declaration Data type Description
REQ Input BOOL REQ = 1: Read request for block attributes
DB_NUMBER Input DB_ANY (UINT) Number of the DB to be tested
RET_VAL Output INT Error information
DB_LENGTH Output UDINT Number of data bytes which the selected DB
contains.
ATTRIB Output BYTE DB properties:
Bit 0*= 0: LINKED - The DB only exists in the work memory
Bit 0*= 1: UNLINKED - The DB only exists in the load memory
Bit 1 = 0: READ_ONLY - The DB is not write-protected.
Bit 1 = 1: READ_ONLY - The DB is write-protected.
Bit 2 = 0: RETAIN - The DB is retentive.
Bit 2 = 1: NON_RETAIN - The DB is not retentive.
Bit 3*= 0: The DB only exists in either the load or the work
memory
Bit 3*= 1: The DB only exists in the load and work memory
* The relationship between bit 0 and bit 3 is explained in the parameters of the instruction "CREATE_DB: Create data
block (Page 2246)".
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2253
RET_VAL parameter
Error code*
(W#16#...)
Explanation
0000 No error occurred.
80A1 Error in input parameter DB_NUMBER: the actual parameter selected
Is "0"
Is greater than the maximum permitted DB number for the CPU used.
80B1 The DB with the specified number does not exist on the CPU.
80B2 Data blocks of Motion Control technology objects cannot be read out with the "ATTR_DB" instruction.
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
DELETE_DB: Delete data block
Description
You use the instruction to delete a data block located in the work memory and, if present, in
the load memory of the CPU. The DB to be deleted must not be open in the current or in any
lower priority class, in other words, it must not be entered in either of the two DB registers or
in the B stack. Otherwise, the CPU starts OB 121 when the "DELETE_DB" instruction is called.
If OB 121 is not present, the CPU switches to STOP mode.
The instruction can only be used to delete data blocks which were created by the user program.
Programmed data blocks cannot be deleted (see error code 80B4 of the RET_VAL parameter).
Data blocks which were created by calling the instruction "CREATE_DB (Page 2246)" can be
deleted using "DELETE_DB".
Note
Deleting data blocks
Data blocks stored on the memory card cannot be deleted with "DELETE_DB".
Interrupt ability
The instruction "DELETE_DB" can be interrupted by higher priority classes. If the instruction
is called again there, then this second call will be aborted and W#16#8091 will be entered in
RET_VAL .
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2254 System Manual, 01/2013,
Parameter
The following table shows the parameters of the "DELETE_DB" instruction:
Parameter Declaration Data type Description
REQ Input BOOL REQ = 1: DB generation request
DB_NUMBER Input UINT Number of the DB to be
deleted
RET_VAL Output INT Error information
BUSY Output BOOL BUSY =1: The process is not yet complete.
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
RET_VAL parameter
Error code*
(W#16#...)
Explanation
0000 No error occurred.
8091 "DELETE_DB" calls were nested and the maximum nesting level of the CPU used was exceeded.
8092 The "Delete a DB" function cannot be executed currently because
The "Compress user memory" function is currently active.
You are copying the DB to be deleted from the CPU to an offline project.
The H-CPU is running link-up or update functions.
The WinAC software CPU has detected an error in the OS of the computer on which WinAC is
installed.
80A1 Error in input parameter DB_NUMBER: the actual parameter selected
Is "0"
Is greater than the maximum permitted DB number for the CPU used.
80B1 The DB with the specified number does not exist on the CPU.
80B4 The DB is on a flash card.
80B5 The DB was not generated using CREATE_DB .
80C1 The "Delete a DB" function cannot be executed at this time due to a temporary resource bottleneck.
8xyy General error information
See also: Getting error ID locally with GetErrorID (Page 2030)
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
See also
Evaluating errors with output parameter RET_VAL (Page 1422)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2255
9.8.3.9 Addressing
GEO2LOG: Determine logical address from geographical address
Description
You use the "LOG2GEO" instruction to determine the logical address based on slot information
that you define using the system data type GEOADDR.
Depending on the hardware type that you define at the HWTYPE parameter, the following
information is evaluated from the other parameters of GEOADDR:
With HWTYPE = 1 (PROFINET IO system):
Only IOSYSTEM is evaluated. The other parameters of GEOADDR are not taken into
consideration.
The hardware identifier of the PROFINET IO system is output.
With HWTYPE = 2 (PROFINET IO device):
IOSYSTEM and STATION are evaluated. The other parameters of GEOADDR are not
taken into consideration.
The hardware identifier of the PROFINET IO device is output.
With HWTYPE = 3 (rack):
Only IOSYSTEM and STATION are evaluated. The other parameters of GEOADDR are
not taken into consideration.
The hardware identifier of the rack is output.
With HWTYPE = 4 (module):
IOSYSTEM, STATION and SLOT are evaluated. The SUBSLOT parameter of
GEOADDR is not taken into consideration.
The hardware identifier of the module is output.
With HWTYPE = 5 (submodule):
All parameters of GEOADDR are evaluated.
The hardware identifier of the submodule is output.
The AREA parameter of the GEOADDR system data type is not evaluated.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2256 System Manual, 01/2013,
Parameter
The following table shows the parameters of the "GEO2LOG" instruction:
Parameter Declaration Data type Memory area Description
GEOADDR Input VARIANT D, L Pointer to the structure of the GEOADDR
system data type.
RET_VAL Return INT I, Q, M, D, L Output of error information.
LADDR Output HW_ANY I, Q, M, D, L Hardware identifier of the module or the
submodule.
The number is assigned automatically and is
stored in the properties of the CPU or of the
interface in the hardware configuration.
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
GEOADDR system data type
The GEOADDR system data type is a structure with the following configuration:
Parameter name Data type Description
GEOADDR STRUCT
HWTYPE UNIT Hardware type:
1: PROFINET IO system
2: PROFINET IO device
3: Rack
4: Module
5: Submodule
If a hardware type is not supported by the instruction, a HWTYPE "0" is output.
AREA UNIT Area identifier (0 = central module)
IOSYSTEM UNIT PROFINET IO system (0 = central device in rack 0-3)
STATION UNIT Number of the rack if the area identifier AREA = 0.
Station number if area identifier AREA > 0.
SLOT UNIT Slot number
SUBSLOT UNIT Number of the submodule. If no submodule can be inserted, this parameter has
the value "0".
RET_VAL parameter
Error code*
(W#16#...)
Explanation
0 No error occurred.
8091 Invalid value for in GEOADDR for HWTYPE.
8094 Invalid value for in GEOADDR for IOSYSTEM.
8095 Invalid value for in GEOADDR for STATION.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2257
Error code*
(W#16#...)
Explanation
8096 Invalid value for in GEOADDR for SLOT.
8097 Invalid value for in GEOADDR for SUBSLOT.
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
LOG2GEO: Determine geographical address from logical address
Description
You use the "LOG2GEO" instruction to determine the module slot belonging to a logical start
address.
Parameters
The following table shows the parameters of the "LOG2GEO" instruction:
Parameter Declaration Data type Memory area Description
LADDR Input HW_ANY I, Q, M, D, L or
constant
Identification number of the module or
submodule.
The number is assigned automatically and is
stored in the properties of the CPU or the
interface of the hardware configuration.
RET_VAL Output INT I, Q, M, D, L Output of error information.
GEOADDR InOut VARIANT D Pointer to the GEOADDR system data type.
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
GEOADDR system data type
The GEOADDR system data type is a structure with the following configuration:
Parameter name Data type Description
GEOADDR STRUCT
HWTYPE UNIT Hardware type:
1: PROFINET IO system
2: PROFINET IO device
3: Rack
4: Module
5: Submodule
If a hardware type is not supported by the instruction, a HWTYPE "0" is output.
AREA UNIT Area identifier (0 = central module)
IOSYSTEM UNIT PROFINET IO system (0 = central device in rack 0-3)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2258 System Manual, 01/2013,
Parameter name Data type Description
STATION UNIT Number of the rack if the area identifier AREA = 0.
Station number if area identifier AREA > 0.
SLOT UNIT Slot number
SUBSLOT UNIT Number of the submodule. If no submodule can be inserted, this parameter has
the value "0".
RET_VAL parameter
Error code*
(W#16#...)
Explanation
0 No error occurred.
8090 The address specified at the LADDR parameter is invalid.
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
LOG2MOD: Determine hardware ID from logical address
Description
You use the "LOG2MOD" instruction to determine the hardware identifier for an IO (sub)module
from the addressing of STEP 7 5.5 SPx (IO data address or diagnostic address).
The hardware identifier is used at the LADDR input parameter for addressing of various
instructions. You can convert the addressing parameters from STEP 7 5.5 SPx by calling
"LOG2MOD" beforehand.
Parameter
The following table shows the parameters of the "LOG2MOD" instruction:
Parameter Declaration Data type Memory area Description
IOID Input BYTE I, Q, M, D, L or
constant
Identifier of the address area as in STEP 7 5.5
SPx:
B#16#00: Bit15 of ADDR specifies whether
an input (Bit15=0) or output address
(Bit15=1) exists.
B#16#54= Peripheral input (PI)
B#16#55= Peripheral output (PQ)
ADDR Input WORD I, Q, M, D, L or
constant
Logical address of the IO data of the module
as offset (corresponding addressing in STEP
7 5.5 SPx) or diagnostic address.
RET_VAL Return INT I, Q, M, D, L Error code of the instruction.
HWID Output HW_IO I, Q, M, D, L Determined hardware identifier (logical
address) of the IO (sub)module.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2259
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
RET_VAL parameter
Error code*
(W#16#...)
Explanation
0 No error occurred.
8093 Specified address is not used by any hardware components.
Specified value at IOID parameter is invalid.
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
IO2MOD: Determine logical address from I/O address
Description
The "IO2MOD" instruction determines the hardware identifier of the module from an IO address
(I, Q, PI, PQ) of a (sub)module.
Enter the IO address at the ADDR parameter. If a series of IO addresses is used at this
parameter, only the first address is evaluated to determine the hardware identifier. If the first
address is correctly specified, the length for the address specification at the ADDR is of no
significance. If an address area is used that encompasses several modules or non-used
addresses, the hardware identifier of the first module can also be determined.
If no IO address of a sub(module) is specified at the ADDR parameter, the error code 8090 is
output at the RET_VAL parameter.
Parameter
The following table shows the parameters of the "IO2MOD" instruction:
Parameter Declaration Data type Memory area Description
ADDR Input VARIANT I, Q, M, D, L IO address (I, Q, PI, PQ) within a (sub)module.
RET_VAL Return INT I, Q, M, D, L Error code of the instruction.
LADDR Output HW_IO I, Q, M, D, L Determined hardware identifier (logical
address) of the IO (sub)module.
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2260 System Manual, 01/2013,
RET_VAL parameter
Error code*
(W#16#...)
Explanation
0 No error occurred.
8090 IO address specified at ADDR parameter is not used by any hardware component.
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
RD_ADDR: Determine module I/O addresses
Description
The "RD_ADDR" instruction determines the length and the start address of the inputs or
outputs based on the hardware identifier of a sub(module).
Use the LADDR parameter to select the input or output module based on the hardware
identifier.
The following output parameters are used depending on whether it is an input module or
output module:
In the case of an input module the determined values are output at the PIADDR and
PICOUNT parameters.
In the case of an output module the determined values are output at the PQADDR and
PQCOUNT parameters.
The PIADDR and PQADDR parameters each contain the start address of the I/O addresses
of the module.
The PICOUNT and PQCOUNT parameters each contain the number of bytes of the inputs
our outputs (1 byte for 8 inputs/outputs, 2 bytes for 16 inputs/outputs).
Parameter
The following table shows the parameters of the "RD_ADDR" instruction:
Parameter Declaration Data type Memory area Description
LADDR Input HW_IO I, Q, M, D, L or
constant
Hardware identifier of the (sub)module.
RET_VAL Return INT I, Q, M, D, L Error code of the instruction.
PIADDR Output UDINT I, Q, M, D, L Start address of the input module.
PICOUNT Output UINT I, Q, M, D, L Number of bytes of the inputs.
PQADDR Output UDINT I, Q, M, D, L Start address of the output module.
PQCOUNT Output UINT I, Q, M, D, L Number of bytes of the outputs.
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2261
RET_VAL parameter
Error code*
(W#16#...)
Explanation
0 No error occurred.
8090 Hardware identifier of the module at the LADDR parameter is invalid.
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
Other
GEO_LOG: Determine start address of a module
Description
The associated module slot of the module is known from the channel of a signal module. Use
the "GEO_LOG" instruction to determine the corresponding hardware identifier of the module
from this.
If you use the "GEO_LOG" instruction on power modules or modules with packed addresses
(ET 200S), then the diagnostics address will be returned.
Parameter
The following table shows the parameters of the instruction "GEO_LOG":
Parameter Declaration Data type Memory area Description
MASTER Input INT I, Q, M, D, L or
constant
Area ID:
0, if the slot is located in a centralized
configuration.
1 to 32: DP master system ID of the
associated field device if the slot is located
in a field device on PROFIBUS
100 to 115: PROFINET IO system ID of the
associated field device if the slot is located
in a field device on PROFINET
STATION Input INT I, Q, M, D, L or
constant
If MASTER = 0: Number of the rack
If MASTER > 0: Station number of the field
device
SLOT Input INT I, Q, M, D, L or
constant
Slot number
SUBSLOT Input INT I, Q, M, D, L or
constant
The SUBLOT parameter is not evaluated by
the instruction.
RET_VAL Return INT I, Q, M, D, L Error information
LADDR Output HW_IO I, Q, M, D, L Hardware identifier or diagnostic address of
the module
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2262 System Manual, 01/2013,
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
RET_VAL parameter
Error code*
(W#16#...)
Explanation
0000 No error occurred.
8094 No subnet was configured with the specified SUBNETID .
8095 Illegal value for STATION parameter
8096 Illegal value for SLOT parameter
8099 The slot is not configured.
809A The number is not configured for the selected slot.
8xyy General error information
See also: Evaluating errors with output parameter RET_VAL (Page 1422)
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
LOG_GEO: Determine the slot belonging to a logical address
Description
You use the "LOG_GEO" instruction to determine the module slot belonging to a hardware
identifier.
Parameter
The following table shows the parameters of the instruction "LOG_GEO":
Parameter Declaration Data type Memory area Description
LADDR Input HW_IO I, Q, M, D, L or constant Hardware identifier of the module
RET_VAL Return INT I, Q, M, D, L Error information
AREA Output INT I, Q, M, D, L Area ID: indicates how the remaining
output parameters are to be interpreted:
0: central device
2: PROFIBUS DP / PROFINET IO
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2263
Parameter Declaration Data type Memory area Description
MASTER Output INT I, Q, M, D, L or constant With AREA = 0:
0: If the slot is located in one of the
racks (central device).
With AREA = 2:
1 to 32: DP master system ID of the
associated field device if the slot is
located in a field device on
PROFIBUS
100 to 115: PROFINET IO system ID
of the associated field device if the
slot is located in a field device on
PROFINET
STATION Output INT I, Q, M, D, L With MASTER = 0: Number of the rack
With MASTER > 0: Station number of
the field device
SLOT Output INT I, Q, M, D, L Slot number
SUBSLOT Output INT I, Q, M, D, L The SUBSLOT parameter is not output
by the instruction (always "0").
OFFSET Output INT I, Q, M, D, L The OFFSET parameter is not output by
the instruction (always "0").
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
RET_VAL parameter
Error code*
(W#16#...)
Explanation
0000 No error occurred.
8090 Specified logical address invalid
8xyy General error information
See also: Evaluating errors with output parameter RET_VAL (Page 1422)
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
RD_LGADR: Determine all logical addresses of a module
Description
You use a hardware identifier of a module, central submodule or a submodule for PNIO. You
use the instruction to determine all the declared logical addresses of this module and the
submodule. The "RD_LGADR" instruction enters the determined logical addresses in the
PEADDR or PAADDR parameter in ascending order.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2264 System Manual, 01/2013,
Parameter
The following table shows the parameters of the instruction "RD_LGADR":
Parameter Declaration Data type Memory area Description
IOID Input BYTE I, Q, M, D, L or constant Address area identifier:
B#16#54 = Peripheral input (PI)
B#16#55 = Peripheral output (PQ)
LADDR Input HW_ANY I, Q, M, D, L or constant Hardware identifier of the module or the
submodule.
RET_VAL Return INT I, Q, M, D, L Error information
PEADDR Output ANY I, Q, M, D, L Array for the PI addresses, array elements
must be of the WORD data type.
PECOUNT Output INT I, Q, M, D, L Number of returned PI addresses
PAADDR Output ANY I, Q, M, D, L Array for the PQ addresses, array elements
must be of the WORD data type.
PACOUNT Output INT I, Q, M, D, L Number of returned PQ addresses
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
RET_VAL parameter
Error code
(W#16#...)
Explanation
0000 No error occurred.
8090 Specified logical address invalid or illegal value for the IOID parameter.
80A0 Error in the output parameter PEADDR: The data type of the array elements is
not WORD.
80A1 Error in the output parameter PAADDR: The data type of the array elements is
not WORD.
80A2 Error in the output parameter PEADDR: The specified array could not
accommodate all the logical addresses.
80A3 Error in the output parameter PAADDR: The specified array could not
accommodate all the logical addresses.
8xyy General error information
See also: Evaluating errors with output parameter RET_VAL (Page 1422)
GADR_LGC: Query logical start address of a module
Description
Based on the channel of a signal module, the corresponding module slot and the offset in the
user data address area of the module are known. You use the "GADR_LGC" instruction to
determine the hardware identifier of the module.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2265
If you use the "GADR_LGC" instruction on power modules or modules with packed addresses
(ET 200S), then the diagnostics address will be returned.
Parameter
The following table shows the parameters of the instruction "GADR_LGC":
Parameter Declaration Data type Memory area Description
SUBNETID Input BYTE I, Q, M, D, L or constant Area ID:
0: If the slot is located in the central
module
DP master system ID of the
corresponding distributed I/O system if
the slot is in a
distributed I/O device.
RACK Input WORD I, Q, M, D, L or constant Number of the rack, if area identifier is 0
Device number of the distributed I/O
device if the area identifier > 0.
SLOT Input WORD I, Q, M, D, L or constant Slot no.
SUBSLOT Input BYTE I, Q, M, D, L or constant Sub-module slot (if no sub-module can be
inserted, 0 must be entered here)
SUBADDR Input WORD I, Q, M, D, L or constant Offset in the user data address area of the
module
RET_VAL Return INT I, Q, M, D, L Error information
IOID Output BYTE I, Q, M, D, L The IOID output parameter is not written
(always "0").
LADDR Output HW_MODUL
E
I, Q, M, D, L Hardware identifier of the module
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
RET_VAL parameter
Error code*
(W#16#...)
Explanation
0000 No error occurred.
8093 Invalid value at parameter SUBNETID (the "GADR_LGC" instruction is not valid for PROFINET IO).
8094 No subnet was configured with the specified SUBNETID .
8095 Illegal value for RACK parameter
8096 Illegal value for SLOT parameter
8097 Illegal value for SUBSLOT parameter
8098 Illegal value for SUBADDR parameter
8099 The slot is not configured.
809A The sub-address of the selected slot is not configured (only possible with central IO devices for CPU and
IM).
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2266 System Manual, 01/2013,
Error code*
(W#16#...)
Explanation
8xyy General error information
See also: Evaluating errors with output parameter RET_VAL (Page 1422)
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
LGC_GADR: Determine the slot belonging to a logical address
Description
You use the "LGC_GADR" instruction to determine the module slot belonging to a hardware
identifier.
Note
The "LGC_GADR" instruction cannot be used on a module with packed addresses (ET 200S).
Parameters
The following table shows the parameters of the instruction "LGC_GADR":
Parameter Declaration Data type Memory area Description
IOID Input BYTE I, Q, M, D, L or constant Address area identifier:
B#16#54 = Peripheral input (PI)
B#16#55 = Peripheral output (PQ)
If the module is a mixed module, the area
identifier of the lower address must be
specified.
LADDR Input HW_MODUL
E
I, Q, M, D, L or constant Hardware identifier of the module
RET_VAL Return INT I, Q, M, D, L Error information
AREA Output BYTE I, Q, M, D, L Area ID: indicates how the remaining output
parameters are to be interpreted:
0: Central module
2: PROFIBUS DP
RACK Output WORD I, Q, M, D, L Rack number:
With central module AREA= 0):
Rack number
For PROFIBUS DP (AREA=2):
Low byte: Station number
High byte: DP master system ID
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2267
Parameter Declaration Data type Memory area Description
SLOT Output WORD I, Q, M, D, L Slot number:
With central module AREA= 0):
Slot number
For PROFIBUS DP (AREA=2):
Slot no. in the station
SUBADDR Output WORD I, Q, M, D, L Is not output (always "0").
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
RET_VAL parameter
Error code*
(W#16#...)
Explanation
0000 No error occurred.
8090 Specified logical address invalid or illegal value for the IOID parameter.
8093 This instruction is not permitted for the module selected by the parameters IOID and LADDR :
8xyy General error information
See also: Evaluating errors with output parameter RET_VAL (Page 1422)
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
9.8.4 Technology
9.8.4.1 High-speed counters
CTRL_HSC: Control high-speed counters
Parameter
Parameter Data type Memory area Description
EN BOOL I, Q, M, D, L Enable input
ENO BOOL I, Q, M, D, L Enable output
HSC HW_HSC I, Q, M or constant Hardware address of
the high-speed counter
(HW-ID)
DIR BOOL I, Q, M, D, L or constant Enables the new count
direction (see
NEW_DIR)
CV BOOL I, Q, M, D, L or constant Enables the new count
value (see NEW_CV)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2268 System Manual, 01/2013,
Parameter Data type Memory area Description
RV BOOL I, Q, M, D, L or constant Enables the new
reference value (see
NEW_RV)
PERIOD BOOL I, Q, M, D, L or constant Enables the new period
of a frequency
measurement (see
NEW_PERIOD)
NEW_DIR INT I, Q, M, D, L or constant Count direction loaded
when DIR = TRUE.
NEW_CV DINT I, Q, M, D, L or constant Count value loaded
when CV = TRUE.
NEW_RV DINT I, Q, M, D, L or constant Reference value loaded
when RV = TRUE.
NEW_PERIOD INT I, Q, M, D, L or constant Period of the frequency
measurement loaded
when PERIOD = TRUE.
BUSY BOOL I, Q, M, D, L Processing status
STATUS WORD I, Q, M, D, L Status of the operation
Description
With the "Control high-speed counters" instruction, you can make parameter settings and
control the high-speed counters supported by the CPU by loading new values into the counter.
Execution of the instruction requires that the high-speed counter to be controlled is enabled.
You cannot execute multiple "Control high-speed counters" instructions simultaneously in the
program for a given high-speed counter.
You can load the following parameter values into a high-speed counter using the "Control high-
speed counters" instruction:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2269
Count direction (NEW_DIR): The count direction defines whether a high-speed counter
counts up or down. The count direction is defined by the following values at the NEW_DIR
input: 1 = up, -1 = down.
A change to the count direction with the "Control high-speed counters" instruction is only
possible when direction control is set in the parameters by the program. The count direction
specified at the NEW_DIR input is loaded into a high-speed counter when the bit at the DIR
input is set.
Count value (NEW_CV): The count value is the initial value at which a high-speed counter
starts counting. The count value can be in the range -2147483648 to 2147483647.
The count value specified at the NEW_CV input is loaded into a high-speed counter when
the bit at the CV input is set.
Reference value (NEW_RV): You can compare the reference value with the current counter
value to trigger an alarm. Similar to the counter value, the reference value can be in the
range -2147483648 to 2147483647.
The reference value specified at the NEW_RV input is loaded into a high-speed counter
when the bit at the RV input is set.
Period of the frequency measurement (NEW_PERIOD): The period of the frequency
measurement is specified by the following values at the NEW_PERIOD input: 10 = 0.01s,
100 = 0.1s, 1000 = 1s.
The time period can be updated if the "Measure frequency" function for the specified high-
speed counter is configured. The time period specified at the NEW_PERIOD input is loaded
into a high-speed counter when the bit at the PERIOD input is set.
The "Control high-speed counters" instruction is only executed if the signal state at the EN
input is "1". As long as the operation is executing, the bit at the BUSY output is set. Once the
operation has executed completely, the bit at the BUSY output is reset.
The ENO enable output is set only when the EN enable input has signal state "1" and no errors
occur during execution of the operation.
When inserting the "Control high-speed counters" instruction, an instance data block is created
in which the operation data is saved.
Parameter STATUS
At the STATUS output, you can query whether errors occurred during execution of the "Control
high-speed counters" instruction. The following table shows the meaning of the values output
at the STATUS output:
Error code (hexadecimal) Description
0 No error
80A1 Hardware identifier of the high-speed counter invalid
80B1 Count direction (NEW_DIR) invalid
80B2 Count value (NEW_CV) invalid
80B3 Reference value (NEW_RV) invalid
80B4 Period of the frequency measurement (NEW_PERIOD) invalid
80C0 Multiple access to the high-speed counter
80D0 The high-speed counter (HSC) is not enabled in the CPU hardware
configuration.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2270 System Manual, 01/2013,
9.8.4.2 PID Control
PID_Compact
New features of PID_Compact
PID_Compact V2.0
Reaction to error
PID_Compact reaction to error has been completely overhauled and it is now far more fault
tolerant in the default setting. This reaction is set when copying PID_Compact from an
S71200 CPU to an S7-1500 CPU.
NOTICE
Your system may be damaged.
If you use the default setting, PID_Compact remains in automatic mode when the process
value limits are exceeded. This may damage your system.
It is essential to configure how your controlled system reacts in the event of an error to
protect your system from damage.
The Error parameter indicates if an error is pending. When the error is no longer pending,
Error = FALSE. The ErrorBits parameter shows which errors have occurred. Use ErrorAck
to acknowledge the errors and warnings without restarting the controller or clearing the
integral action. Switching operating modes no longer clears errors that are no longer
pending.
You can configure the reaction to error with SetSubstituteOutput and ActivateRecoverMode.
Substitute output value
You can configure a substitute output value that is to be output if an error occurs.
Switching the operating mode
You specify the operating mode at the Mode in/out parameter and use a rising edge at
ModeActivate to start the operating mode. The sRet.i_Mode tag has been omitted.
Multi-instance capability
You can call up PID_Compact as multi-instance DB. No technology object is created in this
case and no parameter assignment interface or commissioning interface is available. You
must assign parameters for PID_Compact directly in the multi-instance DB and commission
it via a watch table.
Startup characteristics
The operating mode specified at the Mode parameter is also started on a falling edge at
Reset and during a CPU cold restart, if RunModeByStartup = TRUE.
ENO characteristics
ENO is set depending on the operating mode.
If State = 0, then ENO = FALSE.
If State 0, then ENO = TRUE.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2271
Setpoint value specification during tuning
You configure the permitted fluctuation of the setpoint during tuning at the
CancelTuningLevel tag.
Value range for output value limits
The value 0.0 no longer has to fall within the output value limits.
Pre-assigning the integral action
Using the tags IntegralResetMode and OverwriteInitialOutputValue, you can determine the
pre-assignment of the integral action when switching from "Inactive" operating mode to
"Automatic mode".
Switching a disturbance variable on
You can switch a disturbance variable on at the Disturbance parameter.
Default value of PID parameters
The following default settings have been changed:
Proportional action weighting (PWeighting) from 0.0 to 1.0
Derivative action weighting (DWeighting) from 0.0 to 1.0
Coefficient for derivative delay (TdFiltRatio) from 0.0 to 0.2
Renaming tags
The static tags have been given new names that are compatible with PID_3Step.
PID_Compact V1.2
Manual mode on CPU startup
If ManualEnable = TRUE when the CPU starts, PID_Compact starts in manual mode. A
rising edge at ManualEnable is not necessary.
Pretuning
If the CPU is switched off during pretuning, pretuning starts again when the CPU is switched
back on.
PID_Compact V1.1
Manual mode on CPU startup
When the CPU starts up, PIC_Compact only switches to manual mode with a rising edge
at ManualEnable. Without rising edge, PID_Compact starts in the last operating mode in
which ManualEnable was FALSE.
Reaction to reset
A rising edge at Reset resets the errors and warnings and clears the integral action. A falling
edge at Reset triggers a switchover to the most recently active operating mode.
Pre-assignment of process value high limit
The pre-assigned value of r_Pv_Hlm has been changed to 120.0.
Monitoring the sampling time
An error is no longer output when the current sampling time is >= 1.5 x current mean
value or when the current sampling time is <= 0.5 x current mean value. The sampling
time may deviate much more in automatic mode.
PID_Compact is compatible with FW, V2.0 or higher.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2272 System Manual, 01/2013,
Access to tags
The following tags can now be used in the user program.
i_Event_SUT
i_Event_TIR
r_Ctrl_Ioutv
Troubleshooting
PID_Compact now outputs the correct pulses when the shortest ON time is not equal to
the shortest OFF time.
Compatibility with CPU and FW
The following table shows which version of PID_Compact can be used on which CPU.
CPU FW PID_Compact
S7-1200 V3.X V1.2
V1.1
S7-1200 V2.X V1.2
V1.1
S7-1200 V1.X V1.0
S7-1500 V1.X V2.0
PID_Compact V2
Description of PID_Compact V2
Description
The PID_Compact instruction provides a PID controller with integrated tuning for actuators
with proportional action.
The following operating modes are possible:
Inactive
Pretuning
Fine tuning
Automatic mode
Manual mode
Substitute output value with error monitoring
For a more detailed description of the operating modes, see the State parameter.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2273
PID algorithm
PID_Compact is a PIDT1 controller with anti-windup and weighting of the proportional and
derivative actions. The PID algorithm operates according to the following equation:
y = K
p
(w - x) + (c w - x)
[
(b w - x) +
1
T
I
s
T
D
s
a T
D
s + 1
]
Symbol Description
y Output value of the PID algorithm
K
p
Proportional gain
s Laplace operator
b Proportional action weighting
w Setpoint
x Process value
T
I
Integral action time
T
D
Derivative action time
a Derivative delay coefficient (derivative delay T1 = a T
D
)
c Derivative action weighting
Block diagram of PID_Compact
PlDT1
Anti Windup
%
%
1
0
0
1
-1
lnputWarning_H
lnputWarning_L
State
lnputPerOn
lnvertControl
PV_ALRM CRP_lN
Limit
PWM
lNV
Limit CRP_OUT
lnput
Output
Output_PER
Output_PWM
ManualValue
lnput_PER
Setpoint
Scale
= 4
= 4
Disturbance
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2274 System Manual, 01/2013,
Block diagram of PIDT1 with anti-windup
-
-
-
Anti Windup
Scaledlnput (x)
Setpoint (w)
l LlMlT
K
P
c
b
DT1
y
Call
PID_Compact is called in the constant time scale of a cycle interrupt OB.
If you call PID_Compact as a multi-instance DB, no technology object is created. No parameter
assignment interface or commissioning interface is available. You must assign parameters for
PID_Compact directly in the multi-instance DB and commission it via a watch table.
Download to device
The actual values of retentive tags are only updated when you download PID_Compact
completely.
Downloading technology objects to device (Page 3543)
Startup
When the CPU starts up, PID_Compact starts in the operating mode that is saved in the Mode
in/out parameter. To switch to "Inactive" operating mode during startup, set
RunModeByStartup = FALSE.
Reaction to error
In automatic mode and during commissioning, the reaction to error depends on the
SetSubstituteOutput and ActivateRecoverMode tags. In manual mode, the reaction is
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2275
independent of SetSubstituteOutput and ActivateRecoverMode. If ActivateRecoverMode =
TRUE, the reaction additionally depends on the error that occurred.
SetSubstituteOu
tput
ActivateReco
verMode
Configuration editor
> output value
> Set Output to
Reaction
Not relevant FALSE Zero (inactive) Switch to "Inactive" mode (State = 0)
The value 0.0 0 is transferred to the actuator.
FALSE TRUE Current output value while error is
pending
Switch to "Substitute output value with error
monitoring" mode (State = 5)
The current output value is transferred to the
actuator while the error is pending.
TRUE TRUE Substitute output value while error
is pending
Switch to "Substitute output value with error
monitoring" mode (State = 5)
The value at SubstituteOutput is transferred to the
actuator while the error is pending.
In manual mode, PID_Compact uses ManualValue as output value, unless ManualValue is
invalid. If ManualValue is invalid, SubstituteOutput is used. If ManualValue and
SubstituteOutput are invalid, Config.OutputLowerLimit is used.
The Error parameter indicates if an error is pending. When the error is no longer pending, Error
= FALSE. The ErrorBits parameter shows which errors have occurred. ErrorBits is reset by a
rising edge at Reset or ErrorAck.
PID_Compact V2 mode of operation
Monitoring process value limits
You specify the high limit and low limit of the process value in the Config.InputUpperLimit and
Config.InputLowerLimit tags. If the process value is outside these limits, an error occurs
(ErrorBits = 0001h).
You specify a high and low warning limit of the process value in the Config.InputUpperWarning
and Config.InputLowerWarning tags. If the process value is outside these warning limits, a
warning occurs (Warning = 0040h), and the InputWarning_H or InputWarning_L output
parameter changes to TRUE.
Limiting the setpoint
You specify a high limit and low limit of the setpoint in the Config.SetpointUpperLimit and
Config.SetpointLowerLimit tags. PID_Compact automatically limits the setpoint to the process
value limits. You can limit the setpoint to a smaller range. PID_Compact checks whether this
range falls within the process value limits. If the setpoint is outside these limits, the high or low
limit is used as the setpoint, and output parameter SetpointLimit_H or SetpointLimit_L is set
to TRUE.
The setpoint is limited in all operating modes.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2276 System Manual, 01/2013,
Limiting the output value
You specify a high limit and low limit of the output value in the Config.OutputUpperLimit and
Config.OutputLowerLimit tags. Output, ManualValue, and SubstituteOutput are limited to these
values. The output value limits must match the control logic.
The valid output value limit values depend on the Output used.
Output -100.0 to 100.0%
Output_PER -100.0 to 100.0%
Output_PWM 0.0 to 100.0%
Rule:
OutputUpperLimit > OutputLowerLimit
Substitute output value
In the event of an error, PID_Compact can output a substitute output value that you define at
the tag SubstituteOutput. The substitute output value must be within the output value limits.
Monitoring signal validity
The values of the following parameters are monitored for validity when used:
Setpoint
Input
Input_PER
Disturbance
ManualValue
SubstituteOutput
Output
Output_PER
Output_PWM
Monitoring of the sampling time PID_Compact
Ideally, the sampling time is equivalent to the cycle time of the calling OB. The PID_Compact
instruction measures the time interval between two calls. This is the current sampling time. On
every switchover of operating mode and during the initial startup, the mean value is formed
from the first 10 sampling times. Too great a difference between the current sampling time and
this mean value triggers an error (Error = 0800h).
The error occurs during tuning if:
New mean value >= 1.1 x old mean value
New mean value <= 0.9 x old mean value
The error occurs in automatic mode if:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2277
New mean value >= 1.5 x old mean value
New mean value <= 0.5 x old mean value
If you deactivate the sampling time monitoring (CycleTime.EnMonitoring = FALSE), you can
also call PID_Compact in OB1. You must then accept a lower control quality due to the
deviating sampling time.
Sampling time of the PID algorithm
The controlled system needs a certain amount of time to respond to changes in the output
value. It is therefore not advisable to calculate the output value in every cycle. The sampling
time of the PID algorithm represents the time between two calculations of the output value. It
is calculated during tuning and rounded to a multiple of the cycle time. All other functions of
PID_Compact are executed at every call.
If you use Output_PWM, the accuracy of the output signal is determined by the ratio of the PID
algorithm sampling time to the cycle time of the OB. The cycle time should be at least 10 times
the PID algorithm sampling time.
Control logic
An increase of the output value is generally intended to cause an increase in the process value.
This is referred to as a normal control logic. For cooling and discharge control systems, it may
be necessary to invert the control logic. PID_Compact does not work with negative proportional
gain. If InvertControl = TRUE, an increasing control deviation causes a reduction in the output
value. The control logic is also taken into account during pretuning and fine tuning.
Input parameters of PID_Compact V2
Table 9-61
Parameter Data type Default Description
Setpoint REAL 0.0 Setpoint of the PID controller in automatic mode
Input REAL 0.0 A tag of the user program is used as the source of the
process value.
If you are using the Input parameter, then
Config.InputPerOn = FALSE must be set.
Input_PER INT 0 An analog input is used as the source of the process
value.
If you are using the Input_PER parameter, then
Config.InputPerOn = TRUE must be set.
Disturbance REAL 0.0 Disturbance variable or precontrol value
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2278 System Manual, 01/2013,
Parameter Data type Default Description
ManualEnable BOOL FALSE A FALSE -> TRUE edge activates "manual mode",
while State = 4, Mode remain unchanged.
As long as ManualEnable = TRUE, you cannot
change the operating mode via a rising edge at
ModeActivate or use the commissioning dialog.
A TRUE -> FALSE edge activates the operating
mode that is specified by Mode.
We recommend that you change the operating mode
using ModeActivate only.
ManualValue REAL 0.0 Manual value
This value is used as the output value in manual mode.
Values from Config.OutputLowerLimit to
Config.OutputUpperLimit are permitted.
ErrorAck BOOL FALSE FALSE -> TRUE edge
ErrorBits and Warning are reset.
Reset BOOL FALSE Restarts the controller.
FALSE -> TRUE edge
Switch to "Inactive" mode
ErrorBits and Warnings are reset.
Integral action is cleared
(PID parameters are retained)
As long as Reset = TRUE, PID_Compact remains
in "Inactive" mode (State = 0).
TRUE -> FALSE edge
PID_Compact switches to the operating mode that
is saved in the Mode parameter.
ModeActivate BOOL FALSE FALSE -> TRUE edge
PID_Compact switches to the operating mode that
is saved in the Mode parameter.
Output parameters of PID_Compact V2
Table 9-62
Parameter Data type Default Description
ScaledInput REAL 0.0 Scaled process value
The "Output", "Output_PER", and "Output_PWM" outputs can be used concurrently.
Output REAL 0.0 Output value in REAL format
Output_PER INT 0 Analog output value
Output_PWM BOOL FALSE Pulse-width-modulated output value
The output value is formed by by variable On and Off times.
SetpointLimit_H BOOL FALSE If SetpointLimit_H = TRUE, the absolute setpoint high limit
is reached (Setpoint Config.SetpointUpperLimit).
The setpoint is limited to Config.SetpointUpperLimit .
SetpointLimit_L BOOL FALSE If SetpointLimit_L = TRUE, the absolute setpoint low limit
has been reached (Setpoint Config.SetpointLowerLimit).
The setpoint is limited to Config.SetpointLowerLimit .
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2279
Parameter Data type Default Description
InputWarning_H BOOL FALSE If InputWarning_H = TRUE, the process value has reached
or exceeded the warning high limit.
InputWarning_L BOOL FALSE If InputWarning_L = TRUE, the process value has reached
or fallen below the warning low limit.
State INT 0 The State parameter (Page 2289) shows the current
operating mode of the PID controller. You can change the
operating mode using the input parameter Mode and a rising
edge at ModeActivate.
State = 0: Inactive
State = 1: Pretuning
State = 2: Fine tuning
State = 3: Automatic mode
State = 4: Manual mode
State = 5: Substitute output value with error monitoring
Error BOOL FALSE If Error = TRUE, at least one error message is pending in
this cycle.
ErrorBits DWORD DW#16#0 The ErrorBits parameter (Page 2293) shows which error
messages are pending. ErrorBits is retentive and is reset
upon a rising edge at Reset or ErrorAck.
In/out parameters of PID_Compact V2
Table 9-63
Parameter Data type Default Description
Mode INT 4 At Mode, specify the operating mode to
which PID_Compact is to switch. Options
are:
Mode = 0: Inactive
Mode = 1: Pretuning
Mode = 2: Fine tuning
Mode = 3: Automatic mode
Mode = 4: Manual mode
The operating mode is activated by:
Rising edge at ModeActivate
Falling edge at Reset
Falling edge at ManualEnable
Cold restart of CPU if
RunModeByStartup = TRUE
Mode is retentive.
A detailed description of the operating
modes can be found in Parameters State
and Mode V2 (Page 2289).
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2280 System Manual, 01/2013,
See also
Parameters State and Mode V2 (Page 2289)
Static tags of PID_Compact V2
You must not change tags that are not listed. These are used for internal purposes only.
Table 9-64
Tag Data type Default Description
IntegralResetMode INT 1 The tag IntegralResetMode determines how
PIDCtrl.IntegralSum is pre-assigned when switching
from "Inactive" operating mode to "Automatic mode".
This setting only works for one cycle.
Options are:
IntegralResetMode = 0: Smoothing
The value of IntegralSum is pre-assigned so that the
switchover is bumpless.
IntegralResetMode = 1: Deleting
The value of IntegralSum is deleted. Any control
deviation will cause a jump change of the output
value.
IntegralResetMode = 2: Holding
The value of IntegralSum is not changed. You can
define a new value using the user program.
IntegralResetMode = 3: Pre-assigning
The value of IntegralSum is automatically pre-
assigned so that Output is calculated with reference
to the value OverwriteInitialOutputValue. This
setting is useful, for example, for an override
controller.
OverwriteInitialOutputValue REAL 0.0 If IntegralResetMode = 3, the value of IntegralSum is
automatically pre-assigned so that Output =
OverwriteInitialOutputValue in the next cycle.
RunModeByStartup BOOL TRUE Activate operating mode at Mode parameter after CPU
restart
If RunModeByStartup = TRUE, PID_Compact starts in
the operating mode saved in the Mode parameter after
CPU startup.
If RunModeByStartup = FALSE, PID_Compact remains
in "Inactive" mode after CPU startup.
LoadBackUp BOOL FALSE If LoadBackUp = TRUE, the last set of PID parameters
is reloaded. The set was saved prior to the last tuning.
LoadBackUp is automatically set back to FALSE.
PhysicalUnit INT 0 Unit of measurement of the process value and setpoint,
e.g., C, or F.
PhysicalQuantity INT 0 Physical quantity of the process value and setpoint,
e.g., temperature.
ActivateRecoverMode BOOL TRUE The Tag ActivateRecoverMode V2 (Page 2295)
determines the reaction to error.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2281
Tag Data type Default Description
Warning DWORD 0 Tag Warning V2 (Page 2297) shows the warnings since
Reset = TRUE or ErrorAck =TRUE. Warning is
retentive.
Progress REAL 0.0 Progress of tuning as a percentage (0.0 - 100.0)
CurrentSetpoint REAL 0.0 CurrentSetpoint always displays the current setpoint.
This value is frozen during tuning.
CancelTuningLevel REAL 10.0 Permissible fluctuation of setpoint during tuning. Tuning
is not canceled until:
Setpoint > CurrentSetpoint + CancelTuningLevel
or
Setpoint < CurrentSetpoint - CancelTuningLevel
SubstituteOutput REAL 0.0 Substitute output value
When the following conditions are met, the substitute
output value is used:
An error has occurred in automatic mode.
SetSubstituteOutput = TRUE
ActivateRecoverMode = TRUE
SetSubstituteOutput BOOL TRUE If SetSubstituteOutput = TRUE and
ActivateRecoverMode = TRUE, the substitute output
value configured is output as long as an error is pending.
If SetSubstituteOutput = FALSE and
ActivateRecoverMode = TRUE, the actuator remains at
the current output value as long as an error is pending.
If ActivateRecoverMode = FALSE, SetSubstituteOutput
is not effective.
If SubstituteOutput is invalid (ErrorBits = 20000h), the
substitute output value cannot be output.
Config.InputPerOn BOOL TRUE If InputPerOn = TRUE, the Input_PER parameter is
used. If InputPerOn = FALSE, the Input parameter is
used.
Config.InvertControl BOOL FALSE Invert control logic
If InvertControl = TRUE, an increasing control deviation
causes a reduction in the output value.
Config.InputUpperLimit REAL 120.0 High limit of the process value
Input and Input_PER are monitored to ensure
adherence to this limit.
At the I/O input, the process value can be a maximum
of 18% higher than the standard range (overrange).
This pre-assignment ensures that an error is no longer
signaled due to a violation of the "Process value high
limit". Only a wire-break and a short-circuit are
recognized and PID_Compact reacts according to the
configured reaction to error.
InputUpperLimit > InputLowerLimit
Config.InputLowerLimit REAL 0.0 Low limit of the process value
Input and Input_PER are monitored to ensure
adherence to this limit.
InputLowerLimit < InputUpperLimit
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2282 System Manual, 01/2013,
Tag Data type Default Description
Config.InputUpperWarning REAL 3.402822e+38 Warning high limit of the process value
If you set InputUpperWarning outside the process value
limits, the configured absolute process value high limit
is used as the warning high limit.
If you configure InputUpperWarning within the process
value limits, this value is used as the warning high limit.
InputUpperWarning > InputLowerWarning
InputUpperWarning InputUpperLimit
Config.InputLowerWarning REAL -
3.402822e+38
Warning low limit of the process value
If you set InputLowerWarning outside the process value
limits, the configured absolute process value low limit
is used as the warning low limit.
If you configure InputLowerWarning within the process
value limits, this value is used as the warning low limit.
InputLowerWarning < InputUpperWarning
InputLowerWarning InputLowerLimit
Config.OutputUpperLimit REAL 100.0 High limit of output value
For details, see OutputLowerLimit
OutputUpperLimit > OutputLowerLimit
Config.OutputLowerLimit REAL 0.0 Low limit of output value
For Output and Output_PER, the range of values from
-100.0 to +100.0, including zero, is valid. At -100.0,
Output_PER = -27648; at +100.0, Output_PER = 27648.
For Output_PWM, the value range 0.0 to +100.0
applies.
The output value limits must match the control logic.
OutputLowerLimit < OutputUpperLimit
Config.SetpointUpperLimit REAL 3.40282
2e+38
High limit of setpoint
If you configure SetpointUpperLimit outside the process
value limits, the configured absolute process value high
limit is used as the setpoint high limit.
If you configure SetpointUpperLimit within the process
value limits, this value is used as the setpoint high limit.
Config.SetpointLowerLimit REAL -3.402822e
+38
Low limit of the setpoint
If you set SetpointLowerLimit outside the process value
limits, the configured process value absolute low limit
is used as the setpoint low limit.
If you set SetpointLowerLimit within the process value
limits, this value is used as the setpoint low limit.
Config.MinimumOnTime REAL The minimum ON time of the pulse width modulation in
seconds is rounded to
MinimumOnTime = nCycleTime.Value
Config.MinimumOffTime REAL The minimum OFF time of the pulse width modulation
in seconds is rounded to
MinimumOffTime = nCycleTime.Value
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2283
Tag Data type Default Description
Config.InputScaling.UpperPointIn REAL 27648.0 Scaling Input_PER high
Input_PER is converted to percent based on the two
value pairs UpperPointOut, UpperPointIn and
LowerPointOut, LowerPointIn.
Config.InputScaling.LowerPointIn REAL 0.0 Scaling Input_PER low
Input_PER is converted to percent based on the two
value pairs UpperPointOut, UpperPointIn and
LowerPointOut, LowerPointIn.
Config.InputScaling.UpperPointOut REAL 100.0 Scaled high process value
Input_PER is converted to percent based on the two
value pairs UpperPointOut, UpperPointIn and
LowerPointOut, LowerPointIn.
Config.InputScaling.LowerPointOut REAL 0.0 Scaled low process value
Input_PER is converted to percent based on the two
value pairs UpperPointOut, UpperPointIn and
LowerPointOut, LowerPointIn.
CycleTime.StartEstimation BOOL TRUE If CycleTime.StartEstimation = TRUE, the automatic
determination of the cycle time is started.
CycleTime.StartEstimation = FALSE once
measurement is complete.
CycleTime.EnEstimation BOOL TRUE If CycleTime.EnEstimation = TRUE, the PID_Compact
sampling time is calculated.
If CycleTime.EnEstimation = FALSE, the PID_Compact
sampling time is not calculated and you need to correct
the configuration of CycleTime.Value manually.
CycleTime.EnMonitoring BOOL TRUE If CycleTime.EnMonitoring = FALSE, the PID_Compact
sampling time is not monitored. If it is not possible to
execute PID_Compact within the sampling time, no
error (ErrorBits=0800h) is output and PID_Compact
does not switch to "Inactive" mode.
CycleTime.Value REAL 0.1 PID_Compact sampling time in seconds
CycleTime.Value is determined automatically and is
usually equivalent to the cycle time of the calling OB.
CtrlParamsBackUp.Gain REAL 1.0 Saved proportional gain
You can reload values from the CtrlParamsBackUp
structure with LoadBackUp = TRUE.
CtrlParamsBackUp.Ti REAL 20.0 Saved integral action time [s]
CtrlParamsBackUp.Td REAL 0.0 Saved derivative action time [s]
CtrlParamsBackUp.TdFiltRatio REAL 0.0 Saved derivative delay coefficient
CtrlParamsBackUp.PWeighting REAL 0.0 Saved proportional action weighting factor
CtrlParamsBackUp.DWeighting REAL 0.0 Saved derivative action weighting factor
CtrlParamsBackUp.Cycle REAL 1.0 Saved sampling time of PID algorithm
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2284 System Manual, 01/2013,
Tag Data type Default Description
PIDSelfTune.SUT.CalculateParams BOOL FALSE The properties of the controlled system are saved
during tuning. If SUT.CalculateParams = TRUE, the
parameters for pretuning are recalculated according to
these properties. This enables you to change the
parameter calculation method without having to repeat
controller tuning.
SUT.CalculateParams is set to FALSE after the
calculation.
PIDSelfTune.SUT.TuneRule INT 0 Methods used to calculate parameters during pretuning:
SUT.TuneRule = 0: PID according to Chien, Hrones
and Reswick
SUT.TuneRule = 1: PI according to Chien, Hrones
and Reswick
PIDSelfTune.SUT.State INT 0 The SUT.State tag indicates the current phase of
pretuning:
State = 0: Initialize pretuning
State = 100: Calculate standard deviation
State = 200: Determine point of inflection
State = 9900: Pretuning successful
State = 1: Pretuning not successful
PIDSelfTune.TIR.RunIn BOOL FALSE With the RunIn tag, you can specify that fine tuning can
also be performed without pretuning.
RunIn = FALSE
Pretuning is started when fine tuning is started from
inactive or manual mode. If the requirements for
pretuning are not met, PID_Compact reacts as
when RunIn = TRUE.
If fine tuning is started from automatic mode, the
system uses the existing PID parameters to control
to the setpoint.
Only then will fine tuning start. If pretuning is not
possible, PID_Compact switches to the mode from
which tuning was started.
RunIn = TRUE
The pretuning is skipped. PID_Compact tries to
reach the setpoint with minimum or maximum
output value. This can produce increased
overshoot. Fine tuning then starts automatically.
RunIn is set to FALSE after fine tuning.
PIDSelfTune.TIR.CalculateParams BOOL FALSE The properties of the controlled system are saved
during tuning. If TIR.CalculateParams = TRUE, the
parameters for fine tuning are recalculated according
to these properties. This enables you to change the
parameter calculation method without having to repeat
controller tuning.
TIR.CalculateParams is set to FALSE after the
calculation.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2285
Tag Data type Default Description
PIDSelfTune.TIR.TuneRule INT 0 Methods used to calculate parameters during fine
tuning:
TIR.TuneRule = 0: PID automatic
TIR.TuneRule = 1: PID rapid
TIR.TuneRule = 2: PID slow
TIR.TuneRule = 3: Ziegler-Nichols PID
TIR.TuneRule = 4: Ziegler-Nichols PI
TIR.TuneRule = 5: Ziegler-Nichols P
PIDSelfTune.TIR.State INT 0 The TIR.State tag indicates the current phase of fine
tuning:
State = -100 Fine tuning is not possible. Pretuning
will be performed first.
State = 0: Initialize fine tuning
State = 200: Calculate standard deviation
State = 300: Attempt to reach the setpoint
State = 400: Attempt to reach the setpoint with
existing PID parameters
(if pretuning was successful)
State = 500: Determine oscillation and calculate
parameters
State = 9900: Fine tuning successful
State = 1: Fine tuning not successful
PIDCtrl.IntegralSum REAL 0.0 Current integral action
Retain.CtrlParams.Gain REAL 1.0 Active proportional gain
To invert the control logic, use the Config.InvertControl
tag. Negative values at Gain also invert the control
logic. We recommend you use only InvertControl to set
the control logic. The control logic is also inverted if
InvertControl = TRUE and Gain < 0.0.
Gain is retentive.
Retain.CtrlParams.Ti REAL 20.0 CtrlParams.Ti > 0.0: Active integral action time
CtrlParams.Ti = 0.0: Integral action is deactivated
Ti is retentive.
Retain.CtrlParams.Td REAL 0.0 CtrlParams.Td > 0.0: Active derivative action time
CtrlParams.Td = 0.0: Derivative action is
deactivated
Td is retentive.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2286 System Manual, 01/2013,
Tag Data type Default Description
Retain.CtrlParams.TdFiltRatio REAL 0.2 Active derivative delay coefficient
The derivative delay coefficient delays the effect of the
derivative action.
Derivative delay = derivative action time derivative
delay coefficient
0.0: Derivative action is effective for one cycle only
and therefore almost not effective.
0.5: This value has proved useful in practice for
controlled systems with one dominant time constant.
> 1.0: The greater the coefficient, the longer the
effect of the derivative action is delayed.
TdFiltRatio is retentive.
Retain.CtrlParams.PWeighting REAL 1.0 Active proportional action weighting
The proportional action may weaken with changes to
the setpoint.
Values from 0.0 to 1.0 are applicable.
1.0: Proportional action for setpoint change is fully
effective
0.0: Proportional action for setpoint change is not
effective
The proportional action is always fully effective when
the process value is changed.
PWeighting is retentive.
Retain.CtrlParams.DWeighting REAL 1.0 Active derivative action weighting
The derivative action may weaken with changes to the
setpoint.
Values from 0.0 to 1.0 are applicable.
1.0: Derivative action is fully effective upon setpoint
change
0.0: Derivative action is not effective upon setpoint
change
The derivative action is always fully effective when the
process value is changed.
DWeighting is retentive.
Retain.CtrlParams.Cycle REAL 1.0 Active sampling time of the PID algorithm
CtrlParams.Cycle is calculated during tuning and
rounded to an integer multiple of CycleTime.Value.
Cycle is retentive.
Note
Change the tags listed in this table in "Inactive" mode to prevent malfunction of the PID
controller.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2287
See also
Tag ActivateRecoverMode V2 (Page 2295)
Tag Warning V2 (Page 2297)
Downloading technology objects to device (Page 3543)
Changing the PID_Compact V2 interface
The following table shows what has changed in the PID_Compact instruction interface.
PID_Compact V1 PID_Compact V2 Change
Input_PER Input_PER Data type from Word to Int
Feedback_PER Feedback_PER Data type from Word to Int
Disturbance New
ErrorAck New
ModeActivate New
Output_PER Output_PER Data type from Word to Int
Error ErrorBits Renamed
Error New
Mode New
sb_RunModeByStartup RunModeByStartup Function
IntegralResetMode
OverwriteInitialOutputValue New
SetSubstituteOutput New
CancelTuningLevel New
SubstituteOutput New
The following table shows which tags have been renamed.
PID_Compact V1.x PID_Compact V2
sb_GetCycleTime CycleTime.StartEstimation
sb_EnCyclEstimation CycleTime.EnEstimation
sb_EnCyclMonitoring CycleTime.EnMonitoring
sb_RunModeByStartup RunModeByStartup
si_Unit PhysicalUnit
si_Type PhysicalQuantity
sd_Warning Warning
sBackUp.r_Gain CtrlParamsBackUp.Gain
sBackUp.r_Ti CtrlParamsBackUp.Ti
sBackUp.r_Td CtrlParamsBackUp.Td
sBackUp.r_A CtrlParamsBackUp.TdFiltRatio
sBackUp.r_B CtrlParamsBackUp.PWeighting
sBackUp.r_C CtrlParamsBackUp.DWeighting
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2288 System Manual, 01/2013,
PID_Compact V1.x PID_Compact V2
sBackUp.r_Cycle CtrlParamsBackUp.Cycle
sPid_Calc.r_Cycle CycleTime.Value
sPid_Calc.b_RunIn PIDSelfTune.TIR.RunIn
sPid_Calc.b_CalcParamSUT PIDSelfTune.SUT.CalculateParams
sPid_Calc.b_CalcParamTIR PIDSelfTune.TIR.CalculateParams
sPid_Calc.i_CtrlTypeSUT PIDSelfTune.SUT.TuneRule
sPid_Calc.i_CtrlTypeTIR PIDSelfTune.TIR.TuneRule
sPid_Calc.r_Progress Progress
sPid_Cmpt.r_Sp_Hlm Config.SetpointUpperLimit
sPid_Cmpt.r_Sp_Llm Config.SetpointLowerLimit
sPid_Cmpt.r_Pv_Norm_IN_1 Config.InputScaling.LowerPointIn
sPid_Cmpt.r_Pv_Norm_IN_2 Config.InputScaling.UpperPointIn
sPid_Cmpt.r_Pv_Norm_OUT_1 Config.InputScaling.LowerPointOut
sPid_Cmpt.r_Pv_Norm_OUT_2 Config.InputScaling.UpperPointOut
sPid_Cmpt.r_Lmn_Hlm Config.OutputUpperLimit
sPid_Cmpt.r_Lmn_Llm Config.OutputLowerLimit
sPid_Cmpt.b_Input_PER_On Config.InputPerOn
sPid_Cmpt.b_LoadBackUp LoadBackUp
sPid_Cmpt.b_InvCtrl Config.InvertControl
sPid_Cmpt.r_Lmn_Pwm_PPTm Config.MinimumOnTime
sPid_Cmpt.r_Lmn_Pwm_PBTm Config.MinimumOffTime
sPid_Cmpt.r_Pv_Hlm Config.InputUpperLimit
sPid_Cmpt.r_Pv_Llm Config.InputLowerLimit
sPid_Cmpt.r_Pv_HWrn Config.InputUpperWarning
sPid_Cmpt.r_Pv_LWrn Config.InputLowerWarning
sParamCalc.i_Event_SUT PIDSelfTune.SUT.State
sParamCalc.i_Event_TIR PIDSelfTune.TIR.State
sRet.i_Mode sRet.i_Mode has been omitted. The operating
mode is changed using Mode and ModeActivate.
sRet.r_Ctrl_Gain Retain.CtrlParams.Gain
sRet.r_Ctrl_Ti Retain.CtrlParams.Ti
sRet.r_Ctrl_Td Retain.CtrlParams.Td
sRet.r_Ctrl_A Retain.CtrlParams.TdFiltRatio
sRet.r_Ctrl_B Retain.CtrlParams.PWeighting
sRet.r_Ctrl_C Retain.CtrlParams.DWeighting
sRet.r_Ctrl_Cycle Retain.CtrlParams.Cycle
Parameters State and Mode V2
Correlation of the parameters
The State parameter shows the current operating mode of the PID controller. You cannot
change the State parameter.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2289
With a rising edge at ModeActivate, PID_Compact switches to the operating mode saved in
the Mode in-out parameter.
When the CPU is switched on or switches from Stop to RUN mode, PID_Compact starts in the
operating mode that is saved in the Mode parameter. To leave PID_Compact in "Inactive"
mode, set RunModeByStartup = FALSE.
Meaning of values
State / Mode Description of operating mode
0 Inactive
In "Inactive" operating mode, the output value 0.0 is always output, regardless of Config.OutputUpperLimit
and Config.OutputLowerLimit. Pulse width modulation is off.
1 Pretuning
The pretuning determines the process response to a jump change of the output value and searches for the
point of inflection. The PID parameters are calculated from the maximum rate of rise and dead time of the
controlled system. You obtain the best PID parameters when you perform pretuning and fine tuning.
Pretuning requirements:
Inactive (State = 0), manual mode (State = 4), or automatic mode (State = 3)
ManualEnable = FALSE
Reset = FALSE
The process value must not be too close to the setpoint.
|Setpoint - Input| > 0.3 * | Config.InputUpperLimit - Config.InputLowerLimit| and
|Setpoint - Input| > 0.5 * |Setpoint|
The setpoint and the process value lie within the configured limits.
The more stable the process value is, the easier it is to calculate the PID parameters and the more precise
the result will be. Noise on the process value can be tolerated as long as the rate of rise of the process value
is significantly higher compared to the noise.
The setpoint is frozen in the CurrentSetpoint tag. Tuning is canceled when:
Setpoint > CurrentSetpoint + CancelTuningLevel
or
Setpoint < CurrentSetpoint - CancelTuningLevel
Before the PID parameters are recalculated, they are backed up and can be reactivated with LoadBackUp.
The controller switches to automatic mode following successful pretuning. If pretuning is unsuccessful, the
switchover of the operating mode is dependent on ActivateRecoverMode.
The phase of pretuning is indicated with PIDSelfTune.SUT.State.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2290 System Manual, 01/2013,
State / Mode Description of operating mode
2 Fine tuning
Fine tuning generates a constant, limited oscillation of the process value. The PID parameters are recalculated
based on the amplitude and frequency of this oscillation. PID parameters from fine tuning usually have better
master control and disturbance characteristics than PID parameters from pretuning. You obtain the best PID
parameters when you perform pretuning and fine tuning.
PID_Compact automatically attempts to generate an oscillation greater than the noise of the process value.
Fine tuning is only minimally influenced by the stability of the process value.
The setpoint is frozen in the CurrentSetpoint tag. Tuning is canceled when:
Setpoint > CurrentSetpoint + CancelTuningLevel
or
Setpoint < CurrentSetpoint - CancelTuningLevel
Before the PID parameters are recalculated, they are backed up and can be reactivated with LoadBackUp.
Requirements for fine tuning:
No disturbances are expected.
The setpoint and the process value lie within the configured limits.
ManualEnable = FALSE
Reset = FALSE
Automatic (State = 3), inactive (State = 0) or manual (State = 4) mode
Fine tuning proceeds as follows when started from:
Automatic mode (State = 3)
Start fine tuning from automatic mode if you wish to improve the existing PID parameters through tuning.
PID_Compact controls the system using the existing PID parameters until the control loop has stabilized
and the requirements for fine tuning have been met. Only then will fine tuning start.
Inactive (State = 0) or manual mode (State = 4)
If the requirements for pretuning are met, pretuning is started. The determined PID parameters will be
used for control until the control loop has stabilized and the requirements for fine tuning have been met.
If the process value for pretuning is already too near the setpoint or PIDSelfTune.TIR.RunIn = TRUE, an
attempt is made to reach the setpoint with the minimum or maximum output value. This can produce
increased overshoot.
Only then will fine tuning start.
The controller switches to automatic mode following successful fine tuning. If fine tuning is unsuccessful, the
switchover of the operating mode is dependent on ActivateRecoverMode.
The "Fine tuning" phase is indicated with PIDSelfTune.TIR.State.
3 Automatic mode
In automatic mode, PID_Compact corrects the controlled system in accordance with the parameters specified.
The controller switches to automatic mode if one the following requirements is fulfilled:
Pretuning successfully completed
Fine tuning successfully completed
Changing of the Mode in-out parameter to the value 3 and a rising edge at ModeActivate.
The switchover from automatic mode to manual mode is only bumpless if carried out in the commissioning
editor.
The ActivateRecoverMode tag is taken into consideration in automatic mode.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2291
State / Mode Description of operating mode
4 Manual mode
In manual mode, you specify a manual output value in the ManualValue parameter.
You can also activate this operating mode using ManualEnable = TRUE. We recommend that you change
the operating mode using Mode and ModeActivate only.
The switchover from manual mode to automatic mode is bumpless. Manual mode is also possible when an
error is pending.
5 Substitute output value with error monitoring
The control algorithm is deactivated. The SetSubstituteOutput tag determines which output value is output in
this operating mode.
SetSubstituteOutput = FALSE: Last valid output value
SetSubstituteOutput = TRUE: Substitute output value
You cannot activate this operating mode using Mode = 5.
In the event of an error, it is activated instead of "Inactive" operating mode if all the following conditions are
met:
Automatic mode (Mode = 3)
ActivateRecoverMode = TRUE
One or more errors have occurred in which ActivateRecoverMode is effective.
As soon as the errors are no longer pending, PID_Compact switches back to automatic mode.
ENO characteristics
If State = 0, then ENO = FALSE.
If State 0, then ENO = TRUE.
Automatic switchover of operating mode during commissioning
Automatic mode is activated following successful pretuning or fine tuning. The following table
shows how Mode and State change during successful pretuning.
Cycle no. Mode State Action
0 4 4 Set Mode = 1
1 1 4 Set ModeActivate = TRUE
1 4 1 Value of State is saved in Mode parameter
Pretuning is started
n 4 1 Pretuning successfully completed
n 3 3 Automatic mode is started
PID_Compact automatically switches the operating mode in the event of an error. The following
table shows how Mode and State change during pretuning with errors.
Cycle no. Mode State Action
0 4 4 Set Mode = 1
1 1 4 Set ModeActivate = TRUE
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2292 System Manual, 01/2013,
Cycle no. Mode State Action
1 4 1 Value of State is saved in Mode parameter
Pretuning is started
n 4 1 Pretuning canceled
n 4 4 Manual mode is started
If ActivateRecoverMode = TRUE, the operating mode that is saved in the Mode parameter is
activated. At the start of pretuning or fine tuning, PID_Compact has saved the value of State
in the Mode in/out parameter. PID_Compact therefore switches to the operating mode from
which tuning was started.
If ActivateRecoverMode = FALSE, the system switches to "Inactive" operating mode.
See also
Output parameters of PID_Compact V2 (Page 2279)
Parameter ErrorBits V2
If several errors are pending simultaneously, the values of the ErrorBits are displayed with
binary addition. The display of ErrorBits = 0003h, for example, indicates that the errors 0001h
and 0002h are pending simultaneously.
In manual mode, PID_Compact uses ManualValue as output value. The exception is Errorbits
= 10000h.
ErrorBits
(DW#16#...)
Description
0000 There is no error.
0001 The "Input" parameter is outside the process value limits.
Input > Config.InputUpperLimit or
Input < Config.InputLowerLimit
If automatic mode was active before the error occurred and ActivateRecoverMode = TRUE, PID_Compact
remains in automatic mode.
If pretuning or fine tuning mode was active before the error occurred and ActivateRecoverMode = TRUE,
PID_Compact switches to the operating mode that is saved in the Mode parameter.
0002 Invalid value at "Input_PER" parameter. Check whether an error is pending at the analog input.
If automatic mode was active before the error occurred and ActivateRecoverMode = TRUE, PID_Compact
outputs the configured substitute output value. As soon as the error is no longer pending, PID_Compact
switches back to automatic mode.
If pretuning or fine tuning mode was active before the error occurred and ActivateRecoverMode = TRUE,
PID_Compact switches to the operating mode that is saved in the Mode parameter.
0004 Error during fine tuning. Oscillation of the process value could not be maintained.
If ActivateRecoverMode = TRUE before the error occurred, PID_Compact cancels the tuning and switches
to the operating mode that is saved in the Mode parameter.
0008 Error at start of pretuning. The process value is too close to the setpoint. Start fine tuning.
If ActivateRecoverMode = TRUE before the error occurred, PID_Compact cancels the tuning and switches
to the operating mode that is saved in the Mode parameter.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2293
ErrorBits
(DW#16#...)
Description
0010 The setpoint was changed during tuning.
You can set the permitted fluctuation of the setpoint at the CancelTuningLevel tag.
If ActivateRecoverMode = TRUE before the error occurred, PID_Compact cancels the tuning and switches
to the operating mode that is saved in the Mode parameter.
0020 Pretuning is not permitted during fine tuning.
If ActivateRecoverMode = TRUE before the error occurred, PID_Compact remains in fine tuning mode.
0080 Error during pretuning. Incorrect configuration of output value limits.
Check whether the limits of the output value are configured correctly and match the control logic.
If ActivateRecoverMode = TRUE before the error occurred, PID_Compact cancels the tuning and switches
to the operating mode that is saved in the Mode parameter.
0100 Error during fine tuning resulted in invalid parameters.
If ActivateRecoverMode = TRUE before the error occurred, PID_Compact cancels the tuning and switches
to the operating mode that is saved in the Mode parameter.
0200 Invalid value at "Input" parameter: Value has an invalid number format.
If automatic mode was active before the error occurred and ActivateRecoverMode = TRUE, PID_Compact
outputs the configured substitute output value. As soon as the error is no longer pending, PID_Compact
switches back to automatic mode.
If pretuning or fine tuning mode was active before the error occurred and ActivateRecoverMode = TRUE,
PID_Compact switches to the operating mode that is saved in the Mode parameter.
0400 Calculation of output value failed. Check the PID parameters.
If automatic mode was active before the error occurred and ActivateRecoverMode = TRUE, PID_Compact
outputs the configured substitute output value. As soon as the error is no longer pending, PID_Compact
switches back to automatic mode.
If pretuning or fine tuning mode was active before the error occurred and ActivateRecoverMode = TRUE,
PID_Compact switches to the operating mode that is saved in the Mode parameter.
0800 Sampling time error: PID_Compact is not called within the sampling time of the cyclic interrupt OB.
If automatic mode was active before the error occurred and ActivateRecoverMode = TRUE, PID_Compact
remains in automatic mode.
If pretuning or fine tuning mode was active before the error occurred and ActivateRecoverMode = TRUE,
PID_Compact switches to the operating mode that is saved in the Mode parameter.
1000 Invalid value at "Setpoint" parameter: Value has an invalid number format.
If automatic mode was active before the error occurred and ActivateRecoverMode = TRUE, PID_Compact
outputs the configured substitute output value. As soon as the error is no longer pending, PID_Compact
switches back to automatic mode.
If pretuning or fine tuning mode was active before the error occurred and ActivateRecoverMode = TRUE,
PID_Compact switches to the operating mode that is saved in the Mode parameter.
10000 Invalid value at ManualValue parameter. Value has an invalid number format.
If ActivateRecoverMode = TRUE before an error occurred, PID_Compact uses SubstituteOutput as the
output value. As soon as you specify a valid value in ManualValue, PID_Compact uses it as the output
value.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2294 System Manual, 01/2013,
ErrorBits
(DW#16#...)
Description
20000 Invalid value at SubstituteOutput tag. Value has an invalid number format.
PID_Compact uses the output value low limit as the output value.
If automatic mode was active before the error occurred, ActivateRecoverMode = TRUE, and the error is
no longer pending, PID_Compact switches back to automatic mode.
40000 Invalid value at parameter Disturbance. Value has an invalid number format.
If automatic mode was active before the error occurred, Disturbance is set to zero. PID_Compact remains
in automatic mode.
If pretuning or fine tuning mode was active and ActivateRecoverMode = TRUE before the error occurred,
PID_Compact switches to the operating mode saved in the Mode parameter. If Disturbance in the current
phase has no effect on the output value, tuning is not be canceled.
Tag ActivateRecoverMode V2
The ActivateRecoverMode tag determines the reaction to error. The Error parameter indicates
if an error is pending. When the error is no longer pending, Error = FALSE. The ErrorBits
parameter shows which errors have occurred.
Automatic mode
NOTICE
Your system may be damaged.
If ActivateRecoverMode = TRUE, PID_Compact remains in automatic mode even if there is
an error and the process limit values are exceeded. This may damage your system.
It is essential to configure how your controlled system reacts in the event of an error to protect
your system from damage.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2295
ActivateRecover
Mode
Description
FALSE PID_Compact automatically switches to "Inactive" mode in the event of an error. The controller is only
activated by a falling edge at Reset or a rising edge at ModeActivate.
TRUE If errors occur frequently in automatic mode, this setting has a negative effect on the control response,
because PID_Compact switches between the calculated output value and the substitute output value at
each error. In this case, check the ErrorBits parameter and eliminate the cause of the error.
If one or more of the following errors occur, PID_Compact stays in automatic mode:
0001h: The "Input" parameter is outside the process value limits.
0800h: Sampling time error
40000h: Invalid value at parameter Disturbance.
If one or more of the following errors occur, PID_Compact switches to "Substitute output value with error
monitoring" mode:
0002h: Invalid value at Input_PER parameter.
0200h: Invalid value at Input parameter.
0400h: Calculation of output value failed.
1000h: Invalid value at Setpoint parameter.
If the following error occurs, PID_Compact switches to "Substitute output value with error monitoring"
mode and moves the actuator to Config.OutputLowerLimit:
20000h: Invalid value at SubstituteOutput tag. Value has an invalid number format.
This characteristics are independent of SetSubstituteOutput.
As soon as the errors are no longer pending, PID_Compact switches back to automatic mode.
Pretuning and fine tuning
ActivateRecover
Mode
Description
FALSE PID_Compact automatically switches to "Inactive" mode in the event of an error. The controller is only
activated by a falling edge at Reset or a rising edge at ModeActivate.
TRUE If the following error occurs, PID_Compact remains in the active mode:
0020h: Pretuning is not permitted during fine tuning.
The following errors are ignored:
10000h: Invalid value at ManualValue parameter.
20000h: Invalid value at SubstituteOutput tag.
When any other error occurs, PID_Compact cancels the tuning and switches to the mode from which
tuning was started.
Manual mode
ActivateRecoverMode is not effective in manual mode.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2296 System Manual, 01/2013,
Tag Warning V2
If several warnings are pending simultaneously, the values of the Warning tag are displayed
with binary addition. The display of warning 0003h, for example, indicates that the warnings
0001h and 0002h are pending simultaneously.
Warning
(DW#16#....)
Description
0000 No warning pending.
0001 The point of inflection was not found during pretuning.
0004 The setpoint was limited to the configured limits.
0008 Not all the necessary controlled system properties were defined for the selected method of calculation.
Instead, the PID parameters were calculated using the TIR.TuneRule = 3 method.
0010 The operating mode could not be changed because Reset = TRUE or ManualEnable = TRUE.
0020 The cycle time of the calling OB limits the sampling time of the PID algorithm.
Improve results by using shorter OB cycle times.
0040 The process value exceeded one of its warning limits.
0080 Invalid value at Mode. The operating mode is not switched.
0100 The manual value was limited to the limits of the controller output.
0200 The specified rule for tuning is not supported. No PID parameters are calculated.
1000 The substitute output value cannot be reached because it is outside the output value limits.
The following warnings are deleted as soon as the cause is eliminated:
0001h
0004h
0008h
0040h
0100h
All other warnings are cleared with a rising edge at Reset or ErrorAck.
PID_Compact V1
Description of PID_Compact V1
Description
The PID_Compact instruction provides a PID controller with integrated tuning for automatic
and manual mode.
Call
PID_Compact is called in the constant interval of the cycle time of the calling OB (preferably
in a cyclic interrupt OB).
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2297
Download to device
The actual values of retentive tags are only updated when you download PID_Compact
completely.
Downloading technology objects to device (Page 3543)
Startup
At the startup of the CPU, PID_Compact starts in the operating mode that was last active. To
retain PID_ Compact in "Inactive" mode, set sb_RunModeByStartup = FALSE.
Monitoring of the sampling time PID_Compact
Ideally, the sampling time is equivalent to the cycle time of the calling OB. The PID_Compact
instruction measures the time interval between two calls. This is the current sampling time. On
every switchover of operating mode and during the initial startup, the mean value is formed
from the first 10 sampling times. If the current sampling time deviates too much from this mean
value, Error = 0800 hex occurs and PID_Compact switches to "Inactive" mode.
PID_Compact, Version 1.1 or higher is set to "Inactive" mode during controller tuning under
the following conditions:
New mean value >= 1.1 x old mean value
New mean value <= 0.9 x old mean value
In automatic mode, PID_Compact, Version 1.1 or higher, is set to "Inactive" mode under the
following conditions:
New mean value >= 1.5 x old mean value
New mean value <= 0.5 x old mean value
During controller tuning and in automatic mode, PID_Compact 1.0 is set to "Inactive" operating
mode under the following conditions:
New mean value >= 1.1 x old mean value
New mean value <= 0.9 x old mean value
Current sampling time >= 1.5 x current mean value
Current sampling time <= 0.5 x current mean value
Sampling time of the PID algorithm
The controlled system needs a certain amount of time to respond to changes in the output
value. It is therefore not advisable to calculate the output value in every cycle. The sampling
time of the PID algorithm represents the time between two calculations of the output value. It
is calculated during tuning and rounded to a multiple of the cycle time. All other functions of
PID_Compact are executed at every call.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2298 System Manual, 01/2013,
PID algorithm
PID_Compact is a PIDT1 controller with anti-windup and weighting of the proportional and
derivative actions. The following equation is used to calculate the output value.
y = K
p
(w - x) + (c w - x)
[
(b w - x) +
1
T
I
s
T
D
s
a T
D
s + 1
]
Symbol Description
y Output value
K
p
Proportional gain
s Laplace operator
b Proportional action weighting
w Setpoint
x Process value
T
I
Integral action time
a Derivative delay coefficient (T1 = a T
D
)
Derivative action time
c Derivative action weighting
Block diagram of PID_Compact
PlDT1
Anti Windup
%
%
1
0
0
1
0
1
1 -
lnputWarning_H
lnputWarning_L
ManualEnable
b_lnput_PER_On
b_lnvCtrl
PV_ALRM CRP_lN
Limit
PWM
lNV
Limit CRP_OUT
lnput
Output
Output_PER
Output_PWM
ManualValue
lnput_PER
Setpoint
Scale
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2299
Block diagram of PIDT1 with anti-windup
-
-
-
Anti Windup
Scaledlnput (x)
Setpoint (w)
l LlMlT
K
P
c
b
DT1
y
Reaction to error
If errors occur, they are output in parameter Error, and PID_Compact changes to "Inactive"
mode. Reset the errors using the Reset parameter.
Control logic
An increase of the output value is generally intended to cause an increase in the process value.
This is referred to as a normal control logic. For cooling and discharge control systems, it may
be necessary to invert the control logic. PID_Compact does not work with negative proportional
gain. If InvertControl = TRUE, an increasing control deviation causes a reduction in the output
value. The control logic is also taken into account during pretuning and fine tuning.
See also
Controller type (Page 3561)
Input parameters of PID_Compact V1
Table 9-65
Parameter Data type Default Description
Setpoint REAL 0.0 Setpoint of the PID controller in automatic mode
Input REAL 0.0 A variable of the user program is used as source for the process value.
If you are using parameter Input, then
sPid_Cmpt.b_Input_PER_On = FALSE must be set.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2300 System Manual, 01/2013,
Parameter Data type Default Description
Input_PER WORD W#16#0 Analog input as the source of the process value
If you are using parameter Input_PER, then
sPid_Cmpt.b_Input_PER_On = TRUE must be set.
ManualEnable BOOL FALSE A FALSE -> TRUE edge selects "Manual mode", while State = 4,
sRet.i_Mode remains unchanged.
A TRUE -> FALSE edge selects the most recently active operating
mode, State =sRet.i_Mode
A change of sRet.i_Mode will not take effect during ManualEnable =
TRUE. The change of sRet.i_Mode will only be considered upon a
TRUE -> FALSE edge at ManualEnable .
PID_Compact V1.2 und PID_Compact V1.0
If at start of the CPU ManualEnable = TRUE, PID_Compact starts in
manual mode. A rising edge (FALSE > TRUE) at ManualEnable is not
necessary.
PID_Compact V1.1
At the start of the CPU, PID_Compact only switches to manual mode
with a rising edge (FALSE->TRUE) at ManualEnable . Without rising
edge, PID_Compact starts in the last operating mode in which
ManualEnable was FALSE.
ManualValue REAL 0.0 Manual value
This value is used as the output value in manual mode.
Reset BOOL FALSE The Reset parameter (Page 2310) restarts the controller.
Output parameters of PID_Compact V1
Parameter Data type Default Description
ScaledInput REAL 0.0 Output of the scaled process value
Outputs "Output", "Output_PER", and "Output_PWM" can be used concurrently.
Output REAL 0.0 Output value in REAL format
Output_PER WORD W#16#0 Analog output value
Output_PWM BOOL FALSE Pulse-width-modulated output value
The output value is formed by minimum On and Off times.
SetpointLimit_H BOOL FALSE If SetpointLimit_H = TRUE, the setpoint absolute high limit is reached.
The setpoint in the CPU is limited to the configured setpoint absolute
high limit. The configured process value absolute high limit is the
default for the setpoint high limit.
If you set sPid_Cmpt.r_Sp_Hlm to a value within the process value
limits, this value is used as the setpoint high limit.
SetpointLimit_L BOOL FALSE If SetpointLimit_L = TRUE, the setpoint absolute low limit has been
reached. In the CPU, the setpoint is limited to the configured setpoint
absolute low limit. The configured process value absolute low limit is
the default setting for the setpoint low limit.
If you set sPid_Cmpt.r_Sp_Llm to a value within the process value
limits, this value is used as the setpoint low limit.
InputWarning_H BOOL FALSE If InputWarning_H = TRUE, the process value has reached or
exceeded the warning high limit.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2301
Parameter Data type Default Description
InputWarning_L BOOL FALSE If InputWarning_L = TRUE, the process value has reached or fallen
below the warning low limit.
State INT 0 The State parameter (Page 2307) shows the current operating mode
of the PID controller. To change the operating mode, use variable
sRet.i_Mode.
State = 0: Inactive
State = 1: pretuning
State = 2: fine tuning
State = 3: Automatic mode
State = 4: Manual mode
Error DWORD W#16#0 The Error parameter (Page 2310) indicates the error messages.
Error = 0000: No error pending.
Static tags of PID_Compact V1
You must not change tags that are not listed. These are used for internal purposes only.
Table 9-66
Tag Data type Default Description
sb_GetCycleTime BOOL TRUE If sb_GetCycleTime = TRUE, the automatic
determination of the cycle time is started.
CycleTime.StartEstimation = FALSE once
measurement is complete.
sb_EnCyclEstimation BOOL TRUE If sb_EnCyclEstimation = TRUE, the sampling time
PID_Compact is calculated.
sb_EnCyclMonitoring BOOL TRUE If sb_EnCyclMonitoring = FALSE, the sampling time
PID_Compact is not monitored. If it is not possible to
execute PID_Compact within the sampling time, an
0800 error is not output and PID_Compact does not
change to "Inactive" mode.
sb_RunModeByStartup BOOL TRUE Activate Mode after CPU restart
If sb_RunModeByStartup = FALSE, the controller will
remain inactive after a CPU startup.
After a CPU startup and if sb_RunModeByStartup =
TRUE, the controller will return to the most recently
active operating mode.
si_Unit INT 0 Unit of measurement of the process value and
setpoint, e.g., C, or F.
si_Type INT 0 Physical quantity of the process value and setpoint,
e.g., temperature.
sd_Warning DWORD DW#16#0 Variable sd_warning (Page 2312) displays the
warnings generated since the reset, or since the last
change of the operating mode.
sBackUp.r_Gain REAL 1.0 Saved proportional gain
You can reload values from the sBackUp structure
with sPid_Cmpt.b_LoadBackUp = TRUE.
sBackUp.r_Ti REAL 20.0 Saved integral action time [s]
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2302 System Manual, 01/2013,
Tag Data type Default Description
sBackUp.r_Td REAL 0.0 Saved derivative action time [s]
sBackUp.r_A REAL 0.0 Saved derivative delay coefficient
sBackUp.r_B REAL 0.0 Saved proportional action weighting factor
sBackUp.r_C REAL 0.0 Saved derivative action weighting factor
sBackUp.r_Cycle REAL 1.0 Saved sampling time of PID algorithm
sPid_Calc.r_Cycle REAL 0.1 Sampling time of the PID_Compact instruction
r_Cycle is determined automatically and usually
equivalent to the cycle time of the calling OB.
sPid_Calc.b_RunIn BOOL FALSE b_RunIn = FALSE
Pretuning is started when fine tuning is started
from inactive or manual mode. If the requirements
for pretuning are not met, PID_Compact reacts like
b_RunIn = TRUE.
If fine tuning is started from automatic mode, the
system uses the existing PID parameters to control
to the setpoint.
Only then will fine tuning start. If pretuning is not
possible, PID_Compact will change to "Inactive"
mode.
b_RunIn = TRUE
The pretuning is skipped. PID_3Compact tries to
reach the setpoint with minimum or maximum
output value. This can produce increased
overshoot. Fine tuning then starts automatically.
b_RunIn is set to FALSE after fine tuning.
sPid_Calc.b_CalcParamSUT BOOL FALSE The parameters for pretuning will be recalculated if
b_CalcParamSUT = TRUE. This enables you to
change the parameter calculation method without
having to repeat controller tuning.
b_CalcParamSUT will be set to FALSE after
calculation.
sPid_Calc.b_CalcParamTIR BOOL FALSE The parameters for fine tuning will be recalculated if
b_CalcParamTIR = TRUE. This enables you to
change the parameter calculation method without
having to repeat controller tuning.
b_CalcParamTIR will be set to FALSE after
calculation.
sPid_Calc.i_CtrlTypeSUT INT 0 Methods used to calculate parameters during
pretuning:
i_CtrlTypeSUT = 0: PID according to Chien,
Hrones and Reswick
i_CtrlTypeSUT = 1: PI according to Chien, Hrones
and Reswick
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2303
Tag Data type Default Description
sPid_Calc.i_CtrlTypeTIR INT 0 Methods used to calculate parameters during fine
tuning:
i_CtrlTypeTIR = 0: PID automatic
i_CtrlTypeTIR = 1: PID rapid
i_CtrlTypeTIR = 2: PID slow
i_CtrlTypeTIR = 3: Ziegler-Nichols PID
i_CtrlTypeTIR = 4: Ziegler-Nichols PI
i_CtrlTypeTIR = 5: Ziegler-Nichols P
sPid_Calc.r_Progress REAL 0.0 Progress of tuning as a percentage (0.0 - 100.0)
sPid_Cmpt.r_Sp_Hlm REAL +3.402822e
+38
High limit of setpoint
If you set sPid_Cmpt.r_Sp_Hlm outside the process
value limits, the configured process value absolute
high limit is used as the setpoint high limit.
If you set sPid_Cmpt.r_Sp_Hlm within the process
value limits, this value is used as the setpoint high limit.
sPid_Cmpt.r_Sp_Llm REAL -3.402822e
+38
Low limit of the setpoint
If you set sPid_Cmpt.r_Sp_Llm outside the process
value limits, the configured process value absolute low
limit is used as the setpoint low limit.
If you set sPid_Cmpt.r_Sp_Llm within the process
value limits, this value is used as the setpoint low limit.
sPid_Cmpt.r_Pv_Norm_IN_1 REAL 0.0 Scaling Input_PER low
Input_PER is converted to percent based on the two
value pairs r_Pv_Norm_OUT_1, r_Pv_Norm_IN_1 and
r_Pv_Norm_OUT_2, r_Pv_Norm_IN_2 from the
sPid_Cmpt structure.
sPid_Cmpt.r_Pv_Norm_IN_2 REAL 27648.0 Scaling Input_PER high
Input_PER is converted to percent based on the two
value pairs r_Pv_Norm_OUT_1, r_Pv_Norm_IN_1 and
r_Pv_Norm_OUT_2, r_Pv_Norm_IN_2 from the
sPid_Cmpt structure.
sPid_Cmpt.r_Pv_Norm_OUT_1 REAL 0.0 Scaled low process value
Input_PER is converted to percent based on the two
value pairs r_Pv_Norm_OUT_1, r_Pv_Norm_IN_1 and
r_Pv_Norm_OUT_2, r_Pv_Norm_IN_2 from the
sPid_Cmpt structure.
sPid_Cmpt.r_Pv_Norm_OUT_2 REAL 100.0 Scaled high process value
Input_PER is converted to percent based on the two
value pairs r_Pv_Norm_OUT_1, r_Pv_Norm_IN_1 and
r_Pv_Norm_OUT_2, r_Pv_Norm_IN_2 from the
sPid_Cmpt structure.
sPid_Cmpt.r_Lmn_Hlm REAL 100.0 Output value high limit for output parameter "Output"
sPid_Cmpt.r_Lmn_Llm REAL 0.0 Low output value limit for output parameter "Output"
sPid_Cmpt.b_Input_PER_On BOOL TRUE If b_Input_PER_On = TRUE, then parameter
Input_PER is used. If b_Input_PER_On = FALSE, then
parameter Input is used.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2304 System Manual, 01/2013,
Tag Data type Default Description
sPid_Cmpt.b_LoadBackUp BOOL FALSE Activate the back-up parameter set. If an optimization
has failed, you can reactivate the previous PID
parameters by setting this bit.
sPid_Cmpt.b_InvCtrl BOOL FALSE Invert control logic
With b_InvCtrl = TRUE, a rising control deviation
reduces the output value.
sPid_Cmpt.r_Lmn_Pwm_PPTm REAL 0.0 The minimum ON time of the pulse width modulation
in seconds is rounded to
r_Lmn_Pwm_PPTm = r_Cycle or
r_Lmn_Pwm_PPTm = n*r_Cycle
sPid_Cmpt.r_Lmn_Pwm_PBTm REAL 0.0 The minimum OFF time of the pulse width modulation
in seconds is rounded to
r_Lmn_Pwm_PBTm = r_Cycle or
r_Lmn_Pwm_PBTm = n*r_Cycle
sPid_Cmpt.r_Pv_Hlm REAL 120.0 High limit of the process value
At the I/O input, the process value can be a maximum
of 18% higher than the standard range (overrange).
An error is no longer reported for a violation of the
"Process value high limit". Only a wire-break and a
short-circuit are recognized and the PID_Compact
switches to "Inactive" mode.
r_Pv_Hlm > r_Pv_Llm
sPid_Cmpt.r_Pv_Llm REAL 0.0 Low limit of the process value
r_Pv_Llm < r_Pv_Hlm
sPid_Cmpt.r_Pv_HWrn REAL +3.402822e
+38
Warning high limit of the process value
If you set r_Pv_HWrn outside the process value limits,
the configured process value absolute high limit is
used as the warning high limit.
If you set r_Pv_HWrn within the process value limits,
this value is used as the warning high limit.
r_Pv_HWrn > r_Pv_LWrn
r_Pv_HWrn r_Pv_Hlm
sPid_Cmpt.r_Pv_LWrn REAL -3.402822e
+38
Warning low limit of the process value
If you set r_Pv_LWrn outside the process value limits,
the configured process value absolute low limit is used
as the warning low limit.
If you set r_Pv_LWrn within the process value limits,
this value is used as the warning low limit.
r_Pv_LWrn < r_Pv_HWrn
r_Pv_LWrn r_Pv_LWrn
sParamCalc.i_Event_SUT INT 0 Variable i_Event_SUT (Page 2313) indicates the
current phase of "pretuning":
sParamCalc.i_Event_TIR INT 0 Variable i_Event_TIR (Page 2313) indicates the
current phase of "fine tuning":
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2305
Tag Data type Default Description
sRet.i_Mode INT 0 The operating mode is changed edge-triggered.
The following operating mode is enabled on a change
to
i_Mode = 0: "Inactive" (controller stop)
i_Mode = 1: "Pretuning" mode
i_Mode = 2: "Fine tuning" mode
i_Mode = 3: "Automatic mode"
i_Mode = 4: "Manual mode"
i_Mode is retentive.
sRet.r_Ctrl_Gain REAL 1.0 Active proportional gain
Gain is retentive.
sRet.r_Ctrl_Ti REAL 20.0 r_Ctrl_Ti > 0.0: active integral action time
r_Ctrl_Ti = 0.0: Integral action is disabled
r_Ctrl_Ti is retentive.
sRet.r_Ctrl_Td REAL 0.0 r_Ctrl_Td > 0.0: Active derivative action time
r_Ctrl_Td = 0.0: Derivative action is disabled
r_Ctrl_Td is retentive.
sRet.r_Ctrl_A REAL 0.0 Active derivative delay coefficient
r_Ctrl_A is retentive.
sRet.r_Ctrl_B REAL 0.0 Active proportional action weighting
r_Ctrl_B is retentive.
sRet.r_Ctrl_C REAL 0.0 Active derivative action weighting
r_Ctrl_C is retentive.
sRet.r_Ctrl_Cycle REAL 1.0 Active sampling time of the PID algorithm
r_Ctrl_Cycle is calculated during controller tuning and
rounded to an integer multiple of r_Cycle.
r_Ctrl_Cycle is retentive.
Note
Change the tags listed in this table in "Inactive" mode to prevent malfunction of the PID
controller. The "Inactive" mode is forced by setting variable "sRet.i_Mode" to "0".
See also
Downloading technology objects to device (Page 3543)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2306 System Manual, 01/2013,
Parameters State and sRet.i_Mode V1
Correlation of the parameters
The State parameter indicates the current operating mode of the PID controller. You cannot
modify the State parameter.
You need to modify the sRet.i_Mode tag to change the operating mode. This also applies when
the value for the new operating mode is already in sRet.i_Mode. First set sRet.i_Mode = 0 and
then sRet.i_Mode = 3. Provided the current operating mode of the controller supports this
change, State is set to the value of sRet.i_Mode.
When PID_Compact automatically switches the operating mode, the following applies: State !
= sRet.i_Mode.
Examples:
Successful pretuning
State = 3 and sRet.i_Mode = 1
Error
State = 0 and sRet.i_Mode remains at the same value, e.g sRet.i_Mode = 3
ManualEnalbe = TRUE
State = 4 and sRet.i_Mode remain at the previous value, for example, sRet.i_Mode = 3
Note
You wish to repeat successful fine tuning without exiting automatic mode with i_Mode = 0.
Setting sRet.i_Mode to an invalid value such as 9999 for one cycle has no effect on State.
Set Mode = 2 in the next cycle. You can generate a change to sRet.i_Mode without first
switching to "inactive" mode.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2307
Meaning of values
State /
sRet.i_Mode
Description of the operating mode
0 Inactive
The controller is switched off.
The controller was in "inactive" mode before pretuning was performed.
The PID controller will change to "inactive" mode when running if an error occurs or if the "Deactivate
controller" icon is clicked in the commissioning window.
1 Pretuning
The pretuning determines the process response to a jump of the output value and searches for the point of
inflection. The optimized PID parameters are calculated as a function of the maximum rate of rise and dead
time of the controlled system.
Pretuning requirements:
The controller is in inactive mode or manual mode
ManualEnable = FALSE
The process value must not be too close to the setpoint.
|Setpoint - Input| > 0.3 * |sPid_Cmpt.r_Pv_Hlm - sPid_Cmpt.r_Pv_Llm| and
|Setpoint - Input| > 0.5 * |Setpoint|
The setpoint may not be changed during pretuning.
The higher the stability of the process value, the easier it is to calculate the PID parameters and increase
precision of the result. Noise on the process value can be tolerated as long as the rate of rise of the process
value is significantly higher compared to the noise.
PID parameters are backed up before they are recalculated and can be reactivated with
sPid_Cmpt.b_LoadBackUp.
There is a change to automatic mode following successful pretuning and to "inactive" mode following
unsuccessful pretuning.
The phase of pretuning is indicated with Tag i_Event_SUT V1 (Page 2313).
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2308 System Manual, 01/2013,
State /
sRet.i_Mode
Description of the operating mode
2 Fine tuning
Fine tuning generates a constant, limited oscillation of the process value. The PID parameters are optimized
based on the amplitude and frequency of this oscillation. The differences between the process response
during pretuning and fine tuning are analyzed. All PID parameters are recalculated on the basis of the findings.
PID parameters from fine tuning usually have better master control and disturbance behavior than PID
parameters from pretuning.
PID_Compact automatically attempts to generate an oscillation greater than the noise of the process value.
Fine tuning is only minimally influenced by the stability of the process value.
PID parameters are backed up before they are recalculated and can be reactivated with
sPid_Cmpt.b_LoadBackUp.
Requirements for fine tuning:
No disturbances are expected.
The setpoint and the process value lie within the configured limits.
The setpoint may not be changed during fine tuning.
ManualEnable = FALSE
Automatic (State = 3), inactive (State = 0) or manual (State = 4) mode
Fine tuning proceeds as follows when started in:
Automatic mode (State = 3)
Start fine tuning in automatic mode if you wish to improve the existing PID parameters using controller
tuning.
PID_Comact will regulate using the existing PID parameters until the control loop has stabilized and the
requirements for fine tuning have been met. Only then will fine tuning start.
Inactive (State = 0) or manual (State = 4) mode
If the requirements for pretuning are met, pretuning is started. The PID parameters established will be
used for adjustment until the control loop has stabilized and the requirements for fine tuning have been
met. Only then will fine tuning start. If pretuning is not possible, PID_Compact will change to "Inactive"
mode.
An attempt is made to reach the setpoint with a minimum or maximum output value if the process value
for pretuning is already too near the setpoint or sPid_Calc.b_RunIn = TRUE. This can produce increased
overshoot.
The controller will change to "automatic mode" after successfully completed "fine tuning" and to "inactive"
mode if "fine tuning" has not been successfully completed.
The "Fine tuning" phase is indicated with Tag i_Event_TIR V1 (Page 2313).
3 Automatic mode
In automatic mode, PID_Compact corrects the controlled system in accordance with the parameters specified.
The controller changes to automatic mode if one the following conditions is fulfilled:
Pretuning successfully completed
Fine tuning successfully completed
Change of variable sRet.i_Mode to the value 3.
After CPU startup or change from Stop to RUN mode, PID_Compact will start in the most recently active
operating mode. To retain PID_Compact in "Inactive" mode, set sb_RunModeByStartup = FALSE.
4 Manual mode
In manual mode, you specify a manual output value in the ManualValue parameter.
This operating mode is enabled if sRet.i_Mode = 4, or at the rising edge on ManualEnable. If ManualEnable
changes to TRUE, only State will change. sRet.i_Mode will retain its current value. PID_Compact will return
to the previous operating mode upon a falling edge at ManualEnable.
The change to automatic mode is bumpless.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2309
See also
Output parameters of PID_Compact V1 (Page 2301)
Pretuning (Page 3571)
Fine tuning (Page 3573)
"Manual" mode (Page 3575)
Tag i_Event_SUT V1 (Page 2313)
Tag i_Event_TIR V1 (Page 2313)
Parameter Error V1
If several errors are pending simultaneously, the values of the error codes are displayed with
binary addition. The display of error code 0003, for example, indicates that the errors 0001
and 0002 are pending simultaneously.
Error
(DW#16#...)
Description
0000 There is no error.
0001 The "Input" parameter is outside the process value limits.
Input > sPid_Cmpt.r_Pv_Hlm or
Input < sPid_Cmpt.r_Pv_Llm
You cannot move the actuator again until you eliminate the error.
0002 Invalid value at "Input_PER" parameter. Check whether an error is pending at the analog input.
0004 Error during fine tuning. Oscillation of the process value could not be maintained.
0008 Error at start of pretuning. The process value is too close to the setpoint. Start fine tuning.
0010 The setpoint was changed during tuning.
0020 Pretuning is not permitted in automatic mode or during fine tuning.
0080 Incorrect configuration of output value limits.
Check whether the limits of the output value are configured correctly and match the control logic.
0100 Error during tuning resulted in invalid parameters.
0200 Invalid value at "Input" parameter: Value has an invalid number format.
0400 Calculation of output value failed. Check the PID parameters.
0800 Sampling time error: PID_Compact is not called within the sampling time of the cyclic interrupt OB.
1000 Invalid value at "Setpoint" parameter: Value has an invalid number format.
See also
Output parameters of PID_Compact V1 (Page 2301)
Parameter Reset V1
The response to Reset = TRUE depends on the version of the PID_Compact instruction.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2310 System Manual, 01/2013,
Reset response PID_Compact V.1.1 or higher
A rising edge at Reset resets the errors and warnings and clears the integral action. A falling
edge at Reset triggers a change to the most recently active operating mode.
i_Mode
State
t (ms)
Reset
3
0
1
0
3
0
1 2 3 1
t (ms)
t (ms)
Activation
Error
Reset
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2311
Reset response PID_Compact V.1.0
A rising edge at Reset resets the errors and warnings and clears the integral action. The
controller is not reactivated until the next edge at i_Mode.
4
0
i_Mode
State
Reset
t (ms)
3
1
0
3
0
1 2 3 1
4
t (ms)
t (ms)
Activation
Error
Reset
Tag sd_warning V1
If several warnings are pending, the values of variable sd_warning are displayed by means of
binary addition. The display of warning 0003, for example, indicates that the warnings 0001
and 0002 are also pending.
sd_warning
(DW#16#....)
Description
0000 No warning pending.
0001 The point of inflection was not found during pretuning.
0002 Oscillation increased during fine tuning.
0004 The setpoint was outside the set limits.
0008 Not all the necessary controlled system properties were defined for the selected method of calculation. The
PID parameters were instead calculated using the "i_CtrlTypeTIR = 3" method.
0010 The operating mode could not be changed because ManualEnable = TRUE.
0020 The cycle time of the calling OB limits the sampling time of the PID algorithm.
Improve results by using shorter OB cycle times.
0040 The process value exceeded one of its warning limits.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2312 System Manual, 01/2013,
The following warnings are deleted as soon as the cause is dealt with:
0004
0020
0040
All other warnings are cleared with a rising edge at Reset.
Tag i_Event_SUT V1
i_Event_SUT Name Description
0 SUT_INIT Initialize pretuning
100 SUT_STDABW Calculate the standard deviation
200 SUT_GET_POI Find the point of inflection
9900 SUT_IO Pretuning successful
1 SUT_NIO Pretuning not successful
See also
Static tags of PID_Compact V1 (Page 2302)
Parameters State and sRet.i_Mode V1 (Page 2307)
Tag i_Event_TIR V1
i_Event_TIR Name Description
-100 TIR_FIRST_SUT Fine tuning is not possible. Pretuning will be executed first.
0 TIR_INIT Initialize fine tuning
200 TIR_STDABW Calculate the standard deviation
300 TIR_RUN_IN Attempt to reach the setpoint
400 TIR_CTRLN Attempt to reach the setpoint with the existing PID parameters
(if pretuning has been successful)
500 TIR_OSZIL Determine oscillation and calculate parameters
9900 TIR_IO Fine tuning successful
1 TIR_NIO Fine tuning not successful
See also
Static tags of PID_Compact V1 (Page 2302)
Parameters State and sRet.i_Mode V1 (Page 2307)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2313
PID_3Step
New features of PID_3Step
PID_3Step V2.0
Reaction to error
The reaction to ActivateRecoverMode = TRUE has been completely overhauled.
PID_3Step is now more fault tolerant in the default setting.
NOTICE
Your system may be damaged.
If you use the default setting, PID_3Step remains in automatic mode even if the process
value limits are exceeded. This may damage your system.
It is essential to configure how your controlled system reacts in the event of an error to
protect your system from damage.
You use the ErrorAck input parameter to acknowledge the errors and warnings without
restarting the controller or clearing the integral action.
Switching operating modes does not acknowledge errors that are no longer pending.
Switching the operating mode
You specify the operating mode at the Mode in/out parameter and use a rising edge at
ModeActivate to start the operating mode. The Retain.Mode tag has been omitted.
The transition time measurement can no longer be started with GetTransitTime.Start, but
only with Mode = 6 and a rising edge at ModeActivate.
Multi-instance capability
You can call up PID_3Step as multi-instance DB. No technology object is created in this
case and no parameter assignment interface or commissioning interface is available. You
must assign parameters for PID_3Step directly in the multi-instance DB and commission it
via a watch table.
Startup characteristics
The operating mode specified at the Mode parameter is also started on a falling edge at
Reset and during a CPU cold restart, if RunModeByStartup = TRUE.
ENO characteristics
ENO is set depending on the operating mode.
If State = 0, then ENO = FALSE.
If State 0, then ENO = TRUE.
Manual mode
The Manual_UP and Manual_DN input parameters no longer function as edge-triggered
parameters. Edge-triggered manual mode continues to be possible using the
ManualUpInternal and ManualDnInternal tags.
In "Manual mode without endstop signals" (Mode = 10), the endstop signals Actuator_H
and Actuator_L are ignored even though they are activated.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2314 System Manual, 01/2013,
Default value of PID parameters
The following default settings have been changed:
Proportional action weighting (PWeighting) from 0.0 to 1.0
Derivative action weighting (DWeighting) from 0.0 to 1.0
Coefficient for derivative delay (TdFiltRatio) from 0.0 to 0.2
Limiting of motor transition time
You configure the maximum percentage of the motor transition time that the actuator will
travel in one direction in the Config.VirtualActuatorLimit tag.
Setpoint value specification during tuning
You configure the permitted fluctuation of the setpoint during tuning at the
CancelTuningLevel tag.
Switching a disturbance variable on
You can switch a disturbance variable on at the Disturbance parameter.
Troubleshooting
If the endstop signals are not activated (ActuatorEndStopOn = FALSE), ScaledFeedback
is determined without Actuator_H or Actuator_L.
PID_3Step V1.1
Manual mode on CPU startup
If ManualEnable = TRUE when the CPU starts, PID_3Step starts in manual mode. A rising
edge at ManualEnable is not necessary.
Reaction to error
The ActivateRecoverMode tag is no longer effective in manual mode.
Troubleshooting
The Progress tag is reset following successful tuning or transition time measurement.
Compatibility with CPU and FW
The following table shows which version of PID_3Step can be used on which CPU.
CPU FW PID_3Step
S7-1200 V3.X V1.0
V1.1
S7-1200 V2.X V1.0
V1.1
S7-1200 V1.X -
S7-1500 V1.X V2.0
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2315
PID_3Step V2
Description of PID_3Step V2
Description
You use the PID_3Step instruction to configure a PID controller with self tuning for valves or
actuators with integrating behavior.
The following operating modes are possible:
Inactive
Pretuning
Fine tuning
Automatic mode
Manual mode
Approach substitute output value
Transition time measurement
Error monitoring
Approach substitute output value with error monitoring
Manual mode without endstop signals
For a more detailed description of the operating modes, see the State parameter.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2316 System Manual, 01/2013,
PID algorithm
PID_3Step is a PIDT1 controller with anti-windup and weighting of the proportional and
derivative actions. The PID algorithm operates according to the following equation:
y = K
p
s (w - x) + (c w - x)
[
(b w - x) +
1
T
I
s
T
D
s
a T
D
s + 1
]
Symbol Description
y Output value of the PID algorithm
K
p
Proportional gain
s Laplace operator
b Proportional action weighting
w Setpoint
x Process value
T
I
Integral action time
T
D
Derivative action time
a Derivative delay coefficient (derivative delay T1 = a T
D
)
c Derivative action weighting
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2317
Block diagram without position feedback
1
0
ManualValue
ManualEnable
Adead_B
PV_ALRM
%
CRP_lN
lnput_PER
Scale
Limit
Setpoint
CRP_OUT
%
1/FAC
PulseOut
lnputPerOn
lnput
lnputWarning_H
lnputWarning_L
Disturbance
Output_PER
OutputPerOn
Output_DN
Output_UP
State
ManualDNlnternal
ManualUPlnternal
Manual_UP
PlDT1
Anti Windup
Anti Windup
Manual_DN
1
0
D
-
-
-
1
0
0.0 0.0
1 0
Limit
Av
ThrStp
Roc_Lim
0 1
1.0
0.0
1
0
1.0
0.0
Fac
lnt
1 0
0.0
0.0
OutputPerOn
State
1
0
1
0
Manual_UP Manual_DN
OutputUpperLimit
OutputLowerLimit
= 4
= 4
= 4
= 4
< 1
1
0
= 4
= 4
< 1
= 4
= 4
= 4
= 4
0
0
State
State
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2318 System Manual, 01/2013,
Block diagram with position feedback
State
ManualDNlnternal
ManualUPlnternal
= 4
= 4
= 4
PulseOut
Output_DN
Output_UP
Manual_UP
Manual_DN
< 1
< 1
= 4
= 4
= 4
= 4
0
0
State
State
PV_ALRM
%
CRP_lN
Scale
Limit
D
%
CRP_lN Scale
lnt
Limit Fac
CRP_OUT
%
Adead_B
ThrStp
lnputPerOn
lnput
Setpoint
lnput_PER
lnputWarning_H
lnputWarning_L
Feedback_PER
FeedbackPerOn
Feedback
OutputPerOn Output_PER
Anti Windup
Manual Value
State
Disturbance
PlDT1
Anti Windup
1
0
V
-
1
0
0
1
0.0
0.0
1
0
State
f 4
1
0
1
0
Manual_UP
Manual_DN
OutputUpperLimit
OutputLowerLimit
= 4
= 4
= 4
= 4
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2319
Block diagram of PIDT1 with anti-windup
c
b
K
P
1/Ti
Fac/Tt
-
Dead_B
-
-
D
l
DT1
-
Anti Windup
Scaledlnput (x)
Setpoint (w)
Ay
Call
PID_3Step is called in the constant time scale of a cycle interrupt OB.
If you call PID_3Step as a multi-instance DB, no technology object is created. No parameter
assignment interface or commissioning interface is available. You must assign parameters for
PID_3Step directly in the multi-instance DB and commission it via a watch table.
Download to device
The actual values of retentive tags are only updated when you download PID_3Step
completely.
Downloading technology objects to device (Page 3543)
Startup
When the CPU starts up, PID_3Step starts in the operating mode that is saved in the Mode in/
out parameter. To leave PID_3Step in "Inactive" mode, set RunModeByStartup = FALSE.
Reaction to error
In automatic mode and during commissioning, the reaction to error depends on the
ErrorBehaviour and ActivateRecoverMode tags. In manual mode, the reaction is independent
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2320 System Manual, 01/2013,
of ErrorBehaviour and ActivateRecoverMode. If ActivateRecoverMode = TRUE, the reaction
additionally depends on the error that occurred.
ErrorBeha
viour
ActivateRecov
erMode
Configuration editor
> actuator setting
> Set Output to
Reaction
FALSE FALSE Current output value Switch to "Inactive" mode (State = 0)
The actuator remains in the current
position.
FALSE TRUE Current output value while
error is pending
Switch to "Error monitoring" mode
(State = 7)
The actuator remains in the current
position while the error is pending.
TRUE FALSE Substitute output value Switch to "Approach substitute output
value" mode (State = 5)
The actuator moves to the configured
substitute output value.
Switch to "Inactive" mode (State = 0)
The actuator remains in the current
position.
TRUE TRUE Substitute output value while
error is pending
Switch to "Approach substitute output
value with error monitoring" mode
(State = 8)
The actuator moves to the configured
substitute output value.
Switch to "Error monitoring" mode
(State = 7)
In manual mode, PID_3Step uses ManualValue as output value, unless the following errors
occur:
2000h: Invalid value at Feedback_PER parameter.
4000h: Invalid value at Feedback parameter.
8000h: Error during digital position feedback.
You can only change the position of the actuator with Manual_UP and Manual_DN, not with
ManualValue.
The Error parameter indicates whether an error has occurred in this cycle. The ErrorBits
parameter shows which errors have occurred. ErrorBits is reset by a rising edge at Reset or
ErrorAck.
See also
Parameters State and Mode V2 (Page 2337)
Parameter ErrorBits V2 (Page 2341)
Configuring PID_3Step V2 (Page 3577)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2321
Mode of operation of PID_3Step V2
Monitoring process value limits
You specify the high limit and low limit of the process value in the Config.InputUpperLimit and
Config.InputLowerLimit tags. If the process value is outside these limits, an error occurs
(ErrorBits = 0001h).
You specify a high and low warning limit of the process value in the Config.InputUpperWarning
and Config.InputLowerWarning tags. If the process value is outside these warning limits, a
warning occurs (Warning = 0040h), and the InputWarning_H or InputWarning_L output
parameter changes to TRUE.
Limiting the setpoint
You specify a high limit and low limit of the setpoint in the Config.SetpointUpperLimit and
Config.SetpointLowerLimit tags. PID_3Step automatically limits the setpoint to the process
value limits. You can limit the setpoint to a smaller range. PID_3Step checks whether this range
falls within the process value limits. If the setpoint is outside these limits, the high or low limit
is used as the setpoint, and output parameter SetpointLimit_H or SetpointLimit_L is set to
TRUE.
The setpoint is limited in all operating modes.
Limiting the output value
You specify a high limit and low limit of the output value in the Config.OutputUpperLimit and
Config.OutputLowerLimit tags. The output value limits must be within "Low endstop" and "High
endstop".
High endstop: Config.FeedbackScaling.UpperPointOut
Low endstop: Config.FeedbackScaling.LowerPointOut
Rule:
UpperPointOut OutputUpperLimit > OutputLowerLimit LowerPointOut
The valid values for "High endstop" and "Low endstop" depend upon:
FeedbackOn
FeedbackPerOn
OutputPerOn
OutputPerOn FeedbackOn FeedbackPerOn LowerPointOut UpperPointOut
FALSE FALSE FALSE Cannot be set (0.0%) Cannot be set (100.0%)
FALSE TRUE FALSE -100.0% or 0.0% 0.0% or +100.0%
FALSE TRUE TRUE -100.0% or 0.0% 0.0% or +100.0%
TRUE FALSE FALSE Cannot be set (0.0%) Cannot be set (100.0%)
TRUE TRUE FALSE -100.0% or 0.0% 0.0% or +100.0%
TRUE TRUE TRUE -100.0% or 0.0% 0.0% or +100.0%
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2322 System Manual, 01/2013,
If OutputPerOn = FALSE and FeedbackOn = FALSE, you cannot limit the output value. The
digital outputs are reset when Actuator_H = TRUE or Actuator_L = TRUE, or after a travel time
of Config.VirtualActuatorLimit Retain.TransitTime/100.
The output value is 27648 at 100% and -27648 at -100%. PID_3Step must be able to close
the valve completely.
Substitute output value
If an error has occurred, PID_3Step can output a substitute output value and move the actuator
to a safe position that is specified in the SavePosition tag. The substitute output value must
be within the output value limits.
Monitoring signal validity
The values of the following parameters are monitored for validity when used:
Setpoint
Input
Input_PER
Input_PER
Feedback
Feedback_PER
Disturbance
ManualValue
SavePosition
Output_PER
Monitoring the PID_3Step sampling time
Ideally, the sampling time is equivalent to the cycle time of the calling OB. The PID_3Step
instruction measures the time interval between two calls. This is the current sampling time. On
every switchover of operating mode and during the initial startup, the mean value is formed
from the first 10 sampling times. Too great a difference between the current sampling time and
this mean value triggers an error (ErrorBits = 0800h).
The error occurs during tuning if:
New mean value >= 1.1 x old mean value
New mean value <= 0.9 x old mean value
The error occurs in automatic mode if:
New mean value >= 1.5 x old mean value
New mean value <= 0.5 x old mean value
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2323
If you deactivate the sampling time monitoring (CycleTime.EnMonitoring = FALSE), you can
also call PID_3Step in OB1. You must then accept a lower control quality due to the deviating
sampling time.
Sampling time of the PID algorithm
The controlled system needs a certain amount of time to respond to changes in the output
value. It is therefore not advisable to calculate the output value in every cycle. The sampling
time of the PID algorithm represents the time between two calculations of the output value. It
is calculated during tuning and rounded to a multiple of the cycle time. All other functions of
PID_3Step are executed at every call.
Measuring the motor transition time
The motor transition time is the time in seconds the motor requires to move the actuator from
the closed to the opened state. The actuator is moved in one direction for a maximum time of
Config.VirtualActuatorLimit Retain.TransitTime/100. PID_3Step requires the motor transition
time to be as accurate as possible for good controller results. The data in the actuator
documentation contains average values for this type of actuator. The value for the specific
actuator used may differ. You can measure the motor transition time during commissioning.
The output value limits are not taken into consideration during the motor transition time
measurement. The actuator can travel to the high or the low endstop.
Control logic
An increase of the output value is generally intended to cause an increase in the process value.
This is referred to as a normal control logic. For cooling and discharge control systems, it may
be necessary to invert the control logic. PID_3Step does not work with negative proportional
gain. If InvertControl = TRUE, an increasing control deviation causes a reduction in the output
value. The control logic is also taken into account during pretuning and fine tuning.
See also
Configuring PID_3Step V1 (Page 3593)
Changing the PID_3Step V2 interface
The following table shows what has changed in the PID_3Step instruction interface.
PID_3Step V1 PID_3Step V2 Change
Input_PER Input_PER Data type from Word to Int
Feedback_PER Feedback_PER Data type from Word to Int
Disturbance New
Manual_UP Manual_UP Function
Manual_DN Manual_DN Function
ErrorAck New
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2324 System Manual, 01/2013,
PID_3Step V1 PID_3Step V2 Change
ModeActivate New
Output_PER Output_PER Data type from Word to Int
ManualUPInternal New
ManualDNInternal New
CancelTuningLevel New
VirtualActuatorLImit New
Config.Loadbackup Loadbackup Renamed
Config.TransitTime Retain.TransitTime Renamed and retentivity added
GetTransitTime.Start Replaced by Mode and ModeActivate
SUT.CalculateSUTPara
ms
SUT.CalculateParams Renamed
SUT.TuneRuleSUT SUT.TuneRule Renamed
TIR.CalculateTIRParams TIR.CalculateParams Renamed
TIR.TuneRuleTIR TIR.TuneRule Renamed
Retain.Mode Mode Function
Declaration of static for in-out parameters
Input parameters of PID_3Step V2
Table 9-67
Parameter Data type Default Description
Setpoint REAL 0.0 Setpoint of the PID controller in automatic mode
Input REAL 0.0 A tag of the user program is used as the source of the process
value.
If you are using the Input parameter, then
Config.InputPerOn = FALSE must be set.
Input_PER INT 0 An analog input is used as the source of the process value.
If you are using the Input_PER parameter, then
Config.InputPerOn = TRUE must be set.
Actuator_H BOOL FALSE Digital position feedback of the valve for the high endstop
If Actuator_H = TRUE, the valve is at the high endstop and is
no longer moved towards this direction.
Actuator_L BOOL FALSE Digital position feedback of the valve for the low endstop
If Actuator_L = TRUE, the valve is at the low endstop and is no
longer moved towards this direction.
Feedback REAL 0.0 Position feedback of the valve
If you are using the Feedback parameter, then
Config.FeedbackPerOn = FALSE must be set.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2325
Parameter Data type Default Description
Feedback_PER INT 0 Analog position feedback of a valve
If you are using the Feedback_PER parameter, then
Config.FeedbackPerOn = TRUE must be set.
Feedback_PER is scaled based on the tags:
Config.FeedbackScaling.LowerPointIn
Config.FeedbackScaling.UpperPointIn
Config.FeedbackScaling.LowerPointOut
Config.FeedbackScaling.UpperPointOut
Disturbance REAL 0.0 Disturbance variable or precontrol value
ManualEnable BOOL FALSE A FALSE -> TRUE edge activates "manual mode", while
State = 4, Mode remain unchanged.
As long as ManualEnable = TRUE, you cannot change the
operating mode via a rising edge at ModeActivate or use
the commissioning dialog.
A TRUE -> FALSE edge activates the operating mode that
is specified by Mode.
We recommend that you change the operating mode using
ModeActivate only.
ManualValue REAL 0.0 In manual mode, the absolute position of the valve is specified.
ManualValue is only evaluated if you are using Output_PER,
or if position feedback is available.
Manual_UP BOOL FALSE Manual_UP = TRUE
The valve is opened even if you are using Output_PER or
a position feedback. The valve is no longer moved once the
high endstop is reached or if Manual_UP is set to TRUE for
longer than VirtualActuatorLimit Retain.TransitTime/100.
Manual_UP = FALSE
If you are using Output_PER or a position feedback, the
valve is moved to ManualValue. Otherwise, the valve is no
longer moved.
If Manual_UP and Manual_DN are set to TRUE simultaneously,
the valve is not moved.
Manual_DN BOOL FALSE Manual_DN = TRUE
The valve is closed even if you are using Output_PER or a
position feedback. The valve is no longer moved once the
low endstop is reached or if Manual_DN is set to TRUE for
longer than VirtualActuatorLimit Retain.TransitTime.
Manual_DN = FALSE
If you are using Output_PER or a position feedback, the
valve is moved to ManualValue. Otherwise, the valve is no
longer moved.
ErrorAck BOOL FALSE FALSE -> TRUE edge
ErrorBits and Warning are reset.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2326 System Manual, 01/2013,
Parameter Data type Default Description
Reset BOOL FALSE Restarts the controller.
FALSE -> TRUE edge
Switch to "Inactive" mode
ErrorBits and Warning are reset.
Integral action is cleared
(PID parameters are retained)
As long as Reset = TRUE, PID_3Step remains in "Inactive"
mode (State = 0).
TRUE -> FALSE edge
PID_3Step switches to the operating mode that is saved in
the Mode parameter.
ModeActivate BOOL FALSE FALSE -> TRUE edge
PID_3Step switches to the operating mode that is saved in
the Mode parameter.
Output parameters of PID_3Step V2
Table 9-68
Parameter Data type Default Description
ScaledInput REAL 0.0 Scaled process value
ScaledFeedback REAL 0.0 Scaled position feedback
For an actuator without position feedback, the position of the
actuator indicated by ScaledFeedback is very imprecise.
ScaledFeedback may only be used for rough estimation of the
current position in this case.
Output_UP BOOL FALSE Digital output value for opening the valve
If Config.OutputPerOn = FALSE, the Output_UP parameter is
used.
Output_DN BOOL FALSE Digital output value for closing the valve
If Config.OutputPerOn = FALSE, the Output_DN parameter is
used.
Output_PER INT 0 Analog output value
If Config.OutputPerOn = TRUE, Output_PER is used.
SetpointLimit_H BOOL FALSE If SetpointLimit_H = TRUE, the absolute setpoint high limit is
reached (Setpoint Config.SetpointUpperLimit).
The setpoint is limited to Config.SetpointUpperLimit .
SetpointLimit_L BOOL FALSE If SetpointLimit_L = TRUE, the absolute setpoint low limit has
been reached (Setpoint Config.SetpointLowerLimit).
The setpoint is limited to Config.SetpointLowerLimit .
InputWarning_H BOOL FALSE If InputWarning_H = TRUE, the process value has reached or
exceeded the warning high limit.
InputWarning_L BOOL FALSE If InputWarning_L = TRUE, the process value has reached or
fallen below the warning low limit.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2327
Parameter Data type Default Description
State INT 0 The State parameter (Page 2337) shows the current operating
mode of the PID controller. You can change the operating
mode using the input parameter Mode and a rising edge at
ModeActivate.
State = 0: Inactive
State = 1: Pretuning
State = 2: Fine tuning
State = 3: Automatic mode
State = 4: Manual mode
State = 5: Approach substitute output value
State = 6: Transition time measurement
State = 7: Error monitoring
State = 8: Approach substitute output value with error
monitoring
State = 10: Manual mode without end stop signals
Error BOOL FALSE If Error = TRUE, at least one error message is pending in this
cycle.
ErrorBits DWORD DW#16#0 The ErrorBits parameter (Page 2341) shows which error
messages are pending. ErrorBits is retentive and is reset upon
a rising edge at Reset or ErrorAck.
See also
Parameters State and Mode V2 (Page 2337)
Parameter ErrorBits V2 (Page 2341)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2328 System Manual, 01/2013,
In-out parameters of PID_3Step V2
Table 9-69
Parameter Data type Default Description
Mode INT 4 At the Mode parameter, you specify the operating mode to
which PID_3Step is to switch. Options are:
Mode = 0: Inactive
Mode = 1: Pretuning
Mode = 2: Fine tuning
Mode = 3: Automatic mode
Mode = 4: Manual mode
Mode = 6: Transition time measurement
Mode = 10: Manual mode without endstop signals
The operating mode is activated by:
Rising edge at ModeActivate
Falling edge at Reset
Falling edge at ManualEnable
Cold restart of CPU if RunModeByStartup = TRUE
Mode is retentive.
A detailed description of the operating modes can be found in
Parameters State and Mode V2 (Page 2337).
Static tags of PID_3Step V2
You must not change tags that are not listed. These are used for internal purposes only.
Tag Data type Default Description
ManualUpInternal BOOL FALSE In manual mode, each rising edge opens the valve by 5% of the total
control range or for the duration of the minimum motor transition
time. ManualUpInternal is only evaluated if you are not using
Output_PER or position feedback. This tag is used in the
commissioning dialog.
ManualDnInternal BOOL FALSE In manual mode, every rising edge closes the valve by 5% of the
total control range or for the duration of the minimum motor transition
time. ManualDnInternal is only evaluated if you are not using
Output_PER or position feedback. This tag is used in the
commissioning dialog.
ActivateRecoverMode BOOL TRUE The ActivateRecoverMode V2 (Page 2344) tag determines the
reaction to error.
RunModeByStartup BOOL TRUE Activate operating mode at Mode parameter after CPU restart
If RunModeByStartup = TRUE, PID_3Step starts in the operating
mode saved in the Mode parameter after CPU startup.
If RunModeByStartup = FALSE, PID_3Step remains in "Inactive"
mode after CPU startup.
LoadBackUp BOOL FALSE If LoadBackUp = TRUE, the last set of PID parameters is reloaded.
The set was saved prior to the last tuning. LoadBackUp is
automatically set back to FALSE.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2329
Tag Data type Default Description
PhysicalUnit INT 0 Unit of measurement of the process value and setpoint, e.g., C, or
F.
PhysicalQuantity INT 0 Physical quantity of the process value and setpoint, e.g.,
temperature.
ErrorBehaviour BOOL FALSE If ErrorBehaviour = FALSE and an error has occurred, the valve
stays at its current position and the controller switches directly to
"Inactive" or "Error monitoring" mode.
If ErrorBehaviour = TRUE and an error occurs, the actuator moves
to the substitute output value and only then switches to "Inactive" or
"Error monitoring" mode.
If the following errors occur, you can no longer move the valve to a
configured substitute output value.
2000h: Invalid value at Feedback_PER parameter.
4000h: Invalid value at Feedback parameter.
8000h: Error during digital position feedback.
20000h: Invalid value at SavePosition tag.
Warning DWORD DW#16#
0
The Warning tag (Page 2337) shows the warnings since Reset =
TRUE or ErrorAck =TRUE. Warning is retentive.
Cyclic warnings (for example, process value warning) are shown
until the cause of the warning is removed. They are automatically
deleted once their cause has gone. Non-cyclic warnings (for
example, point of inflection not found) remain and are deleted like
errors.
SavePosition REAL 0.0 Substitute output value
If ErrorBehaviour = TRUE, the actuator is moved to a position that
is safe for the plant when an error occurs. As soon as the substitute
output value has been reached, PID_3Step switches the operating
mode according to ActivateRecoverMode.
CurrentSetpoint REAL 0.0 Currently active setpoint. This value is frozen at the start of tuning.
CancelTuningLevel REAL 10.0 Permissible fluctuation of setpoint during tuning. Tuning is not
canceled until:
Setpoint > CurrentSetpoint + CancelTuningLevel
or
Setpoint < CurrentSetpoint - CancelTuningLevel
Progress REAL 0.0 Progress of tuning as a percentage (0.0 - 100.0)
Config.InputPerOn BOOL TRUE If InputPerOn = TRUE, the Input_PER parameter is used. If
InputPerOn = FALSE, the Input parameter is used.
Config.OutputPerOn BOOL FALSE If OutputPerOn = TRUE, the Output_PER parameter is used. If
OutputPerOn = FALSE, the Ouput_UP and Output_DN parameters
are used.
Config.InvertControl BOOL FALSE Invert control logic
If InvertControl = TRUE, an increasing control deviation causes a
reduction in the output value.
Config.FeedbackOn BOOL FALSE If FeedbackOn = FALSE, a position feedback is simulated.
Position feedback is generally activated when
FeedbackOn = TRUE.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2330 System Manual, 01/2013,
Tag Data type Default Description
Config.FeedbackPerOn BOOL FALSE FeedbackPerOn is only effective when FeedbackOn = TRUE.
If FeedbackPerOn = TRUE, the analog input is used for the position
feedback (Feedback_PER parameter).
If FeedbackPerOn = FALSE, the Feedback parameter is used for
the position feedback.
Config.ActuatorEndStopOn BOOL FALSE If ActuatorEndStopOn = TRUE, the digital position feedback
Actuator_L and Actuator_H are taken into consideration.
Config.InputUpperLimit REAL 120.0 High limit of the process value
Input and Input_PER are monitored to ensure adherence to this limit.
At the I/O input, the process value can be a maximum of 18% higher
than the standard range (overrange). An error is no longer signaled
due to a violation of the "Process value high limit". Only a wire-break
and a short-circuit are recognized and PID_3Step reacts according
to the configured reaction to error.
InputUpperLimit > InputLowerLimit
Config.InputLowerLimit REAL 0.0 Low limit of the process value
InputLowerLimit < InputUpperLimit
Config.InputUpperWarning REAL +3.40282
2e+38
Warning high limit of the process value
If you set InputUpperWarning outside the process value limits, the
configured absolute process value high limit is used as the warning
high limit.
If you configure InputUpperWarning within the process value limits,
this value is used as the warning high limit.
InputUpperWarning > InputLowerWarning
InputUpperWarning InputUpperLimit
Config.InputLowerWarning REAL -3.40282
2e+38
Warning low limit of the process value
If you set InputLowerWarning outside the process value limits, the
configured absolute process value low limit is used as the warning
low limit.
If you configure InputLowerWarning within the process value limits,
this value is used as the warning low limit.
InputLowerWarning < InputUpperWarning
InputLowerWarning InputLowerLimit
Config.OutputUpperLimit REAL 100.0 High limit of output value
For details, see OutputLowerLimit
Config.OutputLowerLimit REAL 0.0 Low limit of output value
If OutputPerOn = TRUE or FeedbackOn = TRUE, the range of
values from -100% to +100%, including zero, is valid. At -100%,
Output = -27648; at +100%, Output = 27648
If OutputPerOn = FALSE, the range of values from 0% to 100% is
valid. The valve is completely closed at 0% and completely opened
at 100%.
Config.SetpointUpperLimit REAL +3.40282
2e+38
High limit of setpoint
If you set SetpointUpperLimit outside the process value limits, the
configured absolute process value high limit is preassigned as the
setpoint high limit.
If you configure SetpointUpperLimit within the process value limits,
this value is used as the setpoint high limit.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2331
Tag Data type Default Description
Config.SetpointLowerLimit REAL -
3.402822
e+38
Low limit of the setpoint
If you set SetpointLowerLimit outside the process value limits, the
configured absolute process value low limit is preassigned as the
setpoint low limit.
If you set SetpointLowerLimit within the process value limits, this
value is used as the setpoint low limit.
Config.MinimumOnTime REAL 0.0 Minimum ON time
Minimum time in seconds for which the servo drive must be switched
on.
Config.MinimumOffTime REAL 0.0 Minimum OFF time
Minimum time in seconds for which the servo drive must be switched
off.
Config.VirtualActuatorLimit REAL 150.0 If the actuator is moved in one direction for longer than
VirtualActuatorLimit Retain.TransitTime/100, the warning 2000h
is output.
If Config.ActuatorEndStopOn = FALSE, the actuator is moved in
one direction for a maximum time of
VirtualActuatorLimit Retain.TransitTime/100.
Config.InputScaling.UpperPoi
ntIn
REAL 27648.0 Scaling Input_PER high
Input_PER is converted to a percentage based on the two value
pairs UpperPointOut, UpperPointIn and LowerPointOut,
LowerPointIn of the InputScaling structure.
Config.InputScaling.LowerPoi
ntIn
REAL 0.0 Scaling Input_PER low
Input_PER is converted to a percentage based on the two value
pairs UpperPointOut, UpperPointIn and LowerPointOut,
LowerPointIn of the InputScaling structure.
Config.InputScaling.UpperPoi
ntOut
REAL 100.0 Scaled high process value
Input_PER is converted to a percentage based on the two value
pairs UpperPointOut, UpperPointIn and LowerPointOut,
LowerPointIn of the InputScaling structure.
Config.InputScaling.LowerPoi
ntOut
REAL 0.0 Scaled low process value
Input_PER is converted to a percentage based on the two value
pairs UpperPointOut, UpperPointIn and LowerPointOut,
LowerPointIn of the InputScaling structure.
Config.FeedbackScaling.Uppe
rPointIn
REAL 27648.0 Scaling Feedback_PER high
Feedback_PER is converted to a percentage based on the two value
pairs UpperPointOut, UpperPointIn and LowerPointOut,
LowerPointIn of the FeedbackScaling structure.
Config.FeedbackScaling.Lowe
rPointIn
REAL 0.0 Scaling Feedback_PER low
Feedback_PER is converted to a percentage based on the two value
pairs UpperPointOut, UpperPointIn and LowerPointOut,
LowerPointIn of the FeedbackScaling structure.
Config.FeedbackScaling.Uppe
rPointOut
REAL 100.0 High endstop
Feedback_PER is converted to a percentage based on the two value
pairs UpperPointOut, UpperPointIn and LowerPointOut,
LowerPointIn of the FeedbackScaling structure.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2332 System Manual, 01/2013,
Tag Data type Default Description
Config.FeedbackScaling.Lowe
rPointOut
REAL 0.0 Low endstop
Feedback_PER is converted to a percentage based on the two value
pairs UpperPointOut, UpperPointIn and LowerPointOut,
LowerPointIn of the FeedbackScaling structure.
GetTransitTime.InvertDirectio
n
BOOL FALSE If InvertDirection = FALSE, the valve is fully opened, closed, and
then reopened in order to determine the valve transition time.
If InvertDirection = TRUE, the valve is fully closed, opened, and then
closed again.
GetTransitTime.SelectFeedba
ck
BOOL FALSE If SelectFeedback = TRUE, then Feedback_PER, or Feedback is
taken into consideration in the transition time measurement.
If SelectFeedback = FALSE, then Actuator_H and Actuator_L are
taken into consideration in the transition time measurement.
GetTransitTime.State INT 0 Current phase of the transition time measurement
State = 0: Inactive
State = 1: Open valve completely
State = 2: Close valve completely
State = 3: Move valve to target position (NewOutput)
State = 4: Transition time measurement successfully completed
State = 5: Transition time measurement canceled
GetTransitTime.NewOutput REAL 0.0 Target position for transition time measurement with position
feedback
The target position must be between "High endstop" and "Low
endstop". The difference between NewOutput and ScaledFeedback
must be at least 50% of the permissible control range.
CycleTime.StartEstimation BOOL TRUE If StartEstimation = TRUE, the measurement of the PID_3Step
sampling time is started. CycleTime.StartEstimation = FALSE once
measurement is complete.
CycleTime.EnEstimation BOOL TRUE If EnEstimation = TRUE, the PID_3Step sampling time is calculated.
If CycleTime.EnEstimation = FALSE, the PID_3Step sampling time
is not calculated and you need to correct the configuration of
CycleTime.Value manually.
CycleTime.EnMonitoring BOOL TRUE If EnMonitoring = TRUE, the PID_3Step sampling time is monitored.
If it is not possible to execute PID_3Step within the sampling time,
the error 0800h is output and the operating mode is switched.
ActivateRecoverMode and ErrorBehaviour determine which
operating mode is switched to.
If EnMonitoring = FALSE, the PID_3Step sampling time is not
monitored, the error 0800h is not output, and the operating mode is
not switched.
CycleTime.Value REAL 0.1 PID_3Step sampling time in seconds
CycleTime.Value is determined automatically and is usually
equivalent to the cycle time of the calling OB.
CtrlParamsBackUp.SetByUser BOOL FALSE Saved value of Retain.CtrlParams.SetByUser.
You can reload values from the CtrlParamsBackUp structure with
LoadBackUp = TRUE.
CtrlParamsBackUp.Gain REAL 1.0 Saved proportional gain
CtrlParamsBackUp.Ti REAL 20.0 Saved integral action time in seconds
CtrlParamsBackUp.Td REAL 0.0 Saved derivative action time in seconds
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2333
Tag Data type Default Description
CtrlParamsBackUp.TdFiltRati
o
REAL 0.0 Saved derivative delay coefficient
CtrlParamsBackUp.PWeightin
g
REAL 0.0 Saved proportional action weighting
CtrlParamsBackUp.DWeightin
g
REAL 0.0 Saved derivative action weighting
CtrlParamsBackUp.Cycle REAL 1.0 Saved sampling time of PID algorithm in seconds
CtrlParamsBackUp.InputDead
Band
REAL 0.0 Saved dead band width of the control deviation
PIDSelfTune.SUT.CalculateP
arams
BOOL FALSE The properties of the controlled system are saved during tuning. If
CalculateParams = TRUE, the PID parameters are recalculated on
the basis of these properties. The PID parameters are calculated
using the method set in TuneRule. CalculateParams is set to FALSE
following calculation.
PIDSelfTune.SUT.TuneRule INT 1 Methods used to calculate parameters during pretuning:
SUT.TuneRule = 0: PID rapid I
SUT.TuneRule = 1: PID slow I
SUT.TuneRule = 2: Chien, Hrones and Reswick PID
SUT.TuneRule = 3: Chien, Hrones, Reswick PI
SUT.TuneRule = 4: PID rapid II
SUT.TuneRule = 5: PID slow II
PIDSelfTune.SUT.State INT 0 The SUT.State tag indicates the current phase of pretuning:
State = 0: Initialize pretuning
State = 50: Determine start position without position feedback
State = 100: Calculate standard deviation
State = 200: Determine point of inflection
State = 300: Determine rise time
State = 9900: Pretuning successful
State = 1: Pretuning not successful
PIDSelfTune.TIR.RunIn BOOL FALSE With the RunIn tag, you can specify that fine tuning can also be
performed without pretuning.
RunIn = FALSE
Pretuning is started when fine tuning is started from inactive or
manual mode.
If fine tuning is started from automatic mode, the system uses
the existing PID parameters to control to the setpoint.
Only then will fine tuning start. If pretuning is not possible,
PID_3Step switches to the mode from which tuning was started.
RunIn = TRUE
The pretuning is skipped. PID_3Step attempts to reach the
setpoint with the minimum or maximum output value. This can
produce increased overshoot. Only then will fine tuning start.
RunIn is set to FALSE after fine tuning.
PIDSelfTune.TIR.CalculatePar
ams
BOOL FALSE The properties of the controlled system are saved during tuning. If
CalculateParams = TRUE, the PID parameters are recalculated on
the basis of these properties. The PID parameters are calculated
using the method set in TuneRule. CalculateParams is set to FALSE
following calculation.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2334 System Manual, 01/2013,
Tag Data type Default Description
PIDSelfTune.TIR.TuneRule INT 0 Methods used to calculate parameters during fine tuning:
TIR.TuneRule = 0: PID automatic
TIR.TuneRule = 1: PID rapid
TIR.TuneRule = 2: PID slow
TIR.TuneRule = 3: Ziegler-Nichols PID
TIR.TuneRule = 4: Ziegler-Nichols PI
TIR.TuneRule = 5: Ziegler-Nichols P
PIDSelfTune.TIR.State INT 0 The TIR.State tag indicates the current phase of fine tuning:
State = -100 Fine tuning is not possible. Pretuning will be
performed first.
State = 0: Initialize fine tuning
State = 200: Calculate standard deviation
State = 300: Attempt to reach the setpoint with the maximum or
minimum output value
State = 400: Attempt to reach the setpoint with existing PID
parameters
(if pretuning was successful)
State = 500: Determine oscillation and calculate parameters
State = 9900: Fine tuning successful
State = 1: Fine tuning not successful
Retain.TransitTime REAL 30.0 Motor transition time in seconds
Time in seconds the actuating drive requires to move the valve from
the closed to the opened state.
TransitTime is retentive.
Retain.CtrlParams.SetByUser BOOL FALSE If SetByUser = FALSE, the PID parameters are determined
automatically and PID_3Step operates with a dead band at the
output value. The dead band width is calculated during tuning on
the basis of the standard deviation of the output value and saved in
Retain.CtrlParams.OutputDeadBand.
If SetByUser = TRUE, the PID parameters are entered manually
and PID_3 Step operates without a dead band at the output value.
Retain.CtrlParams.OutputDeadBand = 0.0
SetByUser is retentive.
Retain.CtrlParams.Gain REAL 1.0 Active proportional gain
To invert the control logic, use the Config.InvertControl tag.
Negative values at Gain also invert the control logic. We recommend
you use only InvertControl to set the control logic. The control logic
is also inverted if InvertControl = TRUE and Gain < 0.0.
Gain is retentive.
Retain.CtrlParams.Ti REAL 20.0 Ti > 0.0: Active integral action time in seconds
Ti = 0.0: Integral action is deactivated
Ti is retentive.
Retain.CtrlParams.Td REAL 0.0 Td > 0.0: Active derivative action time in seconds
Td = 0.0: Derivative action is deactivated
Td is retentive.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2335
Tag Data type Default Description
Retain.CtrlParams.TdFiltRatio REAL 0.2 Active derivative delay coefficient
The derivative delay coefficient delays the effect of the derivative
action.
Derivative delay = derivative action time derivative delay
coefficient
0.0: Derivative action is effective for one cycle only and therefore
almost not effective.
0.5: This value has proved useful in practice for controlled
systems with one dominant time constant.
> 1.0: The greater the coefficient, the longer the effect of the
derivative action is delayed.
TdFiltRatio is retentive.
Retain.CtrlParams.PWeighting REAL 1.0 Active proportional action weighting
The proportional action may weaken with changes to the setpoint.
Values from 0.0 to 1.0 are applicable.
1.0: Proportional action for setpoint change is fully effective
0.0: Proportional action for setpoint change is not effective
The proportional action is always fully effective when the process
value is changed.
PWeighting is retentive.
Retain.CtrlParams.DWeightin
g
REAL 1.0 Active derivative action weighting
The derivative action may weaken with changes to the setpoint.
Values from 0.0 to 1.0 are applicable.
1.0: Derivative action is fully effective upon setpoint change
0.0: Derivative action is not effective upon setpoint change
The derivative action is always fully effective when the process value
is changed.
DWeighting is retentive.
Retain.CtrlParams.Cycle REAL 1.0 Active sampling time of PID algorithm in seconds, rounded to an
integer multiple of the cycle time of the calling OB.
Cycle is retentive.
Retain.CtrlParams.InputDead
Band
REAL 0.0 Dead band width of the control deviation
InputDeadBand is retentive.
Note
Change the tags listed in this table in "Inactive" mode to prevent malfunction of the PID
controller.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2336 System Manual, 01/2013,
See also
Parameters State and Mode V2 (Page 2337)
Tag ActivateRecoverMode V2 (Page 2344)
Downloading technology objects to device (Page 3543)
Parameters State and Mode V2
Correlation of the parameters
The State parameter shows the current operating mode of the PID controller. You cannot
change the State parameter.
With a rising edge at ModeActivate, PID_3Step switches to the operating mode saved in the
Mode in-out parameter.
When the CPU is switched on or switches from Stop to RUN mode, PID_3Step starts in the
operating mode that is saved in the Mode parameter. To leave PID_Compact in "Inactive"
mode, set RunModeByStartup = FALSE.
Meaning of values
State Description of operating mode
0 Inactive
The controller is switched off and no longer changes the valve position.
1 Pretuning
The pretuning determines the process response to a pulse of the output value and searches for the point of
inflection. The PID parameters are calculated from the maximum rate of rise and dead time of the controlled
system. You obtain the best PID parameters when you perform pretuning and fine tuning.
Pretuning requirements:
The motor transition time has been configured or measured.
Inactive (State = 0), manual mode (State = 4), or automatic mode (State = 3)
ManualEnable = FALSE
Reset = FALSE
The setpoint and the process value lie within the configured limits.
The more stable the process value is, the easier it is to calculate the PID parameters and the more precise
the result will be. Noise on the process value can be tolerated as long as the rate of rise of the process value
is significantly higher as compared to the noise. This is most likely the case in operating modes "Inactive"
and "manual mode".
The setpoint is frozen in the CurrentSetpoint tag. Tuning is canceled when:
Setpoint > CurrentSetpoint + CancelTuningLevel
or
Setpoint < CurrentSetpoint - CancelTuningLevel
Before the PID parameters are recalculated, they are backed up and can be reactivated with LoadBackUp.
The controller switches to automatic mode following successful pretuning. If pretuning is unsuccessful, the
switchover of operating mode is dependent on ActivateRecoverMode and ErrorBehaviour.
The pretuning phase is indicated with the SUT.State tag.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2337
State Description of operating mode
2 Fine tuning
Fine tuning generates a constant, limited oscillation of the process value. The PID parameters are recalculated
based on the amplitude and frequency of this oscillation. PID parameters from fine tuning usually have better
master control and disturbance characteristics than PID parameters from pretuning. You obtain the best PID
parameters when you perform pretuning and fine tuning.
PID_3Step automatically attempts to generate an oscillation greater than the noise of the process value. Fine
tuning is only minimally influenced by the stability of the process value.
The setpoint is frozen in the CurrentSetpoint tag. Tuning is canceled when:
Setpoint > CurrentSetpoint + CancelTuningLevel
or
Setpoint < CurrentSetpoint - CancelTuningLevel
The PID parameters are backed up before fine tuning. They can be reactivated with LoadBackUp.
Requirements for fine tuning:
The motor transition time has been configured or measured.
The setpoint and the process value lie within the configured limits.
ManualEnable = FALSE
Reset = FALSE
Automatic (State = 3), inactive (State = 0) or manual (State = 4) mode
Fine tuning proceeds as follows when started from:
Automatic mode (State = 3)
Start fine tuning from automatic mode if you wish to improve the existing PID parameters through tuning.
PID_3Step controls the system using the existing PID parameters until the control loop has stabilized and
the requirements for fine tuning have been met. Only then will fine tuning start.
Inactive (State = 0) or manual mode (State = 4)
If the requirements for pretuning are met, pretuning is started. The determined PID parameters will be
used for control until the control loop has stabilized and the requirements for fine tuning have been met.
If PIDSelfTune.TIR.RunIn = TRUE, pretuning is skipped and an attempt is made to reach the setpoint with
the minimum or maximum output value. This can produce increased overshoot. Fine tuning then starts
automatically.
The controller switches to automatic mode following successful fine tuning. If fine tuning is unsuccessful, the
switchover of operating mode is dependent on ActivateRecoverMode and ErrorBehaviour.
The fine tuning phase is indicated with the TIR.State tag.
3 Automatic mode
In automatic mode, PID_3Step controls the controlled system in accordance with the parameters specified.
The controller switches to automatic mode if one the following requirements is fulfilled:
Pretuning successfully completed
Fine tuning successfully completed
Changing of the Mode in-out parameter to the value 3 and a rising edge at ModeActivate.
The switchover from automatic mode to manual mode is only bumpless if carried out in the commissioning
editor.
The ActivateRecoverMode tag is taken into consideration in automatic mode.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2338 System Manual, 01/2013,
State Description of operating mode
4 Manual mode
In manual mode, you specify manual output values in the Manual_UP and Manual_DN parameters or
ManualValue parameter. Whether or not the actuator can be moved to the output value in the event of an
error is described in the ErrorBits parameter.
You can also activate this operating mode using ManualEnable = TRUE. We recommend that you change
the operating mode using Mode and ModeActivate only.
The switchover from manual mode to automatic mode is bumpless. Manual mode is also possible when an
error is pending.
5 Approach substitute output value
This operating mode is activated in the event of an error, if Errorbehaviour = TRUE and ActivateRecoverMode
= FALSE..
PID_3Step moves the actuator to the substitute output value and then switches to "Inactive" mode.
6 Transition time measurement
The time that the motor needs to completely open the valve from the closed condition is determined.
This operating mode is activated when Mode = 6 and ModeActivate = TRUE is set.
If endstop signals are used to measure the transition time, the valve will be opened completely from its current
position, closed completely, and opened completely again. If GetTransitTime.InvertDirection = TRUE, this
behavior is inverted.
If position feedback is used to measure the transition time, the actuator will be moved from its current position
to a target position.
The output value limits are not taken into consideration during the transition time measurement. The actuator
can travel to the high or the low endstop.
7 Error monitoring
The control algorithm is switched off and no longer changes the valve position.
This operating mode is activated instead of "Inactive" mode in the event of an error.
All the following conditions must be met:
Automatic mode (Mode = 3)
Errorbehaviour = FALSE
ActivateRecoverMode = TRUE
One or more errors have occurred in which ActivateRecoverMode (Page 2344) is effective.
As soon as the errors are no longer pending, PID_3Step switches back to automatic mode.
8 Approach substitute output value with error monitoring
This operating mode is activated instead of "approach substitute output value" mode when an error occurs.
PID_3Step moves the actuator to the substitute output value and then switches to "error monitoring" mode.
All the following conditions must be met:
Automatic mode (Mode = 3)
Errorbehaviour = TRUE
ActivateRecoverMode = TRUE
One or more errors have occurred in which ActivateRecoverMode (Page 2344) is effective.
As soon as the errors are no longer pending, PID_3Step switches back to automatic mode.
10 Manual mode without endstop signals
The endstop signals are not taken into consideration, even though Config.ActuatorEndStopOn = TRUE.
Otherwise, PID_3Step behaves the same as in manual mode.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2339
ENO characteristics
If State = 0, then ENO = FALSE.
If State 0, then ENO = TRUE.
Automatic switchover of operating mode during commissioning
Automatic mode is activated following successful pretuning or fine tuning. The following table
shows how Mode and State change during successful pretuning.
Cycle no. Mode State Action
0 4 4 Set Mode = 1
1 1 4 Set ModeActivate = TRUE
1 4 1 Value of State is saved in Mode parameter
Pretuning is started
n 4 1 Pretuning successfully completed
n 3 3 Automatic mode is started
PID_3Step automatically switches the operating mode in the event of an error. The following
table shows how Mode and State change during pretuning with errors.
Cycle no. Mode State Action
0 4 4 Set Mode = 1
1 1 4 Set ModeActivate = TRUE
1 4 1 Value of State is saved in Mode parameter
Pretuning is started
n 4 1 Pretuning canceled
n 4 4 Manual mode is started
If ActivateRecoverMode = TRUE, the operating mode that is saved in the Mode parameter is
activated. At the start of transition time measurement, pretuning, or fine tuning, PID_3Step
saved the value of State in the Mode in/out parameter. PID_3Step therefore switches to the
operating mode from which transition time measurement or tuning was started.
If ActivateRecoverMode = FALSE, "Inactive" or "Approach substitute output value" mode is
activated.
Automatic switchover of operating mode after transition time measurement
If ActivateRecoverMode = TRUE, the operating mode that is saved in the Mode parameter is
activated after successful transition time measurement.
If ActivateRecoverMode = FALSE, the system switches to "Inactive" operating mode after
successful transition time measurement.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2340 System Manual, 01/2013,
Automatic switchover of operating mode in automatic mode
PID_3Step automatically switches the operating mode in the event of an error. The following
diagram illustrates the influence of ErrorBehaviour and ActivateRecoverMode on this
switchover of operating mode.
Approach substitute output value (5)
Error monitoring (7)
Approach substitute output value
with error monitoring (8)
Automatic mode (3)
lnactive (0)
ActivateRecoverMode = FALSE
ErrorBehaviour = TRUE
ActivateRecoverMode = TRUE
ErrorBehaviour = TRUE
ActivateRecoverMode = TRUE
ErrorBehaviour = FALSE
ActivateRecoverMode = FALSE
ErrorBehaviour = FALSE
Automatic switchover of operating mode in the event of an error
Automatic switchover of operating mode once the current operation has been completed.
Automatic switchover of operating mode when error is no longer pending.
See also
Tag ActivateRecoverMode V2 (Page 2344)
Parameter ErrorBits V2 (Page 2341)
Parameter ErrorBits V2
If several errors are pending simultaneously, the values of the ErrorBits are displayed with
binary addition. The display of ErrorBits = 0003h, for example, indicates that the errors 0001h
and 0002h are pending simultaneously.
If there is a position feedback, PID_3Step uses ManualValue as output value in manual mode.
The exception is Errorbits = 10000h.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2341
ErrorBits
(DW#16#...)
Description
0000 There is no error.
0001 The "Input" parameter is outside the process value limits.
Input > Config.InputUpperLimit or
Input < Config.InputLowerLimit
If automatic mode was active before the error occurred and ActivateRecoverMode = TRUE, PID_3Step
remains in automatic mode.
If pretuning, fine tuning, or transition time measurement mode and ActivateRecoverMode = TRUE were
active before the error occurred, PID_3Step switches to the operating mode that is saved in the Mode
parameter.
0002 Invalid value at "Input_PER" parameter. Check whether an error is pending at the analog input.
If automatic mode was active before the error occurred and ActivateRecoverMode = TRUE, PID_3Step
outputs the configured substitute output value. As soon as the error is no longer pending, PID_3Step
switches back to automatic mode.
If pretuning, fine tuning, or transition time measurement mode and ActivateRecoverMode = TRUE were
active before the error occurred, PID_3Step switches to the operating mode that is saved in the Mode
parameter.
0004 Error during fine tuning. Oscillation of the process value could not be maintained.
If ActivateRecoverMode = TRUE before the error occurred, PID_3Step cancels the tuning and switches
to the operating mode that is saved in the Mode parameter.
0010 The setpoint was changed during tuning.
You can set the permitted fluctuation of the setpoint at the CancelTuningLevel tag.
If ActivateRecoverMode = TRUE before the error occurred, PID_3Step cancels the tuning and switches
to the operating mode that is saved in the Mode parameter.
0020 Pretuning is not permitted during fine tuning.
If ActivateRecoverMode = TRUE before the error occurred, PID_3Step remains in fine tuning mode.
0080 Error during pretuning. Incorrect configuration of output value limits.
Check whether the limits of the output value are configured correctly and match the control logic.
If ActivateRecoverMode = TRUE before the error occurred, PID_3Step cancels the tuning and switches
to the operating mode that is saved in the Mode parameter.
0100 Error during fine tuning resulted in invalid parameters.
If ActivateRecoverMode = TRUE before the error occurred, PID_3Step cancels the tuning and switches
to the operating mode that is saved in the Mode parameter.
0200 Invalid value at "Input" parameter: Value has an invalid number format.
If automatic mode was active before the error occurred and ActivateRecoverMode = TRUE, PID_3Step
outputs the configured substitute output value. As soon as the error is no longer pending, PID_3Step
switches back to automatic mode.
If pretuning, fine tuning, or transition time measurement mode and ActivateRecoverMode = TRUE were
active before the error occurred, PID_3Step switches to the operating mode that is saved in the Mode
parameter.
0400 Calculation of output value failed. Check the PID parameters.
If automatic mode was active before the error occurred and ActivateRecoverMode = TRUE, PID_3Step
outputs the configured substitute output value. As soon as the error is no longer pending, PID_3Step
switches back to automatic mode.
If pretuning, fine tuning, or transition time measurement mode and ActivateRecoverMode = TRUE were
active before the error occurred, PID_3Step switches to the operating mode that is saved in the Mode
parameter.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2342 System Manual, 01/2013,
ErrorBits
(DW#16#...)
Description
0800 Sampling time error: PID_3Step is not called within the sampling time of the cyclic interrupt OB.
If automatic mode was active before the error occurred and ActivateRecoverMode = TRUE, PID_3Step
remains in automatic mode.
If pretuning, fine tuning, or transition time measurement mode and ActivateRecoverMode = TRUE were
active before the error occurred, PID_3Step switches to the operating mode that is saved in the Mode
parameter.
1000 Invalid value at "Setpoint" parameter: Value has an invalid number format.
If automatic mode was active before the error occurred and ActivateRecoverMode = TRUE, PID_3Step
outputs the configured substitute output value. As soon as the error is no longer pending, PID_3Step
switches back to automatic mode.
If pretuning, fine tuning, or transition time measurement mode and ActivateRecoverMode = TRUE were
active before the error occurred, PID_3Step switches to the operating mode that is saved in the Mode
parameter.
2000 Invalid value at Feedback_PER parameter.
Check whether an error is pending at the analog input.
The actuator cannot be moved to the substitute output value and remains in its current position. In manual
mode, you can change the position of the actuator only with Manual_UP and Manual_DN, and not with
ManualValue.
If automatic mode was active before the error occurred, ActivateRecoverMode = TRUE, and the error is
no longer pending, PID_3Step switches back to automatic mode.
If pretuning, fine tuning, or transition time measurement mode and ActivateRecoverMode = TRUE were
active before the error occurred, PID_3Step switches to the operating mode that is saved in the Mode
parameter.
4000 Invalid value at Feedback parameter. Value has an invalid number format.
The actuator cannot be moved to the substitute output value and remains in its current position. In manual
mode, you can change the position of the actuator only with Manual_UP and Manual_DN, and not with
ManualValue.
If automatic mode was active before the error occurred, ActivateRecoverMode = TRUE, and the error is
no longer pending, PID_3Step switches back to automatic mode.
If pretuning, fine tuning, or transition time measurement mode and ActivateRecoverMode = TRUE were
active before the error occurred, PID_3Step switches to the operating mode that is saved in the Mode
parameter.
8000 Error during digital position feedback. Actuator_H = TRUE and Actuator_L = TRUE.
The actuator cannot be moved to the substitute output value and remains in its current position. Manual
mode is not possible in this state.
In order to move the actuator from this state, you must deactivate the "Actuator endstop"
(Config.ActuatorEndStopOn = FALSE) or switch to manual mode without endstop signals (Mode = 10).
If automatic mode was active before the error occurred, ActivateRecoverMode = TRUE, and the error is
no longer pending, PID_3Step switches back to automatic mode.
If pretuning, fine tuning, or transition time measurement mode and ActivateRecoverMode = TRUE were
active before the error occurred, PID_3Step switches to the operating mode that is saved in the Mode
parameter.
10000 Invalid value at ManualValue parameter. Value has an invalid number format.
The actuator cannot be moved to the manual value and remains in its current position.
Specify a valid value in ManualValue or move the actuator in manual mode with Manual_UP and
Manual_DN.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2343
ErrorBits
(DW#16#...)
Description
20000 Invalid value at SavePosition tag. Value has an invalid number format.
The actuator cannot be moved to the substitute output value and remains in its current position.
40000 Invalid value at parameter Disturbance. Value has an invalid number format.
If automatic mode was active before the error occurred, Disturbance is set to zero. PID_3Step remains
in automatic mode.
If pretuning or fine tuning mode was active and ActivateRecoverMode = TRUE before the error occurred,
PID_3Step switches to the operating mode saved in the Mode parameter. If Disturbance in the current
phase has no effect on the output value, tuning is not be canceled.
The error has no effect during transition time measurement.
Tag ActivateRecoverMode V2
The ActivateRecoverMode tag determines the reaction to error. The Error parameter indicates
if an error is pending. When the error is no longer pending, Error = FALSE. The ErrorBits
parameter shows which errors have occurred.
NOTICE
Your system may be damaged.
If ActivateRecoverMode = TRUE, PID_3Step remains in automatic mode even if the process
limit values are exceeded. This may damage your system.
It is essential to configure how your controlled system reacts in the event of an error to protect
your system from damage.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2344 System Manual, 01/2013,
Automatic mode
ActivateRecover
Mode
Description
FALSE In the event of an error, PID_3Step switches to "Inactive" or "Approach substitute output value" mode.
The controller is only activated by a falling edge at Reset or a rising edge at ModeActivate.
TRUE If errors occur frequently in automatic mode, this setting has a negative effect on the control response,
because PID_3Step switches between the calculated output value and the substitute output value at each
error. In this case, check the ErrorBits parameter and eliminate the cause of the error.
If one or more of the following errors occur, PID_3Step stays in automatic mode:
0001h: The "Input" parameter is outside the process value limits.
0800h: Sampling time error
40000h: Invalid value at Disturbance parameter.
If one or more of the following errors occur, PID_3Step switches to "Approach substitute output value with
error monitoring" or "Error monitoring" mode:
0002h: Invalid value at Input_PER parameter.
0200h: Invalid value at Input parameter.
0400h: Calculation of output value failed.
1000h: Invalid value at Setpoint parameter.
If one or more of the following errors occur, PID_3Step can no longer move the actuator:
2000h: Invalid value at Feedback_PER parameter.
4000h: Invalid value at Feedback parameter.
8000h: Error during digital position feedback.
20000h: Invalid value at SavePosition tag. Value has an invalid number format.
The characteristics are independent of ErrorBehaviour.
As soon as the errors are no longer pending, PID_3Step switches back to automatic mode.
Pretuning, fine tuning, and transition time measurement
ActivateRecover
Mode
Description
FALSE In the event of an error, PID_3Step switches to "Inactive" or "Approach substitute output value" mode.
The controller is only activated by a falling edge at Reset or a rising edge at ModeActivate.
The controller changes to "Inactive" mode after successful transition time measurement.
TRUE If the following error occurs, PID_3Step remains in the active mode:
0020h: Pretuning is not permitted during fine tuning.
The following errors are ignored:
10000h: Invalid value at ManualValue parameter.
20000h: Invalid value at SavePosition tag.
When any other error occurs, PID_3Step cancels the tuning and switches to the mode from which tuning
was started.
Manual mode
ActivateRecoverMode is not effective in manual mode.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2345
See also
Static tags of PID_3Step V2 (Page 2329)
Parameters State and Mode V2 (Page 2337)
Tag Warning V2
If several warnings are pending simultaneously, their values are displayed with binary addition.
The display of warning 0003h, for example, indicates that the warnings 0001h and 0002h are
pending simultaneously.
Warning
(DW#16#...)
Description
0000 No warning pending.
0001 The point of inflection was not found during pretuning.
0004 The setpoint was limited to the configured limits.
0008 Not all the necessary controlled system properties were defined for the selected method of calculation.
Instead, the PID parameters were calculated using the TIR.TuneRule = 3 method.
0010 The operating mode could not be changed because Reset = TRUE or ManualEnable = TRUE.
0020 The cycle time of the calling OB limits the sampling time of the PID algorithm.
Improve results by using shorter OB cycle times.
0040 The process value exceeded one of its warning limits.
0080 Invalid value at Mode. The operating mode is not switched.
0100 The manual value was limited to the limits of the controller output.
0200 The specified rule for tuning is not supported. No PID parameters are calculated.
0400 The transition time cannot be measured because the actuator settings do not match the selected
measuring method.
0800 The difference between the current position and the new output value is too small for transition time
measurement. This can produce incorrect results. The difference between the current output value and
new output value must be at least 50% of the entire control range.
1000 The substitute output value cannot be reached because it is outside the output value limits.
2000 The actuator was moved in one direction for longer than Config.VirtualActuatorLimit Retain.TransitTime.
Check whether the actuator has reached an endstop signal.
The following warnings are deleted as soon as the cause is eliminated:
0001h
0004h
0008h
0040h
0100h
All other warnings are cleared with a rising edge at Reset or ErrorAck.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2346 System Manual, 01/2013,
PID_3Step V1
Description of PID_3Step
Description
You use the PID_3Step instruction to configure a PID controller with self tuning for valves or
actuators with integrating behavior.
The following operating modes are possible:
Inactive
Pretuning
Fine tuning
Automatic mode
Manual mode
Approach substitute output value
Transition time measurement
Approach substitute output value with error monitoring
Error monitoring
For a more detailed description of the operating modes, see the State parameter.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2347
PID algorithm
PID_3Step is a PIDT1 controller with anti-windup and weighting of the proportional and
derivative actions. The following equation is used to calculate the output value.
y = K
p
s (w - x) + (c w - x)
[
(b w - x) +
1
T
I
s
T
D
s
a T
D
s + 1
]
Symbol Description
y Output value
K
p
Proportional gain
s Laplace operator
b Proportional action weighting
w Setpoint
x Process value
T
I
Integral action time
a Derivative delay coefficient (T1 = a T
D
)
T
D
Derivative action time
c Derivative action weighting
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2348 System Manual, 01/2013,
Block diagram without position feedback
-
%
1
0
-
-
Adead_B
1/FAC
lnputWarning_H
lnputWarning_L
PV_ALRM
1
0
Limit
Anti Windup
1
0
0.0 0.0
1 0
PulseOut
Output_PER
Limit
Av
CRP_lN
ThrStp
OutputPerOn
Output_DN
Output_UP
lnputPerOn
lnput
ManualEnable
PlDT1
Anti Windup
lnput_PER
Setpoint
Roc_Lim
ManualValue
Manual_DN
Manual_UP
1
0
1
0
ManualEnable
0 1
1.0
0.0
1
0
1.0
0.0
Scale
Fac lnt
1 0
0.0
1
0
0.0
OutputPerOn
CRP_OUT
%
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2349
Block diagram with position feedback
X
%
%
-
CRP_lN
Limit lnt
PlDT1
Anti Windup
CRP_lN
Limit
Fac
ThrStp Adead_B
PulseOut
Scale
Scale
%
CRP_OUT
lnputPerOn
Feedback_PER
FeedbackPerOn
lnput
Anti Windup
Setpoint
lnput_PER
Feedback
Output_DN
Output_UP
ManualEnable
Manual_DN
Manual_UP
OutputPerOn
Output_PER
lnputWarning_H
lnputWarning_L
PV_ALRM
1
0
AV
1
0
1
0
0
1
0.0
1
0
0.0
1
0
ManualEnable
ManualValue
1
0
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2350 System Manual, 01/2013,
Block diagram of PIDT1 with anti-windup
c
b
K
P
1/Ti
Fac/Tt
-
Dead_B
-
-
D
l
DT1
-
Anti Windup
Scaledlnput (x)
Setpoint (w)
Ay
Call
PID_3Step is called in a constant time interval of the cycle time of the calling OB (preferably
in a cyclic interrupt OB).
Download to device
The actual values of retentive tags are only updated when you download PID_3Step
completely.
Downloading technology objects to device (Page 3543)
Startup
At the startup of the CPU, PID_3Step starts in the operating mode that was last active. To
leave PID_3Step in "Inactive" mode, set RunModeByStartup = FALSE.
Reaction to error
If errors occur, these are output in the Error parameter. You configure the reaction of PID_3Step
using the ErrorBehaviour and ActivateRecoverMode tags.
ErrorBeha
viour
ActivateRecov
erMode
Actuator setting configuration
Set Output to
Reaction
0 FALSE Current output value Switch to "Inactive" mode (Mode = 0)
0 TRUE Current output value while
error is pending
Switch to "Error monitoring" mode
(Mode = 7)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2351
ErrorBeha
viour
ActivateRecov
erMode
Actuator setting configuration
Set Output to
Reaction
1 FALSE Substitute output value Switch to "Approach substitute output
value" mode (Mode = 5)
Switch to "Inactive" mode (Mode = 0)
1 TRUE Substitute output value while
error is pending
Switch to "Approach substitute output
value with error monitoring" mode
(Mode = 8)
Switch to "Error monitoring" mode
(Mode = 7)
The ErrorBits parameter shows which errors have occurred.
See also
State and Retain.Mode parameters (Page 2364)
ErrorBits parameter (Page 2371)
Configuring PID_3Step V1 (Page 3593)
Operating principle of PID_3Step
Monitoring process value limits
You specify the high limit and low limit of the process value in the Config.InputUpperLimit and
Config.InputLowerLimit tags. If the process value is outside these limits, an error occurs
(ErrorBits = 0001hex).
You specify a high and low warning limit of the process value in the Config.InputUpperWarning
and Config.InputLowerWarning tags. If the process value is outside these warning limits, a
warning occurs (Warnings = 0040hex), and the InputWarning_H or InputWarning_L output
parameter changes to TRUE.
Limiting the setpoint
You specify a high limit and low limit of the setpoint in the Config.SetpointUpperLimit and
Config.SetpointLowerLimit tags. PID_3Step automatically limits the setpoint to the process
value limits. You can limit the setpoint to a smaller range. PID_3Step checks whether this range
falls within the process value limits. If the setpoint is outside these limits, the high or low limit
is used as the setpoint, and output parameter SetpointLimit_H or SetpointLimit_L is set to
TRUE.
The setpoint is limited in all operating modes.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2352 System Manual, 01/2013,
Limiting the output value
You specify a high limit and low limit of the output value in the Config.OutputUpperLimit and
Config.OutputLowerLimit tags. The output value limits must be within "Low endstop" and "High
endstop".
High endstop: Config.FeedbackScaling.UpperPointOut
Low endstop: Config.FeedbackScaling.LowerPointOut
Rule:
UpperPointOut OutputUpperLimit > OutputLowerLimit LowerPointOut
The valid values for "High endstop" and "Low endstop" depend upon:
FeedbackOn
FeedbackPerOn
OutputPerOn
OutputPerOn FeedbackOn FeedbackPerOn LowerPointOut UpperPointOut
FALSE FALSE FALSE Cannot be set (0.0%) Cannot be set (100.0%)
FALSE TRUE FALSE -100.0% or 0.0% 0.0% or +100.0%
FALSE TRUE TRUE -100.0% or 0.0% 0.0% or +100.0%
TRUE FALSE FALSE Cannot be set (100.0%) Cannot be set (100.0%)
TRUE TRUE FALSE -100.0% or 0.0% 0.0% or +100.0%
TRUE TRUE TRUE -100.0% or 0.0% 0.0% or +100.0%
If OutputPerOn = FALSE and FeedbackOn = FALSE, you cannot limit the output value. The
digital outputs are reset with Actuator_H = TRUE or Actuator_L = TRUE, or after a travel time
amounting to 110% of the motor transition time.
The output value is 27648 at 100% and -27648 at -100%. PID_3Step must be able to close
the valve completely. Therefore, zero must be included in the output value limits.
Substitute output value
If an error has occurred, PID_3Step can output a substitute output value and move the actuator
to a safe position that is specified in the SavePosition tag. The substitute output value must
be within the output value limits.
Monitoring signal validity
The values of the following parameters are monitored for validity:
Setpoint
Input
Input_PER
Feedback
Feedback_PER
Output
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2353
Monitoring the PID_3Step sampling time
Ideally, the sampling time is equivalent to the cycle time of the calling OB. The PID_3Step
instruction measures the time interval between two calls. This is the current sampling time. On
every switchover of operating mode and during the initial startup, the mean value is formed
from the first 10 sampling times. Too great a difference between the current sampling time and
this mean value triggers an error (ErrorBits = 0800 hex).
PID_3Step is set to "Inactive" mode during tuning under the following conditions:
New mean value >= 1.1 x old mean value
New mean value <= 0.9 x old mean value
In automatic mode, PID_3Step is set to "Inactive" mode under the following conditions:
New mean value >= 1.5 x old mean value
New mean value <= 0.5 x old mean value
Sampling time of the PID algorithm
The controlled system needs a certain amount of time to respond to changes in the output
value. It is therefore not advisable to calculate the output value in every cycle. The sampling
time of the PID algorithm represents the time between two calculations of the output value. It
is calculated during tuning and rounded to a multiple of the cycle time. All other functions of
PID_3Step are executed at every call.
Measuring the motor transition time
The motor transition time is the time in seconds the motor requires to move the actuator from
the closed to the opened state. The maximum time that the actuator is moved in one direction
is 110% of the motor transition time. PID_3Step requires the motor transition time to be as
accurate as possible for good controller results. The data in the actuator documentation
contains average values for this type of actuator. The value for the specific actuator used may
differ. You can measure the motor transition time during commissioning. The output value
limits are not taken into consideration during the motor transition time measurement. The
actuator can travel to the high or the low endstop.
Control logic
An increase of the output value is generally intended to cause an increase in the process value.
This is referred to as a normal control logic. For cooling and discharge control systems, it may
be necessary to invert the control logic. PID_3Step does not work with negative proportional
gain. If InvertControl = TRUE, an increasing control deviation causes a reduction in the output
value. The control logic is also taken into account during pretuning and fine tuning.
See also
Configuring PID_3Step V1 (Page 3593)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2354 System Manual, 01/2013,
Input parameters of PID_3Step
Table 9-70
Parameters Data type Default Description
Setpoint REAL 0.0 Setpoint of the PID controller in automatic mode
Input REAL 0.0 A variable of the user program is used as source for the process
value.
If you are using parameter Input, then
Config.InputPerOn = FALSE must be set.
Input_PER WORD W#16#0 An analog input is used as source for the process value.
If you are using parameter Input_PER, then
Config.InputPerOn = TRUE must be set.
Actuator_H BOOL FALSE Digital position feedback of the valve for the high endstop
If Actuator_H = TRUE, the valve is at the high endstop and is
no longer moved towards this direction.
Actuator_L BOOL FALSE Digital position feedback of the valve for the low endstop
If Actuator_L = TRUE, the valve is at the low endstop and is no
longer moved towards this direction.
Feedback REAL 0.0 Position feedback of the valve
If you are using parameter Feedback, then
Config.FeedbackPerOn = FALSE must be set.
Feedback_PER WORD W#16#0 Analog feedback of the valve position
If you are using parameter Feedback_PER, then
Config.FeedbackPerOn = TRUE must be set.
Feedback_PER is scaled based on the variables:
Config.FeedbackScaling.LowerPointIn
Config.FeedbackScaling.UpperPointIn
Config.FeedbackScaling.LowerPointOut
Config.FeedbackScaling.UpperPointOut
ManualEnable BOOL FALSE A FALSE -> TRUE edge selects "Manual mode", while State
= 4, Retain.Mode remains unchanged.
A TRUE -> FALSE edge selects the most recently active
operating mode
A change of Retain.Mode will not take effect during
ManualEnable = TRUE. The change of Retain.Mode will only
be considered upon a TRUE -> FALSE edge at ManualEnable .
PID_3Step V1.1If at start of the CPU ManualEnable = TRUE,
PID_3Step starts in manual mode. A rising edge
(FALSE > TRUE) at ManualEnable is not necessary.
PID_3Step V1.0
At the start of the CPU, PID_3Step only switches to manual
mode with a rising edge (FALSE->TRUE) at ManualEnable .
Without rising edge, PID_3Step starts in the last operating
mode in which ManualEnable was FALSE.
ManualValue REAL 0.0 In manual mode, you specify the absolute position of the valve.
ManualValue will only be evaluated if you are using OutputPer,
or if position feedback is available.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2355
Parameters Data type Default Description
Manual_UP BOOL FALSE In manual mode, every rising edge opens the valve by 5% of
the total control range, or for the duration of the minimum motor
transition time. Manual_UP is evaluated only if you are not
using Output_PER and there is no position feedback available.
Manual_DN BOOL FALSE In manual mode, every rising edge closes the valve by 5% of
the total control range, or for the duration of the minimum motor
transition time. Manual_DN is evaluated only if you are not
using Output_PER and there is no position feedback available.
Reset BOOL FALSE Restarts the controller.
FALSE -> TRUE edge
Change to "Inactive" mode
Intermediate controller values are reset
(PID parameters are retained)
TRUE -> FALSE edge
Change in most recent active mode
Output parameters of PID_3Step
Table 9-71
Parameter Data type Default Description
ScaledInput REAL 0.0 Scaled process value
ScaledFeedback REAL 0.0 Scaled position feedback
For an actuator without position feedback, the position of the
actuator indicated by ScaledFeedback is very imprecise.
ScaledFeedback may only be used for rough estimation of the
current position in this case.
Output_UP BOOL FALSE Digital output value for opening the valve
If Config.OutputPerOn = FALSE, the Output_UP parameter is
used.
Output_DN BOOL FALSE Digital output value for closing the valve
If Config.OutputPerOn = FALSE, the Output_DN parameter is
used.
Output_PER WORD W#16#0 Analog output value
If Config.OutputPerOn = TRUE, Output_PER is used.
SetpointLimit_H BOOL FALSE If SetpointLimit_H = TRUE, the absolute setpoint high limit is
reached. In the CPU, the setpoint is limited to the configured
absolute setpoint high limit. The configured absolute process
value high limit is the default for the setpoint high limit.
If you configure Config.SetpointUpperLimit to a value within the
process value limits, this value is used as the setpoint high limit.
SetpointLimit_L BOOL FALSE If SetpointLimit_L = TRUE, the absolute setpoint low limit has
been reached. In the CPU, the setpoint is limited to the
configured absolute setpoint low limit. The configured absolute
process value low limit is the default setting for the setpoint low
limit.
If you configure Config.SetpointLowerLimit to a value within the
process value limits, this value is used as the setpoint low limit.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2356 System Manual, 01/2013,
Parameter Data type Default Description
InputWarning_H BOOL FALSE If InputWarning_H = TRUE, the process value has reached or
exceeded the warning high limit.
InputWarning_L BOOL FALSE If InputWarning_L = TRUE, the process value has reached or
fallen below the warning low limit.
State INT 0 The State parameter (Page 2364) shows the current operating
mode of the PID controller. You change the operating mode
with the Retain.Mode tag.
State = 0: Inactive
State = 1: Pretuning
State = 2: Fine tuning
State = 3: Automatic mode
State = 4: Manual mode
State = 5: Approach substitute output value
State = 6: Transition time measurement
State = 7: Error monitoring
State = 8: Approach substitute output value with error
monitoring
Error BOOL FALSE If Error = TRUE, at least one error message is pending.
ErrorBits DWORD DW#16#0 The ErrorBits parameter (Page 2371) indicates the error
messages.
See also
State and Retain.Mode parameters (Page 2364)
ErrorBits parameter (Page 2371)
PID_3Step static variables
You must not change tags that are not listed. These are used for internal purposes only.
Table 9-72
Tag Data type Default Description
ActivateRecoverMode BOOL TRUE The ActivateRecoverMode tag (Page 2372) determines the reaction
to error.
RunModeByStartup BOOL TRUE Activate Mode after CPU restart
If RunModeByStartup = TRUE, the controller returns to the last
active operating mode after a CPU restart.
If RunModeByStartup = FALSE, the controller remains inactive after
a CPU restart.
PhysicalUnit INT 0 Unit of measurement of the process value and setpoint, e.g., C, or
F.
PhysicalQuantity INT 0 Physical quantity of the process value and setpoint, e.g.,
temperature.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2357
Tag Data type Default Description
ErrorBehaviour INT 0 If ErrorBehaviour = 0 and an error has occurred, the valve stays at
its current position and the controller switches directly to "Inactive"
or "Error monitoring" mode.
If ErrorBehaviour = 1 and an error occurs, the actuator moves to the
substitute output value and only then switches to "Inactive" or "Error
monitoring" mode.
If the following errors occur, you can no longer move the valve to a
configured substitute output value.
2000h: Invalid value at Feedback_PER parameter.
4000h: Invalid value at Feedback parameter.
8000h: Error during digital position feedback.
Warning DWORD DW#16#
0
The Warning tag (Page 2364) displays the warnings generated
since a Reset or since the last switchover of operating mode.
Cyclic warnings (for example, process value warning) are shown
until the cause of the warning is removed. They are automatically
deleted once their cause has gone. Non-cyclic warnings (for
example, point of inflection not found) remain and are deleted like
errors.
SavePosition REAL 0.0 Substitute output value
If ErrorBehaviour = 1 and an error occurs, the actuator moves to a
safe position for the plant and only then switches to "Inactive" mode.
CurrentSetpoint REAL 0.0 Currently active setpoint. This value is frozen at the start of tuning.
Progress REAL 0.0 Progress of tuning as a percentage (0.0 - 100.0)
Config.InputPerOn BOOL TRUE If InputPerOn = TRUE, the Input_PER parameter is used. If
InputPerOn = FALSE, the Input parameter is used.
Config.OutputPerOn BOOL FALSE If OutputPerOn = TRUE, the Output_PER parameter is used. If
OutputPerOn = FALSE, the Ouput_UP and Output_DN parameters
are used.
Config.LoadBackUp BOOL FALSE If LoadBackUp = TRUE, the last set of PID parameters is reloaded.
This set was saved prior to the last tuning operation. LoadBackUp
is automatically reset to FALSE.
Config.InvertControl BOOL FALSE Invert control logic
If InvertControl = TRUE, an increasing control deviation causes a
reduction in the output value.
Config.FeedbackOn BOOL FALSE If FeedbackOn = FALSE, a position feedback is simulated.
Position feedback is generally activated when
FeedbackOn = TRUE.
Config.FeedbackPerOn BOOL FALSE FeedbackPerOn is only effective when FeedbackOn = TRUE.
If FeedbackPerOn = TRUE, the analog input is used for the position
feedback (Feedback_PER parameter).
If FeedbackPerOn = FALSE, the Feedback parameter is used for
the position feedback.
Config.ActuatorEndStopOn BOOL FALSE If ActuatorEndStopOn = TRUE, the digital position feedback
Actuator_L and Actuator_H are taken into consideration.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2358 System Manual, 01/2013,
Tag Data type Default Description
Config.InputUpperLimit REAL 120.0 High limit of the process value
At the I/O input, the process value can be a maximum of 18% higher
than the standard range (overrange). An error is no longer signaled
due to a violation of the "Process value high limit". Only a wire-break
and a short-circuit are recognized and PID_3Step reacts according
to the configured reaction to error.
InputUpperLimit > InputLowerLimit
Config.InputLowerLimit REAL 0.0 Low limit of the process value
InputLowerLimit < InputUpperLimit
Config.InputUpperWarning REAL +3.40282
2e+38
Warning high limit of the process value
If you set InputUpperWarning outside the process value limits, the
configured absolute process value high limit is used as the warning
high limit.
If you configure InputUpperWarning within the process value limits,
this value is used as the warning high limit.
InputUpperWarning > InputLowerWarning
InputUpperWarning InputUpperLimit
Config.InputLowerWarning REAL -3.40282
2e+38
Warning low limit of the process value
If you set InputLowerWarning outside the process value limits, the
configured absolute process value low limit is used as the warning
low limit.
If you configure InputLowerWarning within the process value limits,
this value is used as the warning low limit.
InputLowerWarning < InputUpperWarning
InputLowerWarning InputLowerLimit
Config.OutputUpperLimit REAL 100.0 High limit of output value
For details, see OutputLowerLimit
Config.OutputLowerLimit REAL 0.0 Low limit of output value
If OutputPerOn = TRUE or FeedbackOn = TRUE, the range of
values from -100% to +100%, including zero, is valid. At -100%,
Output = -27648; at +100%, Output = 27648
If OutputPerOn = FALSE, the range of values from 0% to 100% is
valid. The valve is completely closed at 0% and completely opened
at 100%.
Config.SetpointUpperLimit REAL +3.40282
2e+38
High limit of setpoint
If you set SetpointUpperLimit outside the process value limits, the
configured absolute process value high limit is preassigned as the
setpoint high limit.
If you configure SetpointUpperLimit within the process value limits,
this value is used as the setpoint high limit.
Config.SetpointLowerLimit REAL -
3.402822
e+38
Low limit of the setpoint
If you set SetpointLowerLimit outside the process value limits, the
configured absolute process value low limit is preassigned as the
setpoint low limit.
If you set SetpointLowerLimit within the process value limits, this
value is used as the setpoint low limit.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2359
Tag Data type Default Description
Config.MinimumOnTime REAL 0.0 Minimum ON time
Minimum time in seconds for which the servo drive must be switched
on.
Config.MinimumOffTime REAL 0.0 Minimum OFF time
Minimum time in seconds for which the servo drive must be switched
off.
Config.TransitTime REAL 30.0 Motor transition time
Time in seconds the actuating drive requires to move the valve from
the closed to the opened state.
Config.InputScaling.UpperPoi
ntIn
REAL 27648.0 Scaling Input_PER high
Input_PER is converted to a percentage based on the two value
pairs UpperPointOut, UpperPointIn and LowerPointOut,
LowerPointIn of the InputScaling structure.
Config.InputScaling.LowerPoi
ntIn
REAL 0.0 Scaling Input_PER low
Input_PER is converted to a percentage based on the two value
pairs UpperPointOut, UpperPointIn and LowerPointOut,
LowerPointIn of the InputScaling structure.
Config.InputScaling.UpperPoi
ntOut
REAL 100.0 Scaled high process value
Input_PER is converted to a percentage based on the two value
pairs UpperPointOut, UpperPointIn and LowerPointOut,
LowerPointIn of the InputScaling structure.
Config.InputScaling.LowerPoi
ntOut
REAL 0.0 Scaled low process value
Input_PER is converted to a percentage based on the two value
pairs UpperPointOut, UpperPointIn and LowerPointOut,
LowerPointIn of the InputScaling structure.
Config.FeedbackScaling.Uppe
rPointIn
REAL 27648.0 Scaling Feedback_PER high
Feedback_PER is converted to a percentage based on the two value
pairs UpperPointOut, UpperPointIn and LowerPointOut,
LowerPointIn of the FeedbackScaling structure.
Config.FeedbackScaling.Lowe
rPointIn
REAL 0.0 Scaling Feedback_PER low
Feedback_PER is converted to a percentage based on the two value
pairs UpperPointOut, UpperPointIn and LowerPointOut,
LowerPointIn of the FeedbackScaling structure.
Config.FeedbackScaling.Uppe
rPointOut
REAL 100.0 High endstop
Feedback_PER is converted to a percentage based on the two value
pairs UpperPointOut, UpperPointIn and LowerPointOut,
LowerPointIn of the FeedbackScaling structure.
Config.FeedbackScaling.Lowe
rPointOut
REAL 0.0 Low endstop
Feedback_PER is converted to a percentage based on the two value
pairs UpperPointOut, UpperPointIn and LowerPointOut,
LowerPointIn of the FeedbackScaling structure.
GetTransitTime.InvertDirectio
n
BOOL FALSE If InvertDirection = FALSE, the valve is fully opened, closed, and
then reopened in order to determine the valve transition time.
If InvertDirection = TRUE, the valve is fully closed, opened, and then
closed again.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2360 System Manual, 01/2013,
Tag Data type Default Description
GetTransitTime.SelectFeedba
ck
BOOL FALSE If SelectFeedback = TRUE, then Feedback_PER, or Feedback is
taken into consideration in the transition time measurement.
If SelectFeedback = FALSE, then Actuator_H and Actuator_L are
taken into consideration in the transition time measurement.
GetTransitTime.Start BOOL FALSE If Start = TRUE, the transition time measurement is started.
GetTransitTime.State INT 0 Current phase of the transition time measurement
State = 0: Inactive
State = 1: Open valve completely
State = 2: Close valve completely
State = 3: Move valve to target position (NewOutput)
State = 4: Transition time measurement successfully completed
State = 5: Transition time measurement canceled
GetTransitTime.NewOutput REAL 0.0 Target position for transition time measurement with position
feedback
The target position must be between "High endstop" and "Low
endstop". The difference between NewOutput and ScaledFeedback
must be at least 50% of the permissible control range.
CycleTime.StartEstimation BOOL TRUE If StartEstimation = TRUE, the measurement of the PID_3Step
sampling time is started. CycleTime.StartEstimation = FALSE once
measurement is complete.
CycleTime.EnEstimation BOOL TRUE If EnEstimation = TRUE, the PID_3Step sampling time is calculated.
CycleTime.EnMonitoring BOOL TRUE If EnMonitoring = TRUE, the PID_3Step sampling time is monitored.
If it is not possible to execute PID_3Step within the sampling time,
the error 0800h is output and the operating mode is switched.
ActivateRecoverMode and ErrorBehaviour determine which
operating mode is switched to.
If EnMonitoring = FALSE, the PID_3Step sampling time is not
monitored, the error 0800h is not output, and the operating mode is
not switched.
CycleTime.Value REAL 0.1 PID_3Step sampling time in seconds
CycleTime.Value is determined automatically and is usually
equivalent to the cycle time of the calling OB.
CtrlParamsBackUp.SetByUser BOOL FALSE Saved value of Retain.CtrlParams.SetByUser.
You can reload values from the CtrlParamsBackUp structure with
Config.LoadBackUp = TRUE.
CtrlParamsBackUp.Gain REAL 1.0 Saved proportional gain
CtrlParamsBackUp.Ti REAL 20.0 Saved integral action time
CtrlParamsBackUp.Td REAL 0.0 Saved derivative action time
CtrlParamsBackUp.TdFiltRati
o
REAL 0.0 Saved derivative delay coefficient
CtrlParamsBackUp.PWeightin
g
REAL 0.0 Saved proportional action weighting
CtrlParamsBackUp.DWeightin
g
REAL 0.0 Saved derivative action weighting
CtrlParamsBackUp.Cycle REAL 1.0 Saved sampling time of PID algorithm
CtrlParamsBackUp.InputDead
Band
REAL 0.0 Saved dead band width of the control deviation
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2361
Tag Data type Default Description
PIDSelfTune.SUT.CalculateS
UTParams
BOOL FALSE The properties of the controlled system are saved during tuning. If
CalculateSUTParams = TRUE, the PID parameters are recalculated
on the basis of these properties. The PID parameters are calculated
using the method set in TuneRuleSUT. CalculateSUTParams is set
to FALSE following calculation.
PIDSelfTune.SUT.TuneRuleS
UT
INT 1 Methods used to calculate parameters during pretuning:
TuneRuleSUT = 0: PID rapid I
TuneRuleSUT = 1: PID slow I
TuneRuleSUT = 2: Chien, Hrones and Reswick PID
TuneRuleSUT = 3TuneRuleSUT = 3: Chien, Hrones, Reswick
PI
TuneRuleSUT = 4: PID rapid II
TuneRuleSUT = 5: PID slow II
PIDSelfTune.SUT.State INT 0 The SUT.State tag indicates the current phase of pretuning:
PIDSelfTune.TIR.RunIn BOOL FALSE RunIn = FALSE
Pretuning is started when fine tuning is started from inactive or
manual mode.
If fine tuning is started from automatic mode, the system uses
the existing PID parameters to control to the setpoint.
Only then will fine tuning start. If pretuning is not possible,
PID_3Step switches to "Inactive" mode.
RunIn = TRUE
The pretuning is skipped. PID_3Step attempts to reach the
setpoint with the minimum or maximum output value. This can
produce increased overshoot. Only then will fine tuning start.
RunIn is set to FALSE after fine tuning.
PIDSelfTune.TIR.CalculateTI
RParams
BOOL FALSE The properties of the controlled system are saved during tuning. If
CalculateTIRParams = TRUE, the PID parameters are recalculated
on the basis of these properties. The PID parameters are calculated
using the method set in TuneRuleTIR. CalculateTIRParams is set
to FALSE following calculation.
PIDSelfTune.TIR.TuneRuleTI
R
INT 0 Methods used to calculate parameters during fine tuning:
TuneRuleTIR = 0: PID automatic
TuneRuleTIR = 1: PID rapid
TuneRuleTIR = 2: PID slow
TuneRuleTIR = 3: Ziegler-Nichols PID
TuneRuleTIR = 4: Ziegler-Nichols PI
TuneRuleTIR = 5: Ziegler-Nichols P
PIDSelfTune.TIR.State INT 0 The TIR.State tag indicates the current phase of "fine tuning":
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2362 System Manual, 01/2013,
Tag Data type Default Description
Retain.Mode INT 0 A change to the value of Retain.Mode initiates a switch to another
operating mode.
The following operating mode is enabled upon a change of Mode to:
Mode = 0: Inactive
Mode = 1: Pretuning
Mode = 2: Fine tuning
Mode = 3: Automatic mode
Mode = 4: Manual mode
Mode = 5: Approach substitute output value
Mode = 6: Transition time measurement
Mode = 7Mode = 7: Error monitoring
Mode = 8: Approach substitute output value with error monitoring
Mode is retentive.
Retain.CtrlParams.SetByUser BOOL FALSE If SetByUser = FALSE, the PID parameters are determined
automatically and PID_3Step operates with a dead band at the
output value. The dead band width is calculated during tuning on
the basis of the standard deviation of the output value and saved in
Retain.CtrlParams.OutputDeadBand.
If SetByUser = TRUE, the PID parameters are entered manually
and PID_3 Step operates without a dead band at the output value.
Retain.CtrlParams.OutputDeadBand = 0.0
SetByUser is retentive.
Retain.CtrlParams.Gain REAL 1.0 Active proportional gain
Gain is retentive.
Retain.CtrlParams.Ti REAL 20.0 Ti > 0.0: Active integral action time
Ti = 0.0: Integral action is deactivated
Ti is retentive.
Retain.CtrlParams.Td REAL 0.0 Td > 0.0: Active derivative action time
Td = 0.0: Derivative action is deactivated
Td is retentive.
Retain.CtrlParams.TdFiltRatio REAL 0.0 Active derivative delay coefficient
TdFiltRatio is retentive.
Retain.CtrlParams.PWeighting REAL 0.0 Active proportional action weighting
PWeighting is retentive.
Retain.CtrlParams.DWeightin
g
REAL 0.0 Active derivative action weighting
DWeighting is retentive.
Retain.CtrlParams.Cycle REAL 1.0 Active sampling time of PID algorithm in seconds, rounded to an
integer multiple of the cycle time of the calling OB.
Cycle is retentive.
Retain.CtrlParams.InputDead
Band
REAL 0.0 Dead band width of the control deviation
InputDeadBand is retentive.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2363
Note
Change the tags listed in this table in "Inactive" mode to prevent malfunction of the PID
controller. "Inactive" mode is forced by setting the "Retain.Mode" tag to "0".
See also
State and Retain.Mode parameters (Page 2364)
ActivateRecoverMode variable (Page 2372)
Downloading technology objects to device (Page 3543)
State and Retain.Mode parameters
Correlation of the parameters
The State parameter shows the current operating mode of the PID controller. You cannot
change the State parameter.
To switch from one operating mode to another, you must change the Retain.Mode tag. This
also applies when the value for the new operating mode is already in Retain.Mode. For
example, set Retain.Mode = 0 first and then Retain.Mode = 3. Provided the current operating
mode of the controller permits this switchover, State will be set to the value of Retain.Mode.
When PID_3Step automatically switches from one operating mode to another, the following
applies: State != Retain.Mode.
Examples:
After successful pretuning
State = 3 and Retain.Mode = 1
In the event of an error
State = 0 and Retain.Mode remain at the previous value, for example, Retain.Mode = 3
ManualEnalbe = TRUE
State = 4 and Retain.Mode remain at the previous value, e.g., Retain.Mode = 3
Note
You want, for example, to repeat successful fine tuning without exiting automatic mode
with Mode = 0.
Setting Retain.Mode to an invalid value such as 9999 for one cycle has no effect on State.
Set Mode = 2 in the next cycle. In this way, you can generate a change to Retain.Mode
without first switching to "Inactive" mode.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2364 System Manual, 01/2013,
Meaning of values
State /
Retain.Mode
Description
0 Inactive
The controller is switched off and no longer changes the valve position.
1 Pretuning
The pretuning determines the process response to a pulse of the output value and searches for the point of
inflection. The optimized PID parameters are calculated as a function of the maximum rate of rise and dead
time of the controlled system.
Pretuning requirements:
State = 0 or State = 4
ManualEnable = FALSE
The motor transition time has been configured or measured.
The setpoint and the process value lie within the configured limits.
The more stable the process value is, the easier it is to calculate the PID parameters and the more precise
the result will be. Noise on the process value can be tolerated as long as the rate of rise of the process value
is significantly higher as compared to the noise.
Before the PID parameters are recalculated, they are backed up and can be reactivated with
Config.LoadBackUp. The setpoint is frozen in the CurrentSetpoint tag.
The controller switches to automatic mode following successful pretuning and to "Inactive" mode following
unsuccessful pretuning.
The pretuning phase is indicated with the SUT.State tag.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2365
State /
Retain.Mode
Description
2 Fine tuning
Fine tuning generates a constant, limited oscillation of the process value. The PID parameters are tuned
based on the amplitude and frequency of this oscillation. The differences between the process response
during pretuning and fine tuning are analyzed. All PID parameters are recalculated from the results. PID
parameters from fine tuning usually have better master control and disturbance characteristics than PID
parameters from pretuning.
PID_3Step automatically attempts to generate an oscillation greater than the noise of the process value. Fine
tuning is only minimally influenced by the stability of the process value.
The PID parameters are backed up before fine tuning. They can be reactivated with Config.LoadBackUp.
The setpoint is frozen in the CurrentSetpoint tag.
Requirements for fine tuning:
The motor transition time has been configured or measured.
The setpoint and the process value lie within the configured limits.
ManualEnable = FALSE
Automatic (State = 3), inactive (State = 0) or manual (State = 4) mode
Fine tuning proceeds as follows when started from:
Automatic mode (State = 3)
Start fine tuning from automatic mode if you wish to improve the existing PID parameters through tuning.
PID_3Step controls the system using the existing PID parameters until the control loop has stabilized and
the requirements for fine tuning have been met. Only then will fine tuning start.
Inactive (State = 0) or manual mode (State = 4)
Pretuning is always started first. The determined PID parameters will be used for control until the control
loop has stabilized and the requirements for fine tuning have been met.
If PIDSelfTune.TIR.RunIn = TRUE, pretuning is skipped and an attempt is made to reach the setpoint with
the minimum or maximum output value. This can produce increased overshoot. Fine tuning then starts
automatically.
The controller switches to automatic mode following successful fine tuning. If fine tuning was not successful,
the controller switches to "Inactive" mode.
The fine tuning phase is indicated with the TIR.State tag.
3 Automatic mode
In automatic mode, PID_3Step controls the controlled system in accordance with the parameters specified.
The controller switches to automatic mode if one the following requirements is fulfilled:
Pretuning successfully completed
Fine tuning successfully completed
Changing the Retain.Mode tag to the value 3.
When the CPU is switched on or switches from Stop to RUN mode, PID_3Step starts in the most recently
active operating mode. To leave PID_3Step in "Inactive" mode, set RunModeByStartup = FALSE.
The ActivateRecoverMode tag is taken into consideration in automatic mode.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2366 System Manual, 01/2013,
State /
Retain.Mode
Description
4 Manual mode
In manual mode, you specify manual output values in the Manual_UP and Manual_DN parameters or
ManualValue parameter. Whether or not the actuator can be moved to the output value in the event of an
error is described in the ErrorBits parameter.
This operating mode is enabled if Retain.Mode = 4, or on a rising edge at ManualEnable.
If ManualEnable changes to TRUE, only State changes. Retain.Mode retains its current value. On a falling
edge at ManualEnable, PID_3Step returns to the previous operating mode.
The switchover to automatic mode is bumpless.
PID_3Step V1.1
Manual mode is always possible in the event of an error.
PID_3Step V1.0
Manual mode is dependent on the ActivateRecoverMode tag in the event of an error.
5 Approach substitute output value
This operating mode is activated in the event of an error or when Reset = TRUE if Errorbehaviour = 1 and
ActivateRecoverMode = FALSE..
PID_3Step moves the actuator to the substitute output value and then switches to "Inactive" mode.
6 Transition time measurement
The time that the motor needs to completely open the valve from the closed condition is determined.
This operating mode is activated when GetTransitTime.Start = TRUE is set.
If endstop signals are used to measure the transition time, the valve will be opened completely from its current
position, closed completely, and opened completely again. If GetTransitTime.InvertDirection = TRUE, this
behavior is inverted.
If position feedback is used to measure the transition time, the actuator will be moved from its current position
to a target position.
The output value limits are not taken into consideration during the transition time measurement. The actuator
can travel to the high or the low endstop.
7 Error monitoring
The control algorithm is switched off and no longer changes the valve position.
This operating mode is activated instead of "Inactive" mode in the event of an error.
All the following conditions must be met:
Mode = 3 (automatic mode)
Errorbehaviour = 0
ActivateRecoverMode = TRUE
One or more errors have occurred in which ActivateRecoverMode (Page 2372) is effective.
As soon as the errors are no longer pending, PID_3Step switches back to automatic mode.
8 Approach substitute output value with error monitoring
This operating mode is activated instead of "Approach substitute output value" mode in the event of an error.
PID_3Step moves the actuator to the substitute output value and then switches to "Error monitoring" mode.
All the following conditions must be met:
Mode = 3 (automatic mode)
Errorbehaviour = 1
ActivateRecoverMode = TRUE
One or more errors have occurred in which ActivateRecoverMode (Page 2372) is effective.
As soon as the errors are no longer pending, PID_3Step switches back to automatic mode.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2367
Automatic switchover of operating mode during commissioning
PID_3Step automatically switches the operating mode in the event of an error. The following
diagram illustrates the influence of ErrorBehaviour on the switchover of operating mode from
transition time measurement, pretuning, and fine tuning modes.
Pretuning (1)
Automatic mode (3)
Fine tuning (2)
Approach substitute output value (5)
Transition time measurement (6)
lnactive (0)
ErrorBehaviour = 1 ErrorBehaviour = 1
ErrorBehaviour = 0 ErrorBehaviour = 0
ErrorBehaviour = 1
ErrorBehaviour = 0
Automatic switchover of operating mode in the event of an error
Automatic switchover of operating mode once the current operation has been completed.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2368 System Manual, 01/2013,
Automatic switchover of operating mode in automatic mode (PID_3Step V1.1)
PID_3Step automatically switches the operating mode in the event of an error. The following
diagram illustrates the influence of ErrorBehaviour and ActivateRecoverMode on this
switchover of operating mode.
Approach substitute output value (5)
Error monitoring (7)
Approach substitute output value
with error monitoring (8)
Automatic mode (3)
lnactive (0)
ActivateRecoverMode = FALSE
ErrorBehaviour = 1
ActivateRecoverMode = TRUE
ErrorBehaviour = 1
ActivateRecoverMode = TRUE
ErrorBehaviour = 0
ActivateRecoverMode = FALSE
ErrorBehaviour = 0
Automatic switchover of operating mode in the event of an error
Automatic switchover of operating mode once the current operation has been completed.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2369
Automatic switchover of operating mode in automatic and manual modes (PID_3Step V1.0)
PID_3Step automatically switches the operating mode in the event of an error. The following
diagram illustrates the influence of ErrorBehaviour and ActivateRecoverMode on this
switchover of operating mode.
Approach substitute output value (5)
Error monitoring (7)
Approach substitute output value
with error monitoring (8)
Automatic mode (3)
Manual mode (4)
lnactive (0)
ActivateRecoverMode = FALSE
ErrorBehaviour = 1
ActivateRecoverMode = TRUE
ErrorBehaviour = 1
ActivateRecoverMode = TRUE
ErrorBehaviour = 0
ActivateRecoverMode = FALSE
ErrorBehaviour = 0
ErrorBehaviour = 1
ErrorBehaviour = 0
ActivateRecoverMode = FALSE
ActivateRecoverMode = FALSE
ActivateRecoverMode = TRUE
Automatic switchover of operating mode in the event of an error
Automatic switchover of operating mode once the current operation has been completed.
Automatic switchover of operating mode when error is no longer pending.
See also
ActivateRecoverMode variable (Page 2372)
ErrorBits parameter (Page 2371)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2370 System Manual, 01/2013,
ErrorBits parameter
If several errors are pending simultaneously, the values of the error codes are displayed with
binary addition. The display of error code 0003, for example, indicates that the errors 0001
and 0002 are pending simultaneously.
ErrorBits
(DW#16#...)
Description
0000 There is no error.
0001 The "Input" parameter is outside the process value limits.
Input > Config.InputUpperLimit or
Input < Config.InputLowerLimit
If ActivateRecoverMode = TRUE and ErrorBehaviour = 1, the actuator moves to the substitute output
value. If ActivateRecoverMode = TRUE and ErrorBehaviour = 0, the actuator stops in its current position.
If ActivateRecoverMode = FALSE, the actuator stops in its current position.
PID_3Step V1.1
You can move the actuator in manual mode.
PID_3Step V1.0
Manual mode is not possible in this state. You cannot move the actuator again until you eliminate the
error.
0002 Invalid value at "Input_PER" parameter. Check whether an error is pending at the analog input.
If automatic mode was active before the error occurred, ActivateRecoverMode = TRUE, and the error is
no longer pending, PID_3Step switches back to automatic mode.
0004 Error during fine tuning. Oscillation of the process value could not be maintained.
0020 Pretuning is not permitted in automatic mode or during fine tuning.
0080 Error during pretuning. Incorrect configuration of output value limits.
Check whether the limits of the output value are configured correctly and match the control logic.
0100 Error during fine tuning resulted in invalid parameters.
0200 Invalid value at "Input" parameter: Value has an invalid number format.
If automatic mode was active before the error occurred, ActivateRecoverMode = TRUE, and the error is
no longer pending, PID_3Step switches back to automatic mode.
0400 Calculation of output value failed. Check the PID parameters.
0800 Sampling time error: PID_3Step is not called within the sampling time of the cyclic interrupt OB.
If automatic mode was active before the error occurred, ActivateRecoverMode = TRUE, and the error is
no longer pending, PID_3Step switches back to automatic mode.
1000 Invalid value at "Setpoint" parameter: Value has an invalid number format.
If automatic mode was active before the error occurred, ActivateRecoverMode = TRUE, and the error is
no longer pending, PID_3Step switches back to automatic mode.
2000 Invalid value at Feedback_PER parameter.
Check whether an error is pending at the analog input.
The actuator cannot be moved to the substitute output value and remains in its current position. Manual
mode is not possible in this state. You must deactivate position feedback (Config. FeedbackOn = FALSE)
to move the actuator from this state.
If automatic mode was active before the error occurred, ActivateRecoverMode = TRUE, and the error is
no longer pending, PID_3Step switches back to automatic mode.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2371
ErrorBits
(DW#16#...)
Description
4000 Invalid value at Feedback parameter. Value has an invalid number format.
The actuator cannot be moved to the substitute output value and remains in its current position. Manual
mode is not possible in this state. You must deactivate position feedback (Config. FeedbackOn = FALSE)
to move the actuator from this state.
If automatic mode was active before the error occurred, ActivateRecoverMode = TRUE, and the error is
no longer pending, PID_3Step switches back to automatic mode.
8000 Error during digital position feedback. Actuator_H = TRUE and Actuator_L = TRUE.
The actuator cannot be moved to the substitute output value and remains in its current position. Manual
mode is not possible in this state.
In order to move the actuator from this state, you must deactivate the "Actuator endstop"
(Config.ActuatorEndStopOn = FALSE).
If automatic mode was active before the error occurred, ActivateRecoverMode = TRUE, and the error is
no longer pending, PID_3Step switches back to automatic mode.
Reset parameter
A rising edge at Reset resets the errors and warnings and clears the integral action. A falling
edge at Reset triggers a change to the most recently active operating mode.
Mode
State
t (ms)
Reset
t (ms)
t (ms)
3
0
1
0
3
0
1 2 3 1
Activation
Error
Reset
ActivateRecoverMode variable
The effect of the ActivateRecoverMode variable depends on the version of the PID_3Step.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2372 System Manual, 01/2013,
Behavior in version 1.1
The ActivateRecoverMode variable determines the behavior in the event of an error in
automatic mode. ActivateRecoverMode is not effective during pretuning, fine tuning and
transition time measurement.
ActivateRecover
Mode
Description
FALSE In the event of an error, PID_3Step switches to "Inactive" or "Approach substitute output value" operating
mode. The controller is activated by a reset or a change in Retain.Mode.
TRUE If errors occur frequently in automatic mode, this setting has a negative effect on the control response. In
this case, check the ErrorBits parameter and eliminate the cause of the error.
If one or more errors occur, PID_3Step switches to "Approach substitute output value with error
monitoring" or "Error monitoring" mode:
0002h: Invalid value at parameter Input_PER.
0200h: Invalid value at parameter Input.
0800h: Sampling time error
1000h: Invalid value at parameter Setpoint.
2000h: Invalid value at parameter Feedback_PER.
4000h: Invalid value at parameter Feedback.
8000h: Error in digital position feedback.
With errors 2000h, 4000h and 8000h, PID_3Step cannot approach the configured substitute output value.
As soon as the errors are no longer pending, PID_3Step switches back to automatic mode.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2373
Behavior in version 1.0
The ActivateRecoverMode variable determines the behavior in the event of an error in
automatic and manual mode. ActivateRecoverMode is not effective during pretuning, fine
tuning and transition time measurement.
ActivateRecover
Mode
Description
FALSE In the event of an error, PID_3Step switches to "Inactive" or "Approach substitute output value" operating
mode. The controller is activated by a reset or a change in Retain.Mode.
TRUE Errors in automatic mode
If errors occur frequently in automatic mode, this setting has a negative effect on the control response. In
this case, check the ErrorBits parameter and eliminate the cause of the error.
If one or more errors occur, PID_3Step switches to "Approach substitute output value with error
monitoring" or "Error monitoring" mode:
0002h: Invalid value at parameter Input_PER.
0200h: Invalid value at parameter Input.
0800h: Sampling time error
1000h: Invalid value at parameter Setpoint.
2000h: Invalid value at parameter Feedback_PER.
4000h: Invalid value at parameter Feedback.
8000h: Error in digital position feedback.
With errors 2000h, 4000h and 8000h, PID_3Step cannot approach the configured substitute output value.
As soon as the errors are no longer pending, PID_3Step switches back to automatic mode.
Errors in manual mode
If one or more of the following errors occur, PID_3Step stays in manual mode:
0002h: Invalid value at parameter Input_PER.
0200h: Invalid value at parameter Input.
0800h: Sampling time error
1000h: Invalid value at parameter Setpoint.
2000h: Invalid value at parameter Feedback_PER.
4000h: Invalid value at parameter Feedback.
8000h: Error in digital position feedback.
With errors 2000h, 4000h and 8000h, you cannot move the valve to a suitable position.
See also
PID_3Step static variables (Page 2357)
State and Retain.Mode parameters (Page 2364)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2374 System Manual, 01/2013,
Tag Warning
If several warnings are pending simultaneously, their values are displayed with binary addition.
The display of warning 0003, for example, indicates that the warnings 0001 and 0002 are
pending simultaneously.
Warning
(DW#16#...)
Description
0000 No warning pending.
0001 The point of inflection was not found during pretuning.
0002 Oscillation increased during fine tuning.
0004 The setpoint was limited to the configured limits.
0008 Not all the necessary controlled system properties were defined for the selected method of calculation.
The PID parameters were instead calculated using the TuneRuleTIR = 3 method.
0010 The operating mode could not be changed because ManualEnable = TRUE.
0020 The cycle time of the calling OB limits the sampling time of the PID algorithm.
Improve results by using shorter OB cycle times.
0040 The process value exceeded one of its warning limits.
0080 Invalid value at Retain.Mode. The operating mode is not switched.
0100 The manual value was limited to the limits of the controller output.
0200 The rule used for tuning produces an incorrect result, or is not supported.
0400 Method selected for transition time measurement not suitable for actuator.
The transition time cannot be measured because the actuator settings do not match the selected
measuring method.
0800 The difference between the current position and the new output value is too small for transition time
measurement. This can produce incorrect results. The difference between the current output value and
new output value must be at least 50% of the entire control range.
1000 The substitute output value cannot be reached because it is outside the output value limits.
The following warnings are deleted as soon as the cause is eliminated:
0004
0020
0040
0100
All other warnings are cleared with a rising edge at Reset.
SUT.State variable
SUT.Stat
e
Name Description
0 SUT_INIT Initialize pretuning
50 SUT_TPDN Determine start position without position feedback
100 SUT_STDABW Calculate the standard deviation
200 SUT_GET_POI Find the point of inflection
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2375
SUT.Stat
e
Name Description
300 SUT_GET_RISETM Determine the rise time
9900 SUT_IO Pretuning successful
1 SUT_NIO Pretuning not successful
TIR.State variable
TIR.State Name Description
-100 TIR_FIRST_SUT Fine tuning is not possible. Pretuning will be executed first.
0 TIR_INIT Initialize fine tuning
200 TIR_STDABW Calculate the standard deviation
300 TIR_RUN_IN Attempt to reach the setpoint with the maximum or minimum output value
400 TIR_CTRLN Attempt to reach the setpoint with the existing PID parameters
(if pretuning has been successful)
500 TIR_OSZIL Determine oscillation and calculate parameters
9900 TIR_IO Fine tuning successful
1 TIR_NIO Fine tuning not successful
9.8.4.3 S7-1200 Motion Control
MC_Power
MC_Power: Enable, disable axis
Description
The Motion Control instruction "MC_Power" releases or locks an axis.
Requirements
The technology object "Axis" has been configured correctly.
There is no pending enable-inhibiting error.
Override response
Execution of "MC_Power" cannot be aborted by a motion control command.
Disabling the axis (input parameter "Enable" = FALSE ) aborts all motion control commands
for the associated technology object in accordance with the selected "StopMode".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2376 System Manual, 01/2013,
Parameter
Parameter Declaration Data type Default value Description
Axis INPUT TO_Axis_1 - Axis technology object
Enable INPUT BOOL FALSE TRUE Motion Control attempts to enable the axis.
FALSE All active commands are aborted according to the
configured "StopMode" and the axis is stopped.
StopMode INPUT INT 0 0 Emergency stop
If a request to disable the axis is pending, the axis
brakes at the configured emergency stop
deceleration. The axis is disabled after reaching
standstill.
1 Immediate stop
If a request to disable the axis is pending, this axis
is disabled without deceleration. The pulse output
is stopped immediately.
2 Emergency stop with jerk control
If a request to disable the axis is pending, the axis
brakes at the configured emergency stop
deceleration. If the jerk control is activated, the
configured jerk is taken into account. The axis is
disabled after reaching standstill.
Status OUTPUT BOOL FALSE Status of axis enable
FALSE The axis is disabled.
The axis does not execute motion control
commands and does not accept any new
commands (exception: MC_Reset command).
The axis is not homed.
Upon disabling, the status does not change to
FALSE until the axis reaches a standstill.
TRUE The axis is enabled.
The axis is ready to execute motion control
commands.
Upon axis enabling, the status does not change to
TRUE until the signal "Drive ready" is pending. If
the "Drive ready" drive interface was not configured
in the axis configuration, the status changes to
TRUE immediately.
Busy OUTPUT BOOL FALSE TRUE MC Power is active
Error OUTPUT BOOL FALSE TRUE An error occurred in motion control instruction
"MC_Power" or in the associated technology
object. The cause of the error can be found in
parameters "ErrorID" and "ErrorInfo".
ErrorID OUTPUT WORD 16#0000 Error ID (Page 3711) for parameter "Error"
ErrorInfo OUTPUT WORD 16#0000 Error info ID (Page 3711) for parameter "ErrorID"
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2377
Note
If the axis is switched off due to an error, it will be enabled again automatically after the error
has been eliminated and acknowledged. This requires that input parameter "Enable" has
retained the value TRUE during this process.
Enabling an axis with configured drive interface
To enable the axis, follow these steps:
1. Check the requirements indicated above.
2. Initialize input parameter "StopMode" with the desired value. Set input parameter "Enable"
to TRUE.
The enable output for "Drive enabled" changes to TRUE to enable the power to the drive.
The CPU waits for the "Drive ready" signal of the drive.
When the "Drive ready" signal is available at the configured ready input of the CPU, the
axis becomes enabled. Output parameter "Status" and tag of technology object <Axis
name>.StatusBits.Enable indicate the value TRUE.
Enabling an axis without configured drive interface
To enable the axis, follow these steps:
1. Check the requirements indicated above.
2. Initialize input parameter "StopMode" with the desired value. Set input parameter "Enable"
to TRUE. The axis is enabled. Output parameter "Status" and tag of technology object <Axis
name>.StatusBits.Enable indicate the value TRUE.
Disabling an axis
To disable an axis, you can follow the steps described below:
1. Bring the axis to a standstill.
You can identify when the axis is at a standstill in the tag of the technology object <Axis
name>.StatusBits.StandStill.
2. Set input parameter "Enable" to FALSE after standstill is reached.
3. If output parameters "Busy" and "Status" and tag of technology object <Axis
name>.StatusBits.Enable indicate the value FALSE, disabling of the axis is complete.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2378 System Manual, 01/2013,
See also
List of ErrorIDs and ErrorInfos (technology objects as of V2.0) (Page 3711)
MC_Power: Function chart (Page 2380)
MC_Reset: Acknowledge error (Page 2381)
MC_Home: Home axes, set home position (Page 2382)
MC_Halt: Halt axis (Page 2386)
MC_MoveAbsolute: Absolute positioning of axes (Page 2389)
MC_MoveRelative: Relative positioning of axes (Page 2392)
MC_MoveVelocity: Move axes at preset rotational speed (Page 2396)
MC_MoveJog: Move axes in jogging mode (Page 2400)
MC_ChangeDynamic: Changing the dynamic settings for the axis (as of technology object
"Axis" V2.0) (Page 2406)
MC_CommandTable: Run axis jobs as movement sequence (as of technology object "Axis"
V2.0) (Page 2404)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2379
MC_Power: Function chart
Function chart
t
t
t
t
t
t
t
1
t
t
MC_Power
Axis
Enable
Status
Busy
Error
ErrorlD
Errorlnfo
StopMode
Axis
Execute
Done
Busy
Error
ErrorlD
Errorlnfo
FB1 FB2
Axis_1
Ena_1
Status_1
Busy_1
Error_1
Axis_1
Exe_2
Done_2
Busy_2
MC_Reset
FB1
FB2
Ena_1
Exe_2
Status_1
Busy_1
Done_2
Busy_2
Error_1
Drive Enabled
Drive Ready
Drive lnterface
1
0
1
0
1
0
1
0
0
1
1
0
1
0
2 1
1
0
1
0
An axis is enabled and then disabled again. When the drive has signaled "Drive ready" back to the CPU, the successful
enable can be read out via "Status_1".
Following an axis enable, an error has occurred that caused the axis to be disabled. The error is eliminated and
acknowledged with "MC_Reset". The axis is then enabled again.
See also
MC_Power: Enable, disable axis (Page 2376)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2380 System Manual, 01/2013,
MC_Reset
MC_Reset: Acknowledge error
Description
Motion Control instruction "MC_Reset" can be used to acknowledge "Operating error with axis
stop" and "Configuration error". The errors that require acknowledgement can be found in the
"List of ErrorIDs and ErrorInfos" under "Remedy".
From version V3.0, the axis configuration can be downloaded to the work memory in RUN
operating mode.
Requirements
The technology object "Axis" has been configured correctly.
The cause of a pending configuration error requiring acknowledgement has been eliminated
(for example, acceleration in "Axis" technology object has been changed to a valid value).
Override response
The MC_Reset command cannot be aborted by any other motion control command.
The new MC_Reset command does not abort any other active motion control commands.
Parameter
Parameter Declaration Data type Default value Description
Axis INPUT TO_Axis_1 - Axis technology object
Execute INPUT BOOL FALSE Start of the command with a positive edge
Restart INPUT BOOL FALSE (From version V3.0)
TRUE Download the axis configuration from the load
memory to the work memory. The command can
only be executed when the axis is disabled.
Please refer to the notes on Download to the CPU
(Page 3670).
FALSE Acknowledges pending errors
Done OUTPUT BOOL FALSE TRUE Error has been acknowledged.
Busy OUTPUT BOOL FALSE TRUE The command is being executed.
Error OUTPUT BOOL FALSE TRUE An error occurred during execution of the
command. The cause of the error can be found in
parameters "ErrorID" and "ErrorInfo".
ErrorID OUTPUT WORD 16#0000 Error ID (Page 3711) for parameter "Error"
ErrorInfo OUTPUT WORD 16#0000 Error info ID (Page 3711) for parameter "ErrorID"
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2381
Acknowledging an error requiring acknowledgement with MC_Reset
To acknowledge an error, follow these steps:
1. Check the requirements indicated above.
2. Start the acknowledgement of the error with a rising edge at input parameter "Execute".
3. If output parameter "Done" indicates the value TRUE and tag of technology object <Axis
name>.StatusBits.Error the value FALSE, the error has been acknowledged.
See also
Download to CPU (Page 3670)
List of ErrorIDs and ErrorInfos (technology objects as of V2.0) (Page 3711)
MC_Power: Enable, disable axis (Page 2376)
MC_Home: Home axes, set home position (Page 2382)
MC_Halt: Halt axis (Page 2386)
MC_MoveAbsolute: Absolute positioning of axes (Page 2389)
MC_MoveRelative: Relative positioning of axes (Page 2392)
MC_MoveVelocity: Move axes at preset rotational speed (Page 2396)
MC_MoveJog: Move axes in jogging mode (Page 2400)
MC_CommandTable: Run axis jobs as movement sequence (as of technology object "Axis"
V2.0) (Page 2404)
MC_ChangeDynamic: Changing the dynamic settings for the axis (as of technology object
"Axis" V2.0) (Page 2406)
MC_Home
MC_Home: Home axes, set home position
Description
Use the motion control instruction "MC_Home" to match the axis coordinates to the real,
physical drive position. Homing is required for absolute positioning of the axis. The following
types of homing can be executed:
Active homing (Mode = 3)
The homing procedure is executed automatically.
Passive homing (Mode = 2)
During passive homing, the motion control instruction "MC_Home" does not carry out any
homing motion. The traversing motion required for this step must be implemented by the
user via other motion control instructions. When the homing switch is detected, the axis is
homed.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2382 System Manual, 01/2013,
Direct homing absolute (Mode = 0)
The current axis position is set to the value of parameter "Position".
Direct homing relative (Mode = 1)
The current axis position is offset by the value of parameter "Position".
Requirements
The technology object "Axis" has been configured correctly.
The axis is enabled.
No MC_CommandTable command may be active upon start with Mode = 0, 1 or 2.
Override response
The override response is dependent on the selected mode:
Mode = 0, 1
The MC_Home command cannot be aborted by any other motion control command.
The MC_Home command does not abort any active motion control commands. Position-
related motion commands are resumed after homing according to the new homing position
(value at input parameter: "Position").
Mode = 2
The MC_Home command can be aborted by the following motion control commands:
MC_Home command Mode = 2, 3
The new MC_Home command aborts the following active motion control command.
MC_Home command Mode = 2
Position-related motion commands are resumed after homing according to the new homing
position (value at input parameter: "Position").
Mode = 3
The MC_Home command can be aborted by the following motion control commands:
MC_Home command Mode = 3
MC_Halt command
MC_MoveAbsolute command
MC_MoveRelative command
MC_MoveVelocity command
MC_MoveJog command
The new MC_Home command aborts the following active motion control commands:
MC_Home command Mode = 2, 3
MC_Halt command
MC_MoveAbsolute command
MC_MoveRelative command
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2383
MC_MoveVelocity command
MC_MoveJog command
Parameter
Parameter Declaration Data type Default value Description
Axis INPUT TO_Axis_1 - Axis technology object
Execute INPUT BOOL FALSE Start of the command with a positive edge
Position INPUT REAL 0.0 Mode = 0, 2, and 3
Absolute position of axis after completion of the
homing operation
Mode = 1
Correction value for the current axis position
Limit values:
-1.0e
12
Position 1.0e
12
Mode INPUT INT 0 Homing mode
0 Direct homing absolute
New axis position is the position value of
parameter "Position".
1 Direct homing relative
New axis position is the current axis
position + position value of parameter
"Position".
2 Passive homing
Homing according to the axis
configuration. Following homing, the
value of parameter "Position" is set as the
new axis position.
3 Active homing
Home position approach in accordance
with the axis configuration. Following
homing, the value of parameter "Position"
is set as the new axis position.
Done OUTPUT BOOL FALSE TRUE Command completed
Busy OUTPUT BOOL FALSE TRUE The command is being executed.
CommandAborted OUTPUT BOOL FALSE TRUE During execution the command was
aborted by another command.
Error OUTPUT BOOL FALSE TRUE An error occurred during execution of the
command. The cause of the error can be
found in parameters "ErrorID" and
"ErrorInfo".
ErrorID OUTPUT WORD 16#0000 Error ID for parameter "Error"
ErrorInfo OUTPUT WORD 16#0000 Error info ID for parameter "ErrorID"
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2384 System Manual, 01/2013,
Note
Axis homing is lost under the following conditions:
Disabling of axis by motion control instruction "MC_Power"
Changeover between automatic mode and manual control
Upon start of active homing. After successful completion of the homing operation, axis
homing is again available.
After POWER OFF -> POWER ON of the CPU
After CPU restart (RUN-STOP -> STOP-RUN)
Homing an axis
To home the axis, follow these stops:
1. Check the requirements indicated above.
2. Initialize the necessary input parameters with values, and start the homing operation with
a rising edge at input parameter "Execute"
3. If output parameter "Done" and technology object tag <Axis
name>.StatusBits.HomingDone indicate the value TRUE, homing is complete.
See also
List of ErrorIDs and ErrorInfos (technology objects as of V2.0) (Page 3711)
MC_Power: Enable, disable axis (Page 2376)
MC_Reset: Acknowledge error (Page 2381)
MC_Halt: Halt axis (Page 2386)
MC_MoveAbsolute: Absolute positioning of axes (Page 2389)
MC_MoveRelative: Relative positioning of axes (Page 2392)
MC_MoveVelocity: Move axes at preset rotational speed (Page 2396)
MC_MoveJog: Move axes in jogging mode (Page 2400)
MC_CommandTable: Run axis jobs as movement sequence (as of technology object "Axis"
V2.0) (Page 2404)
MC_ChangeDynamic: Changing the dynamic settings for the axis (as of technology object
"Axis" V2.0) (Page 2406)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2385
MC_Halt
MC_Halt: Halt axis
Description
The "MC_Halt" motion control instruction stops all movements and brings the axis to a standstill
with the configured deceleration. The standstill position is not defined.
Requirements
The technology object "Axis" has been configured correctly.
The axis is enabled.
Override response
The MC_Halt command can be aborted by the following motion control jobs:
MC_Home command Mode = 3
MC_Halt command
MC_MoveAbsolute command
MC_MoveRelative command
MC_MoveVelocity command
MC_MoveJog command
The new MC_Halt command aborts the following active motion control jobs:
MC_Home command Mode = 3
MC_Halt command
MC_MoveAbsolute command
MC_MoveRelative command
MC_MoveVelocity command
MC_MoveJog command
Parameter
Parameter Declaration Data type Default value Description
Axis INPUT TO_Axis_1 - Axis technology object
Execute INPUT BOOL FALSE Start of the command with a positive edge
Done OUTPUT BOOL FALSE TRUE Zero velocity reached
Busy OUTPUT BOOL FALSE TRUE The command is being executed.
CommandAborted OUTPUT BOOL FALSE TRUE During execution the command was aborted
by another command.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2386 System Manual, 01/2013,
Parameter Declaration Data type Default value Description
Error OUTPUT BOOL FALSE TRUE An error occurred during execution of the
command. The cause of the error can be
found in parameters "ErrorID" and
"ErrorInfo".
ErrorID OUTPUT WORD 16#0000 Error ID (Page 3711) for parameter "Error"
ErrorInfo OUTPUT WORD 16#0000 Error info ID (Page 3711) for parameter "ErrorID"
See also
MC_Halt: Function chart (Page 2388)
List of ErrorIDs and ErrorInfos (technology objects as of V2.0) (Page 3711)
MC_Power: Enable, disable axis (Page 2376)
MC_Reset: Acknowledge error (Page 2381)
MC_Home: Home axes, set home position (Page 2382)
MC_MoveAbsolute: Absolute positioning of axes (Page 2389)
MC_MoveRelative: Relative positioning of axes (Page 2392)
MC_MoveVelocity: Move axes at preset rotational speed (Page 2396)
MC_MoveJog: Move axes in jogging mode (Page 2400)
MC_CommandTable: Run axis jobs as movement sequence (as of technology object "Axis"
V2.0) (Page 2404)
MC_ChangeDynamic: Changing the dynamic settings for the axis (as of technology object
"Axis" V2.0) (Page 2406)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2387
MC_Halt: Function chart
Function chart
t
t
t
t
t
t
t
50.0
1
0
t
t
Axis
Execute
Velocity
Direction
lnVelocity
Busy
CommandAborted
Error
ErrorlD
Errorlnfo
Current
Axis
Execute
Done
Busy
CommandAborted
Error
ErrorlD
Errorlnfo
MC_MoveVelocity
FB1
Axis_1
Exe_1
lnVel_1 Axis_1
Exe_2
Done_2
Abort_2
MC_Halt
FB2
FB1
FB2
Exe_1
Exe_2
lnVel_1
Abort_1
Done_2
Velocity
Axis_1
Abort_2
Abort_1
Busy_1 Busy_2
Busy_1
Busy_2
1
0
1
0
1
0
1
0
0
1
1
0
1 2
1
0
0
1
50.0
0.0
The following values were configured in the configuration window Dynamics > General:
Acceleration: 10.0
Deceleration: 5.0
The axis is braked by an MC_Halt command until it comes to a standstill. The axis standstill is signaled via "Done_2".
While an MC_Halt command is braking the axis, this command is aborted by another motion command. The abort is
signaled via "Abort_2".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2388 System Manual, 01/2013,
See also
MC_Halt: Halt axis (Page 2386)
MC_MoveAbsolute
MC_MoveAbsolute: Absolute positioning of axes
Description
The "MC_MoveAbsolute" motion control instruction starts an axis positioning motion to move
it to an absolute position.
Requirements
The technology object "Axis" has been configured correctly.
The axis is enabled.
The axis is homed.
Override response
The MC_MoveAbsolute command can be aborted by the following motion control commands:
MC_Home command Mode = 3
MC_Halt command
MC_MoveAbsolute command
MC_MoveRelative command
MC_MoveVelocity command
MC_MoveJog command
The new MC_MoveAbsolute command aborts the following active motion control commands:
MC_Home command Mode = 3
MC_Halt command
MC_MoveAbsolute command
MC_MoveRelative command
MC_MoveVelocity command
MC_MoveJog command
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2389
Parameter
Parameter Declaration Data type Default value Description
Axis INPUT TO_Axis_1 - Axis technology object
Execute INPUT BOOL FALSE Start of the command with a positive edge
Position INPUT REAL 0.0 Absolute target position
Limit values:
-1.0e
12
Position 1.0e
12
Velocity INPUT REAL 10.0 Velocity of axis
This velocity is not always reached on account of the
configured acceleration and deceleration and the
target position to be approached.
Limit values:
Start/stop velocity Velocity maximum velocity
Done OUTPUT BOOL FALSE TRUE Absolute target position reached
Busy OUTPUT BOOL FALSE TRUE The command is being executed.
CommandAborted OUTPUT BOOL FALSE TRUE During execution the command was aborted
by another command.
Error OUTPUT BOOL FALSE TRUE An error occurred during execution of the
command. The cause of the error can be
found in parameters "ErrorID" and
"ErrorInfo".
ErrorID OUTPUT WORD 16#0000 Error ID (Page 3711) for parameter "Error"
ErrorInfo OUTPUT WORD 16#0000 Error info ID (Page 3711) for parameter "ErrorID"
See also
MC_MoveAbsolute: Function chart (Page 2391)
List of ErrorIDs and ErrorInfos (technology objects as of V2.0) (Page 3711)
MC_Power: Enable, disable axis (Page 2376)
MC_Reset: Acknowledge error (Page 2381)
MC_Home: Home axes, set home position (Page 2382)
MC_Halt: Halt axis (Page 2386)
MC_MoveRelative: Relative positioning of axes (Page 2392)
MC_MoveVelocity: Move axes at preset rotational speed (Page 2396)
MC_MoveJog: Move axes in jogging mode (Page 2400)
MC_CommandTable: Run axis jobs as movement sequence (as of technology object "Axis"
V2.0) (Page 2404)
MC_ChangeDynamic: Changing the dynamic settings for the axis (as of technology object
"Axis" V2.0) (Page 2406)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2390 System Manual, 01/2013,
MC_MoveAbsolute: Function chart
Function chart
t
t
t
t
t
1
0
1
0
1
0
1
0
1
0
t
t
1
0 t
1
0 t
50.0
30.0
1500.0
1000.0
FB1 FB2
MC_MoveAbsolute
Axis
Execute
Position
Velocity
Axis_1
Exe_1
1000.0
50.0
Done
Busy
CommandAborted
Error
ErrorlD
Errorlnfo
Done_1
Abort_1
Axis
Execute
Position
Velocity
Done
Busy
CommandAborted
Error
ErrorlD
Errorlnfo
Axis_1
Exe_2
1500.0
30.0
Done_2
FB1
FB2
Exe_1
Exe_2
Done_1
Abort_1
Done_2
Velocity
Axis_1
Position
Axis_1
MC_MoveAbsolute
Busy_1
Busy_1 Busy_2
Busy_2
0.0
0.0
1 2
The following values were configured in the configuration window Dynamics > General:
Acceleration: 10.0
Deceleration: 10.0
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2391
An axis is moved to absolute position 1000.0 with an MC_MoveAbsolute command. When the axis reaches the target
position, this is signaled via "Done_1". When "Done_1" = TRUE, another MC_MoveAbsolute command, with target
position 1500.0, is started. Because of the response times (e.g., cycle time of user program, etc.), the axis comes to a
standstill briefly (see zoomed-in detail). When the axis reaches the new target position, this is signaled via "Done_2".
An active MC_MoveAbsolute command is aborted by another MC_MoveAbsolute command. The abort is signaled via
"Abort_1". The axis is then moved at the new velocity to the new target position 1500.0. When the new target position
is reached, this is signaled via "Done_2".
See also
MC_MoveAbsolute: Absolute positioning of axes (Page 2389)
MC_MoveRelative
MC_MoveRelative: Relative positioning of axes
Description
The "MC_MoveRelative" motion control instruction starts a positioning motion relative to the
start position.
Requirements
The technology object "Axis" has been configured correctly.
The axis is enabled.
Override response
The MC_MoveRelative command can be aborted by the following motion control jobs:
MC_Home command Mode = 3
MC_Halt command
MC_MoveAbsolute command
MC_MoveRelative command
MC_MoveVelocity command
MC_MoveJog command
The new MC_MoveRelative command aborts the following active motion control jobs:
MC_Home command Mode = 3
MC_Halt command
MC_MoveAbsolute command
MC_MoveRelative command
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2392 System Manual, 01/2013,
MC_MoveVelocity command
MC_MoveJog command
Parameter
Parameter Declaration Data type Default value Description
Axis INPUT TO_Axis_1 - Axis technology object
Execute INPUT BOOL FALSE Start of the command with a positive edge
Distance INPUT REAL 0.0 Travel distance for the positioning operation
Limit values:
-1.0e
12
Distance 1.0e
12
Velocity INPUT REAL 10.0 Velocity of axis
This velocity is not always reached on account of the
configured acceleration and deceleration and the
distance to be traveled.
Limit values:
Start/stop velocity Velocity maximum velocity
Done OUTPUT BOOL FALSE TRUE Target position reached
Busy OUTPUT BOOL FALSE TRUE The command is being executed.
CommandAborted OUTPUT BOOL FALSE TRUE During execution the command was aborted
by another command.
Error OUTPUT BOOL FALSE TRUE An error occurred during execution of the
command. The cause of the error can be
found in parameters "ErrorID" and
"ErrorInfo".
ErrorID OUTPUT WORD 16#0000 Error ID (Page 3711) for parameter "Error"
ErrorInfo OUTPUT WORD 16#0000 Error info ID (Page 3711) for parameter "ErrorID"
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2393
See also
MC_MoveRelative: Function chart (Page 2395)
List of ErrorIDs and ErrorInfos (technology objects as of V2.0) (Page 3711)
MC_Power: Enable, disable axis (Page 2376)
MC_Reset: Acknowledge error (Page 2381)
MC_Home: Home axes, set home position (Page 2382)
MC_Halt: Halt axis (Page 2386)
MC_MoveAbsolute: Absolute positioning of axes (Page 2389)
MC_MoveVelocity: Move axes at preset rotational speed (Page 2396)
MC_MoveJog: Move axes in jogging mode (Page 2400)
MC_CommandTable: Run axis jobs as movement sequence (as of technology object "Axis"
V2.0) (Page 2404)
MC_ChangeDynamic: Changing the dynamic settings for the axis (as of technology object
"Axis" V2.0) (Page 2406)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2394 System Manual, 01/2013,
MC_MoveRelative: Function chart
Function chart
t
t
t
t
t
t
t
MC_MoveRelative MC_MoveRelative
FB1 FB2
1
0
t
t
Axis
Execute
Distance
Velocity
Done
Busy
CommandAborted
Error
ErrorlD
Errorlnfo
Axis
Execute
Distance
Velocity
Done
Busy
CommandAborted
Error
ErrorlD
Errorlnfo
Axis_1
Exe_1
1000.0
50.0
Done_1
Abort_1
Axis_1
Exe_2
500.0
30.0
Done_2
FB1
FB2
Exe_1
Exe_2
Done_1
Abort_1
Done_2
Velocity
Axis_1
Position
Axis_1
Busy_1 Busy_2
Busy_1
Busy_2
50.0
0.0
1500.0
1000.0
0.0
1
0
1
0
1
0
1
0
1
0
500
500
1 2
1
0
1
0
30.0
The following values were configured in the configuration window Dynamics > General:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2395
Acceleration: 10.0
Deceleration: 10.0
The axis is moved by an MC_MoveRelative command by the distance ("Distance") 1000.0. When the axis reaches the
target position, this is signaled via "Done_1". When "Done_1" = TRUE, another MC_MoveRelative command, with travel
distance 500.0, is started. Because of the response times (e.g., cycle time of user program, etc.), the axis comes to a
standstill briefly (see zoomed-in detail). When the axis reaches the new target position, this is signaled via "Done_2".
An active MC_MoveRelative command is aborted by another MC_MoveRelative command. The abort is signaled via
"Abort_1". The axis is then moved at the new velocity by the new distance ("Distance") 500.0. When the new target
position is reached, this is signaled via "Done_2".
See also
MC_MoveRelative: Relative positioning of axes (Page 2392)
MC_MoveVelocity
MC_MoveVelocity: Move axes at preset rotational speed
Description
Motion control instruction "MC_MoveVelocity" moves the axis constantly at the specified
velocity.
Requirements
The technology object "Axis" has been configured correctly.
The axis is enabled.
Override response
MC_MoveVelocity can be aborted by the following motion control commands:
MC_Home command Mode = 3
MC_Halt command
MC_MoveAbsolute command
MC_MoveRelative command
MC_MoveVelocity command
MC_MoveJog command
The new MC_MoveVelocity command aborts the following active motion control commands:
MC_Home command Mode = 3
MC_Halt command
MC_MoveAbsolute command
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2396 System Manual, 01/2013,
MC_MoveRelative command
MC_MoveVelocity command
MC_MoveJog command
Parameter
Parameter Declaration Data type Default value Description
Axis INPUT TO_Axis_1 - Axis technology object
Execute INPUT BOOL FALSE Start of the command with a positive edge
Velocity INPUT REAL 10.0 Velocity specification for axis motion
Limit values:
Start/stop velocity |Velocity maximum velocity
(Velocity = 0.0 is permitted)
Direction INPUT INT 0 Direction specification
0 Direction of rotation corresponds to the sign
of the value in parameter "Velocity"
1 Positive direction of rotation
(The sign of the value in parameter
"Velocity" is ignored)
2 Negative direction of rotation
(The sign of the value in parameter
"Velocity" is ignored)
Current INPUT BOOL FALSE Maintain current velocity
FALSE "Maintain current velocity" is deactivated.
The values of parameters "Velocity" and
"Direction" are used.
TRUE "Maintain current velocity" is activated. The
values in parameters "Velocity" and
"Direction" are not taken into account.
When the axis resumes motion at the
current velocity, the "InVelocity" parameter
returns the value TRUE.
InVelocity OUTPUT BOOL FALSE TRUE "Current" = FALSE:
The velocity specified in parameter
"Velocity" was reached.
"Current" = TRUE:
The axis travels at the current velocity at
the start time.
Busy OUTPUT BOOL FALSE TRUE The command is being executed.
CommandAborted OUTPUT BOOL FALSE TRUE During execution the command was aborted
by another command.
Error OUTPUT BOOL FALSE TRUE An error occurred during execution of the
command. The cause of the error can be
found in parameters "ErrorID" and
"ErrorInfo".
ErrorID OUTPUT WORD 16#0000 Error ID (Page 3711) for parameter "Error"
ErrorInfo OUTPUT WORD 16#0000 Error info ID (Page 3711) for parameter "ErrorID"
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2397
Behavior with zero set velocity (Velocity = 0.0)
An MC_MoveVelocity command with "Velocity" = 0.0 (such as an MC_Halt command) aborts
active motion commands and stops the axis with the configured deceleration.
When the axis comes to a standstill, output parameter "InVelocity" indicates TRUE for at least
one program cycle.
"Busy" indicates the value TRUE during the deceleration process and changes to FALSE
together with "InVelocity". If parameter "Execute" = TRUE is set, "InVelocity" and "Busy" are
latched.
When the "MC_MoveVelocity" command is started, status bit "SpeedCommand" is set in the
technology object. Status bit "ConstantVelocity" is set upon axis standstill. Both bits are
adapted to the new situation when a new motion command is started.
See also
MC_MoveVelocity: Function chart (Page 2399)
List of ErrorIDs and ErrorInfos (technology objects as of V2.0) (Page 3711)
MC_Power: Enable, disable axis (Page 2376)
MC_Reset: Acknowledge error (Page 2381)
MC_Home: Home axes, set home position (Page 2382)
MC_Halt: Halt axis (Page 2386)
MC_MoveAbsolute: Absolute positioning of axes (Page 2389)
MC_MoveRelative: Relative positioning of axes (Page 2392)
MC_MoveJog: Move axes in jogging mode (Page 2400)
MC_CommandTable: Run axis jobs as movement sequence (as of technology object "Axis"
V2.0) (Page 2404)
MC_ChangeDynamic: Changing the dynamic settings for the axis (as of technology object
"Axis" V2.0) (Page 2406)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2398 System Manual, 01/2013,
MC_MoveVelocity: Function chart
Function chart
t
t
t
t
t
t
t
t
FB1
FB2
Exe_1
Exe_2
lnVel_1
Abort_1
lnVel_2
Velocity
Axis_1
0
Axis
Execute
Velocity
Direction
lnVelocity
Busy
CommandAborted
Error
ErrorlD
Errorlnfo
Current
Axis
Execute
Velocity
Direction
lnVelocity
Busy
CommandAborted
Error
ErrorlD
Errorlnfo
Current
Axis_1
Exe_1
50.0
1
0
lnVel_1
Abort_1
Axis_1
Exe_2
15.0
1
lnVel_2
MC_MoveVelocity
MC_MoveVelocity
FB1 FB2
Busy_1 Busy_2
Busy_1
Busy_2
1
0
1
0
1
0
1
0
1
0
1 2
1
0
1
0
50.0
15.0
0.0
The following values were configured in the configuration window Dynamics > General:
Acceleration: 10.0
Deceleration: 10.0
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2399
An active MC_MoveVelocity command signals via "InVel_1" that its target velocity has been reached. It is then aborted
by another MC_MoveVelocity command. The abort is signaled via "Abort_1". When the new target velocity 15.0 is
reached, this is signaled via "InVel_2". The axis then continues moving at the new constant velocity.
An active MC_MoveVelocity command is aborted by another MC_MoveVelocity command prior to reaching its target
velocity. The abort is signaled via "Abort_1". When the new target velocity 15.0 is reached, this is signaled via "InVel_2".
The axis then continues moving at the new constant velocity.
See also
MC_MoveVelocity: Move axes at preset rotational speed (Page 2396)
MC_MoveJog
MC_MoveJog: Move axes in jogging mode
Description
Motion control instruction "MC_MoveJog" moves the axis constantly at the specified velocity
in jog mode. You use this motion control instruction, for example, for testing and commissioning
purposes.
Requirements
The technology object "Axis" has been configured correctly.
The axis is enabled.
Override response
The MC_MoveJog command can be aborted by the following motion control commands:
MC_Home command Mode = 3
MC_Halt command
MC_MoveAbsolute command
MC_MoveRelative command
MC_MoveVelocity command
MC_MoveJog command
The new MC_MoveJog command aborts the following active motion control commands:
MC_Home command Mode = 3
MC_Halt command
MC_MoveAbsolute command
MC_MoveRelative command
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2400 System Manual, 01/2013,
MC_MoveVelocity command
MC_MoveJog command
Parameter
Parameter Declaration Data type Default value Description
Axis INPUT TO_Axis_1 - Axis technology object
JogForward INPUT BOOL FALSE As long as the parameter is TRUE, the axis moves in
the positive direction at the velocity specified in
parameter "Velocity".
JogBackward INPUT BOOL FALSE As long as the parameter is TRUE, the axis moves in
the negative direction at the velocity specified in
parameter "Velocity".
If both parameters are simultaneously TRUE, the axis stops with the configured deceleration. An error is indicated in
parameters "Error", "ErrorID", and "ErrorInfo".
Velocity INPUT REAL 10.0 Preset velocity for jog mode
Limit values, instruction version V1.0:
Start/stop velocity |Velocity maximum velocity
Limits, instruction version V2.0:
Start/stop velocity velocity maximum velocity
InVelocity OUTPUT BOOL FALSE TRUE The velocity specified in parameter
"Velocity" was reached.
Busy OUTPUT BOOL FALSE TRUE The command is being executed.
CommandAborted OUTPUT BOOL FALSE TRUE During execution the command was aborted
by another command.
Error OUTPUT BOOL FALSE TRUE An error occurred during execution of the
command. The cause of the error can be
found in parameters "ErrorID" and
"ErrorInfo".
ErrorID OUTPUT WORD 16#0000 Error ID (Page 3711) for parameter "Error"
ErrorInfo OUTPUT WORD 16#0000 Error info ID (Page 3711) for parameter "ErrorID"
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2401
See also
MC_MoveJog: Function chart (Page 2403)
List of ErrorIDs and ErrorInfos (technology objects as of V2.0) (Page 3711)
MC_Power: Enable, disable axis (Page 2376)
MC_Reset: Acknowledge error (Page 2381)
MC_Home: Home axes, set home position (Page 2382)
MC_Halt: Halt axis (Page 2386)
MC_MoveAbsolute: Absolute positioning of axes (Page 2389)
MC_MoveRelative: Relative positioning of axes (Page 2392)
MC_MoveVelocity: Move axes at preset rotational speed (Page 2396)
MC_CommandTable: Run axis jobs as movement sequence (as of technology object "Axis"
V2.0) (Page 2404)
MC_ChangeDynamic: Changing the dynamic settings for the axis (as of technology object
"Axis" V2.0) (Page 2406)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2402 System Manual, 01/2013,
MC_MoveJog: Function chart
Function chart
t t
t
t
t
t
50.0
FB1
Jog_B
Jog_F
lnVel_1
Busy_1
Velocity
Axis_1
FB1
Axis
JogForward
JogBackward
Velocity
lnVelocity
Busy
CommandAborted
Error
ErrorlD
Errorlnfo
MC_MoveJog
Axis_1
Jog_F
Jog_B
lnVel_1
Busy_1
1
0
1
0
0
1
1
0
1 2
50.0
50.0
-
0.0
The following values were configured in the configuration window Dynamics > General:
Acceleration: 10.0
Deceleration: 5.0
The axis is moved in the positive direction in jog mode via "Jog_F". When the target velocity 50.0 is reached, this is
signaled via "InVelo_1". The axis brakes to a standstill again after Jog_F is reset.
The axis is moved in the negative direction in jog mode via "Jog_B". When the target velocity 50.0 is reached, this is
signaled via "InVelo_1". The axis brakes to a standstill again after Jog_B is reset.
See also
MC_MoveJog: Move axes in jogging mode (Page 2400)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2403
MC_CommandTable
MC_CommandTable: Run axis jobs as movement sequence (as of technology object "Axis" V2.0)
Description
The Motion Control instruction "MC_CommandTable" combines multiple individual axis control
commands in one movement sequence.
Requirements
The technology object "Axis" has been added to Version V2.0 and correctly configured.
The technology object "Command table" has been added and correctly configured.
The axis is enabled.
Override response
The MC_CommandTable command can be aborted by the following motion control commands:
MC_Home command (Mode = 3)
MC_Halt command
MC_MoveAbsolute command
MC_MoveRelative command
MC_MoveVelocity command
MC_MoveJog command
MC_CommandTable command
The new MC_CommandTable command aborts the following active motion control commands:
MC_Home command (Mode = 3)
MC_Halt command
MC_MoveAbsolute command
MC_MoveRelative command
MC_MoveVelocity command
MC_MoveJog command
MC_CommandTable command
The active motion control command is cancelled by the start of the first "Positioning Relative",
"Positioning Absolute", "Velocity set point" or "Halt" command.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2404 System Manual, 01/2013,
Parameter
Parameter Declaration Data type Default value Description
Axis INPUT TO_Axis_1 - Axis technology object
CommandTab
le
INPUT TO_CommandT
able_1
- Command table technology object
Execute INPUT BOOL FALSE Command table start with positive edge
StartStep INPUT INT 1 Defines the step at which the execution of the command
table should begin
Limit values:
1 StartStep EndStep
EndStep INPUT INT 32 Defines the step up to which the execution of command
table should take place
Limit values:
StartStep EndStep 32
Done OUTPUT BOOL FALSE TRUE Command table has been successfully executed
Busy OUTPU BOOL FALSE TRUE The command table is being executed.
CommandAb
orted
OUTPUT BOOL FALSE TRUE The command table was cancelled by another
command.
Error OUTPUT BOOL FALSE TRUE An error occurred during execution of the
command table. The cause of the error can be
found in parameters "ErrorID" and "ErrorInfo".
ErrorID OUTPUT WORD 16#0000 Error ID (Page 3711) for parameter "Error"
ErrorInfo OUTPUT WORD 16#0000 Error info ID (Page 3711) for parameter "ErrorID"
CurrentStep OUTPUT INT 0 Step in command table currently being executed
StepCode OUTPUT WORD 16#0000 User-defined numerical value / bit pattern of the step
currently being executed
See also
List of ErrorIDs and ErrorInfos (technology objects as of V2.0) (Page 3711)
Overview of the Motion Control statements (Page 3674)
MC_Power: Enable, disable axis (Page 2376)
MC_Reset: Acknowledge error (Page 2381)
MC_Home: Home axes, set home position (Page 2382)
MC_Halt: Halt axis (Page 2386)
MC_MoveAbsolute: Absolute positioning of axes (Page 2389)
MC_MoveRelative: Relative positioning of axes (Page 2392)
MC_MoveVelocity: Move axes at preset rotational speed (Page 2396)
MC_MoveJog: Move axes in jogging mode (Page 2400)
MC_ChangeDynamic: Changing the dynamic settings for the axis (as of technology object
"Axis" V2.0) (Page 2406)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2405
MC_ChangeDynamic
MC_ChangeDynamic: Changing the dynamic settings for the axis (as of technology object "Axis" V2.0)
Description
Motion Control instruction "MC_ChangeDynamic" allows you to change the following settings
of the axis:
Change the ramp-up time (acceleration) value
Change the ramp-down time (deceleration) value
Change the emergency stop ramp-down time (emergency stop deceleration) value
Change the smoothing time (jerk) value
The effectiveness of the change is shown in the description of the tag (Page 3720).
Requirements
The technology object "Axis" has been added to Version V2.0.
The technology object "Axis" has been configured correctly.
Override response
A MC_ChangeDynamic command cannot be aborted by any other Motion Control command.
A new MC_ChangeDynamic command does not abort any active Motion Control commands.
Parameter
Parameter Declaration Data type Default value Description
Axis INPUT TO_Axis_1 - Axis technology object
Execute INPUT BOOL FALSE Start of the command with a positive edge
ChangeRa
mpUp
INPUT BOOL FALSE TRUE Change ramp-up time in line with input parameter
"RampUpTime"
RampUpTi
me
INPUT REAL 5.00 Time (in seconds) to accelerate axis from standstill to
configured maximum velocity without jerk limit.
The change will influence the tag <Axis name>.
Config.DynamicDefaults.Acceleration. The effectiveness of
the change is shown in the description of this tag.
ChangeRa
mpDown
INPUT BOOL FALSE TRUE Change ramp-down time in line with input
parameter "RampDownTime"
RampDown
Time
INPUT REAL 5.00 Time (in seconds) to decelerate axis from the configured
maximum velocity to standstill without jerk limiter.
The change will influence the tag <Axis name>.
Config.DynamicDefaults.Deceleration . The effectiveness of
the change is shown in the description of this tag.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2406 System Manual, 01/2013,
Parameter Declaration Data type Default value Description
ChangeEm
ergency
INPUT BOOL FALSE TRUE Change emergency stop ramp-down time in line
with input parameter "EmergencyRampTime"
Emergency
RampTime
INPUT REAL 2.00 Time (in seconds) to decelerate the axis from configured
maximum velocity to standstill without jerk limiter in
emergency stop mode.
The change will influence the tag <Axis name>.
Config.DynamicDefaults.EmergencyDeceleration . The
effectiveness of the change is shown in the description of this
tag.
ChangeJer
kTime
INPUT BOOL FALSE TRUE Change smoothing time according to the input
parameter "JerkTime"
JerkTime INPUT REAL 0.25 Smoothing time (in seconds) used for the axis acceleration
and deceleration ramps
The change will influence the tag <Axis name>.
Config.DynamicDefaults.Jerk . The effectiveness of the
change is shown in the description of this tag.
Done OUTPUT BOOL FALSE TRUE The changed values have been written to the
technology data block. The description of the tags
will show when the change becomes effective.
Error OUTPUT BOOL FALSE TRUE An error occurred during execution of the
command. The cause of the error can be found in
parameters "ErrorID" and "ErrorInfo".
ErrorID OUTPUT WORD 16#0000 Error ID (Page 3711) for parameter "Error"
ErrorInfo OUTPUT WORD 16#0000 Error info ID (Page 3711) for parameter "ErrorID"
Note
At the input parameters "RampUpTime", "RampDownTime", "EmergencyRampTime" and
"JerkTime", values can be entered which exceed the admissible limits of the resulting
parameters: "Acceleration", "Deceleration", "Emergency stop deceleration" and "Jerk".
Please note the equations and limit values in "Axis technology object" -> "Configuring the
technology object" -> "Dynamics" and ensure that the values you input are within the valid
range.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2407
See also
List of ErrorIDs and ErrorInfos (technology objects as of V2.0) (Page 3711)
Overview of the Motion Control statements (Page 3674)
Changing the configuration of dynamics in the user program (Page 3644)
Changing the homing configuration in the user program (Page 3651)
MC_Power: Enable, disable axis (Page 2376)
MC_Reset: Acknowledge error (Page 2381)
MC_Home: Home axes, set home position (Page 2382)
MC_Halt: Halt axis (Page 2386)
MC_MoveAbsolute: Absolute positioning of axes (Page 2389)
MC_MoveRelative: Relative positioning of axes (Page 2392)
MC_MoveVelocity: Move axes at preset rotational speed (Page 2396)
MC_MoveJog: Move axes in jogging mode (Page 2400)
MC_CommandTable: Run axis jobs as movement sequence (as of technology object "Axis"
V2.0) (Page 2404)
Tag of the Axis technology object (Page 3720)
9.8.5 Communication
9.8.5.1 S7 communication
Data consistency
Definition
The size of the data area which can be modified simultaneously by concurrent processes is
called the consistent data area. Data areas which are larger than the consistent data area can
thus be falsified as a whole.
This means that a data area which belongs together and which is larger than consistent data
area can consist in part of new and of old consistent data blocks at the same time.
Example
An inconsistency can arise if a communication block is interrupted, for example, by a hardware
interrupt OB with a higher priority. If the user program in this OB now changes the data which
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2408 System Manual, 01/2013,
have already been processed in part by the communication block, the transferred data
originate:
In part from the time before the hardware interrupt was processed
And in part from the time after the hardware interrupt was processed
This means that these data are inconsistent (not coherent).
Effect
If larger packages of data are to be transferred in a consistent form, the transfer should not be
interrupted. This can, for example, increase the interrupt reaction time of the CPU.
In other words: The greater the quantity of data which must be transferred with absolute
consistency, the longer the interrupt reaction time of a system.
Data consistency with SIMATIC
If the user program contains a communication function that accesses common data, access
to this data area can be coordinated, e.g., by means of the DONE parameter itself. The
data consistency of the communication areas which are transferred locally with a
communication block can therefore be ensured in the user program.
In the case of S7 communication instructions "PUT (Page 2415)"/"GET (Page 2413)", the
size of the consistent data areas must already be taken into consideration during
programming or configuration, because a communication block is not available in the user
program of the target device (server) to synchronize communication data to the user
program.
For the S7-300 and C7-300 (exception: CPU 318-2 DP) the communication data are copied
consistently into the user memory in blocks of 32 bytes in the cycle control point of the
operating system. Data consistency is not guaranteed for larger data areas. If a defined
data consistency is required, the communication data in the user program may not exceed
32 bytes (maximum of 8 bytes, depending on the version).
In the S7-400 and S7-1500, on the other hand, the communication data in 462-byte blocks
are not processed in the cycle control point, but in fixed time slices during the program
cycle. The consistency of a tag is ensured by the system. These communication areas can
then be accessed consistently using the "PUT (Page 2415)" / "GET (Page 2413)"
instructions or when reading/writing tags, for example by an OP or an OS.
Note
Additional information on data consistency is provided in the description of the specific
instructions.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2409
Common parameters of instructions for S7 communication
Classification
The parameters of the instructions for S7 communication can be divided into the following five
categories according to their functions:
1. Control parameters are used to activate an instruction.
2. Addressing parameters are used to address the remote communication partner.
3. Send parameters point to the data areas that are to be sent to the remote partner.
4. Receive parameters point to the data areas where the data received from remote partners
will be entered.
5. Status parameters are used to monitor whether the instruction has completed its task
without error or for the analysis of any errors that have occurred.
Control parameter
Data exchange will only be activated if the appropriate control parameters have a defined value
(for example, are set) when the instruction is called or when the value has undergone a specific
change since the previous call (for example, a positive edge).
Addressing parameters
Parameter Description
ID Reference to the local connection description (specified by the configuration of the
connection). Note: The ID W#16#EEEE is not permitted for S7communication instructions.
R_ID With the R_ID parameter, you specify that a send and a receive instruction belong
together: The R_ID parameter must match in the instruction at the sending end and the
instruction at the receiving end.
This allows the communication of several instruction pairs via the same logic connection.
R_ID must be specified in the form DW#16#wxyzWXYZ.
The instruction pairs of a logical connection specified in R_ID must be unique for this
connection.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2410 System Manual, 01/2013,
Note
Addressing parameters ID and R_ID
You can reassign the addressing parameters ID and R_ID during runtime. The new
parameters are validated with each new job after the previous job has been closed.
You can use the following options to reduce the number of instance DBs and therefore the
work memory required:
1. With tag IDs, you can use several connections via one data instance block.
2. With tag R_IDs, you can define several pairs of sending and receiving instructions for one
job with a single instance.
3. You can combine cases 1 and 2.
Please note that the new parameters are valid after the last job is executed. When you activate
the sending operation, the R_ID parameter in the instruction at the sending end must match
its counterpart at the receiving end.
Status parameter
With the status parameters, you monitor whether the instruction has completed its task
correctly or whether it is still active. The status parameters also indicate errors.
Note
The status parameters are valid for one cycle only, namely from the first command following
the call until the next call. As a result, you must evaluate these parameters after each
instruction cycle.
Send and receive parameters
For communication instructions configured at both ends
The number of the SD_i and RD_i parameters used must match at the send and receive
end.
The data types of the SD_i and RD_i parameters that belong together must match at the
send and receive end.
The amount of data to be sent according to the SD_i parameter must not exceed the range
made available by the corresponding RD_i (does not apply to "BSEND" / "BRCV"). The
RD_i parameters must (with exception of "BSEND"/"BRCV") have the identical data size.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2411
If you do not keep to the rules above, this is indicated by ERROR = 1 and STATUS = 4.
Note
Supplying the send and receive parameters
With the VARIANT data type, send and receive parameters must always be supplied any
time a communication instruction is called. It is not possible, for example, to supply the send
buffer of the communication instruction at startup and to only trigger the send job in cyclic
operation.
User data size
With the "USEND", "URCV", "GET (Page 2413)" and "PUT (Page 2415)" instructions, the
amount of data to be transferred must not exceed a defined user data size. The maximum user
data size depends on:
The instruction used
The communication partner.
The guaranteed minimum size of the user data for an instruction with 1-4 tags is listed in the
following table:
Instruction Partner: S7-300 Partner: S7-400 Partner: S7-1200 Partner: S7-1500
PUT / GET 160 bytes 400 bytes 160 bytes 880 bytes
USEND / URCV 160 bytes 440 bytes - 920 bytes
BSEND / BRCV 32768/65534
bytes
65534 bytes - 65534 bytes
Further information on the user data size can be found in the technical data of the respective
CPU.
Exact user data size
If the user data size specified above is insufficient you can determine the maximum byte length
of the user data as follows:
First read the data block size valid for communication from the following table:
Local CPU Remote CPU Data block size in bytes
S7-1200 Any 240
S7-1500
S7-300 240
S7-400 480
S7-1200 240
S7-1500 960
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2412 System Manual, 01/2013,
Use this value in the following table to read the maximum possible user data length in bytes
as total of the parameters used. It applies for even lengths of the areas SD_i, RD_i, and
ADDR_i.
For each range of uneven length the maximum possible user data length is reduced by one
byte.
Number of SD_i, RD_i, ADDR_i parameters used
Data block size Instruction 1 2 3 4
240 (S7-300) PUT/GET/
USEND
160 - - -
240 (S7-300 via
integrated interface)
PUT 212 - - -
GET 222 - - -
USEND 212 - - -
240 (S7-400) PUT 212 196 180 164
GET 222 218 214 210
USEND 212 - - -
480 (S7-400) PUT 452 436 420 404
GET 462 458 454 450
USEND 452 448 444 440
240 (S7-1200) PUT 212 196 180 164
GET 222 218 214 210
960 (S7-1500) PUT 932 916 900 884
GET 942 938 934 930
USEND 932 928 924 920
GET: Read data from a remote CPU
Description
With the instruction "GET", you can read data from a remote CPU. This is only possible if the
"Allow remote partner access via PUT/GET communication" function was activated for the
partner CPU in the properties of the CPU in "Protection". You cannot use the "GET" instruction
to access blocks that were created with "optimized" access type.
The instruction is started on a positive edge at control input REQ. The relevant pointers to the
areas to be read out (ADDR_i) are then sent to the partner CPU. The remote CPU can be in
RUN or STOP mode. The remote partner returns the data.
A zero at any of the ADDR_i parameters will be ignored. The received data is copied to the
configured receive areas (RD_i) at the next call.
Make sure that the areas defined with the parameters ADDR_i and RD_i match in terms of
number, length, and data type.
If the area to be read (ADDR_i parameter) is greater than the area for data storage (RD_i
parameter), an error is output (ERROR = 1, STATUS = 4).
If the area to be read (ADDR_i parameter) is smaller than the area for data storage (RD_i
parameter), the instruction is executed without error.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2413
Changes in the data areas addressed on the partner CPU are not registered by the "GET"
instruction.
Completion of this action is indicated by the status parameter NDR having the value "1".
Reading can only be activated again after the previous reading process has been completed.
Errors and warnings are output via ERROR and STATUS if access problems occurred while
the data was being read or if the data type check results in an error.
Parameter
The following table shows the parameters of the "GET" instruction:
Parameter Declaration Data type Memory area Description
REQ Input BOOL I, Q, M, D, L or
constant
Control parameter request, activates the
data exchange on a rising edge.
ID Input CONN_PRG
(WORD)
I, Q, M, D, L or
constant
Addressing parameters for specifying the
connection to the partner CPU.
NDR Output BOOL I, Q, M, D, L Status parameter NDR:
0: Job not yet started or still executing.
1: Job successfully completed.
ERROR
Output BOOL I, Q, M, D, L Status parameters ERROR and STATUS,
error code:
ERROR=0
STATUS has the value:
0000H: Neither warning nor error
<> 0000H: Warning, STATUS
supplies detailed information.
ERROR=1
An error has occurred. STATUS
supplies detailed information on the type
of error.
STATUS Output WORD I, Q, M, D, L
ADDR_1 InOut REMOTE I, Q, M, D
Pointers to the areas on the partner CPU
that are to be read.
When the REMOTE pointer accesses a DB,
the DB must always be specified.
Example: P#DB10.DBX5.0 Byte 10.
ADDR_2 InOut REMOTE
ADDR_3 InOut REMOTE
ADDR_4 InOut REMOTE
RD_1 InOut VARIANT I, Q, M, D, L Pointers to the areas on the local CPU in
which the read data are entered.
RD_2 InOut VARIANT
RD_3 InOut VARIANT
RD_4 InOut VARIANT
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2414 System Manual, 01/2013,
Parameters ERROR and STATUS
The following table contains all specific error information for the "GET" instruction that can be
output via the ERROR and STATUS parameters.
ERROR STATUS
(decimal)
Explanation
0 11 Warning:
New job not active because the previous job is still busy.
The job is already being processed in a priority class with lower priority.
0 25 Communication has started. The job is being processed.
1 1 Communications problems, for example
Connection description not loaded (local or remote)
Connection interrupted (for example: cable, CPU off, CP in STOP mode)
Connection to partner not yet established
1 2 Negative acknowledgement from the partner device. The function cannot be executed.
1 4 Error in the pointers to the data storage RD_i:
Data types of the parameters RD_i and ADDR_i are not compatible with each other.
The length of the area RD_i is smaller than the length of the data of the ADDR_i parameter
that is to be read.
1 8 Access error on the partner CPU.
1 10 Access to the local user memory not possible (for example, access to a deleted DB).
1 20 Not enough work memory.
Maximum number of parallel jobs exceeded.
Note
Data consistency
Data is received consistently if you read the part of the receive area RD_i currently being
used completely before initiating another job.
See also
Common parameters of instructions for S7 communication (Page 2410)
PUT: Write data to a remote CPU
Description
You can write data to a remote CPU with the instruction "PUT". This is only possible if the
"Allow remote partner access via PUT/GET communication" function was activated for the
partner CPU in the properties of the CPU in "Protection". You cannot use the "PUT" instruction
to access blocks that were created with "optimized" access type. The remote CPU can be in
RUN or STOP mode.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2415
The instruction is started on a positive edge at control input REQ. The pointers to the areas to
be written (ADDR_i) and the data (SD_i) are then sent to the partner CPU. Make sure that the
areas defined with the parameters ADDR_i and SD_i match in terms of number, length, and
data type.
A zero at any of the ADDR_i parameters will be ignored. The data to be sent is copied to
the configured send areas ((SD_i) at the next call of the instruction.
Make sure that the areas defined with the parameters ADDR_i and SD_i match in terms of
number, length, and data type.
If the area to be written (ADDR_i parameter) is smaller than the send area (SD_i
parameter), an error is output (ERROR = 1, STATUS = 4).
If the area to be written (ADDR_i parameter) is greater than the area for send area (SD_i
parameter), the instruction is executed without error.
The remote partner saves the required data under the addresses supplied with the data and
returns an execution acknowledgement. If no errors occur, this is indicated at the next
instruction call with status parameter DONE = "1". The writing process can only be activated
again after the last job is complete.
Errors and warnings are output via ERROR and STATUS if access problems occurred while
the data was being written or if the execution check results in an error.
Parameters
The following table shows the parameters of the "PUT" instruction:
Parameter Declaration Data type Memory area Description
REQ Input BOOL I, Q, M, D, L or
constant
Control parameter request, activates the data
exchange on a rising edge.
ID Input CONN_PRG
(WORD)
I, Q, M, D, L or
constant
Addressing parameters for specifying the
connection to the partner CPU.
DONE Output BOOL I, Q, M, D, L Status parameter DONE:
0: Job not yet started or still executing
1: Job executed without errors.
ERROR
Output
BOOL
I, Q, M, D, L Status parameters ERROR and STATUS,
error code:
ERROR=0
STATUS has the value:
0000H: Neither warning nor error
<> 0000H: Warning, STATUS supplies
detailed information.
ERROR=1
An error has occurred. STATUS supplies
detailed information on the type of error.
STATUS Output WORD I, Q, M, D, L
ADDR_1 InOut REMOTE I, Q, M, D Pointers to the areas on the partner CPU to
which the data will be written.
When the REMOTE pointer accesses a DB,
the DB must always be specified.
Example: P#DB10.DBX5.0 Byte 10.
ADDR_2 InOut REMOTE
ADDR_3 InOut REMOTE
ADDR_4 InOut REMOTE
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2416 System Manual, 01/2013,
Parameter Declaration Data type Memory area Description
SD_1 InOut VARIANT I, Q, M, D, L Pointers to the areas on the local CPU which
contain the data to be sent.
Only data types BOOL are permitted (for a bit
field the address must be "0" and the length an
integer multiple of byte), BYTE, CHAR,
WORD, INT, DWORD, DINT, REAL.
SD_2 InOut VARIANT
SD_3 InOut VARIANT
SD_4 InOut VARIANT
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
Parameters ERRORand STATUS
The following table contains all specific error information for the "PUT" instruction that can be
output via the ERROR and STATUS parameters.
ERROR STATUS
(decimal)
Explanation
0 11 Warning:
New job not active because the previous job is still busy.
The job is already being processed in a priority class with lower priority.
0 25 Communication has started. The job is being processed.
1 1 Communications problems, for example
Connection description not loaded (local or remote)
Connection interrupted (for example: cable, CPU off, CP in STOP mode)
Connection to partner not yet established
1 2 Negative acknowledgement from the partner device. The function cannot be executed.
1 4 Error in the pointers to the data storage:
Data types of the parameters SD_i and ADDR_i are not compatible with each other.
The length of the area SD_i is greater than the length of the data of the ADDR_i parameter
that is to be written.
Not possible to access SD_i.
Maximum user data size exceeded.
Number of the parameters SD_i and ADDR_i does not match.
1 8 Access error with the partner CPU (e.g. DB not loaded or write-protected).
1 10 Access to the local user memory not possible (for example, access to a deleted DB).
1 20 Not enough work memory. Maximum number of parallel jobs/instances exceeded.
1 27 There is no function code on the CPU for this instruction.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2417
Data consistency
When a send operation is activated (rising edge at REQ), the data to be sent from the send
area SD_i is copied from the user program. After the block call, you can write to these areas
without corrupting the current send data.
Note
The send operation is only complete when the DONE status parameter has the value "1".
9.8.5.2 Open User Communication
TSEND_C: Send data via Ethernet
TSEND_C: Send data via Ethernet
Description
The "TSEND_C" instruction is executed asynchronously and has the following functions:
Setting up and establishing a communications connection:
"TSEND_C" Sets up and establishes a TCP or ISO-on-TCP communications connection.
Once the connection has been set up and established, it is automatically maintained and
monitored by the CPU. The connection description specified at the CONNECT parameter
is used to set up the communications connection.
To establish a connection, the CONT parameter must be set to the value "1". If connection
establishment is successful, the DONE parameter is set to "1" for one cycle. An existing
connection is terminated and the connection which has been set up is removed when the
CPU goes into STOP mode. To set up and establish the connection again, you must
execute "TSEND_C" again. For information on the number of possible communication
connections, please refer to the technical specifications for your CPU.
Sending data via an existing communications connection:
You specify the send area with the DATA parameter. This includes the address and the
length of the data to be sent. Do not use a data area with the data type BOOL or Array of
BOOL at the DATA parameter. If you use purely symbolic values at the DATA parameter,
the LEN parameter must have the value "0".
The send job is executed when a rising edge is detected at the REQ parameter. With the
LEN parameter, you specify the maximum number of bytes sent with a send job. When
sending data (rising edge at the REQ parameter), the CONT parameter must have the
value "1" in order to establish or maintain a connection. The data to be sent must not be
edited until the send job is completed. If the send job executes successfully, the DONE
parameter is set to "1". Signal state "1" at the DONE parameter is not confirmation that the
data sent has already been read by the communications partner.
Terminating the communications connection:
The communications connection is terminated when the CONT parameter is set to "0".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2418 System Manual, 01/2013,
TSEND_C is executed again when the COM_RST parameter is set to "1". This terminates the
existing communications connection and a new connection is established. If data is being
transferred when it executes again, this can lead to a loss of data.
To enable "TSEND_C" again after the execution (DONE = 1), call the instruction once with
REQ = 0.
Parameter
The following table shows the parameters of the "TSEND_C" instruction:
Parameter Declaration Data type Memory area Description
REQ Input BOOL I, Q, M, D, L Starts the send job on a rising edge.
CONT Input BOOL I, Q, M, D, L Controls the communications connection:
0: Disconnect the communications connection
1: Establish and maintain the communications
connection
When sending data (rising edge at the REQ
parameter), the CONT parameter must have the
value TRUE in order to establish or maintain a
connection.
LEN Input UINT I, Q, M, D, L or
constant
Maximum number of bytes to be sent with the job.
If you use purely symbolic values at the DATA
parameter, the LEN parameter must have the value
"0".
CONNECT InOut TCON_Param D Pointer to the connection description
See also: Auto-Hotspot
DATA InOut VARIANT I, Q, M, D, L Pointer to the send area containing the address and
the length of the data to be sent.
COM_RST InOut BOOL I, Q, M, D, L Restarts the instruction:
0: Irrelevant
1: Complete restart of the instruction causing an
existing connection to be terminated and a new
connection to be established.
DONE Output BOOL I, Q, M, D, L Status parameter with the following values:
0: Job not yet started or still in progress
1: Job executed without errors
BUSY Output BOOL I, Q, M, D, L Status parameter with the following values:
0: Job not yet started or already completed
1: Job not yet completed. A new job cannot be
started.
ERROR Output BOOL I, Q, M, D, L Status parameter with the following values:
0: No error
1: Error occurred
STATUS Output WORD I, Q, M, D, L Status of the instruction
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2419
Parameters BUSY, DONE, and ERROR
You can check the status of the execution with the BUSY, DONE, ERROR, and STATUS
parameters. The BUSY parameter indicates the processing status. With the DONE parameter,
you can check whether or not a job executed successfully. The ERROR parameter is set when
errors occurred during execution of "TSEND_C". The error information is output at the STATUS
parameter.
The following table shows the relationship between the BUSY, DONE, and ERROR
parameters:
BUSY DONE ERROR Description
1 - - The job is being processed.
0 1 0 The job was completed successfully.
0 0 1 The job ended with an error. The cause of the error is specified in the STATUS parameter.
0 0 0 No new job was assigned.
Parameters ERROR and STATUS
ERROR STATUS*
(W#16#...)
Description
0 0000 Job executed without errors
0 7000 No job processing active
0 7001 Start execution of the job
Establish connection
Wait for connection partner
0 7002 Data are being sent
0 7003 Connection is terminated
0 7004 Connection established and monitored, no job processing active.
1 80A0 Group error for error codes 80A1 and 80A2.
1 80A1 Connection or port already being used by user.
Communication error:
The specified connection has not yet been established.
The specified connection is being terminated. Transfer via this connection is not possible.
The interface is being re-initialized.
1 80A2 Local or remote port is being used by the system.
1 80A3 Attempt being made to terminate a non-existent connection.
1 80A4 IP address of the remote endpoint of the connection is invalid, which means it corresponds to
the IP address of the local partner.
1 80A7 Communication error: You called the instruction with COM_RST = 1 before the send job was
complete.
1 80B2 The CONNECT parameter points to a data block that was generated with the attribute "Only
store in load memory".
1 80B3 Inconsistent parameter assignment: Group error for error codes 80A0 to 80A2, 80A4, 80B4 to
80B9.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2420 System Manual, 01/2013,
ERROR STATUS*
(W#16#...)
Description
1 80B4 You have violated one or both of the following conditions for passive connection establishment
(active_est = FALSE) when using the ISO-on-TCP protocol variant (connection_type =
B#16#12): "local_tsap_id_len >= B#16#02", and/or "local_tsap_id[1] = B#16#E0".
1 80B5 Only passive connection establishment is permitted for connection type 13 = UDP.
1 80B6 Parameter assignment error in the connection_type parameter of the data block for connection
description.
1 80B7 Error in one of the following parameters of the data block for connection description:
block_length, local_tsap_id_len, rem_subnet_id_len, rem_staddr_len, rem_tsap_id_len,
next_staddr_len.
1 8085 The LEN parameter is larger than the highest permitted value.
1 8086 The ID parameter within the CONNECT parameter is outside the permitted range.
1 8087 Maximum number of connections reached; no additional connection possible.
1 8088 The value at the LEN parameter does not correspond to the receive area set at the DATA
parameter.
1 8089 The CONNECT parameter does not point to a data block.
1 8091 Maximum nesting depth exceeded.
1 809A The CONNECT parameter points to a field that does not correspond to the length of the
connection description.
1 809B The ID of the local device in the connection description does not correspond to the CPU.
1 80C3 All connection resources are in use.
A block with this ID is already being processed in a different priority group.
1 80C4 Temporary communication error:
The connection cannot be established at this time.
The interface is receiving new parameters or the connection is being established.
The configured connection is being removed by a "TDISCON" instruction.
The connection used is being terminated by a call with COM_RST= 1.
1 8722 CONNECT parameter: The source area is invalid. The area does not exist in the DB.
1 873A CONNECT parameter: Access to the connection description is not possible (for example, DB
does not exist).
1 877F CONNECT parameter: Internal error.
1 8822 DATA parameter: Invalid source area, the area does not exist in the DB.
1 8824 DATA parameter: Area error in the VARIANT pointer.
1 8832 DATA parameter: The DB number is too high.
1 883A CONNECT parameter: Access to specified connection data not possible (e.g. because the DB
does not exist).
1 887F DATA parameter: Internal error, e.g. invalid VARIANT reference.
1 893A DATA parameter: Access to send area not possible (e.g. because the DB does not exist).
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2421
Note
Error messages of the instructions "TCON", "TSEND" and "TDISCON"
Internally, the TRV_C instruction uses the "TCON (Page 2427)", "TSEND (Page 2432)" and
"TDISCON (Page 2430)" instructions. The error messages of these instructions are contained
in the respective descriptions.
TRCV_C: Receive data via Ethernet
TRCV_C: Receive data via Ethernet
Description
The "TRCV_C" instruction is executed asynchronously and has the following functions:
Setting up and establishing a communications connection:
"TRCV_C" sets up and establishes a TCP or ISO-on-TCP communications connection.
Once the connection has been set up and established, it is automatically maintained and
monitored by the CPU.
The connection description specified at the CONNECT parameter is used to set up the
communications connection. To establish a connection, the CONT parameter must be set
to the value "1". If the connection establishment is successful, the DONE parameter is set
to "1".
An existing connection is terminated and the connection which has been set up is removed
when the CPU goes into STOP mode. To set up and establish the connection again, you
must execute "TRCV_C" again.
For information on the number of possible communications connections, refer to the
technical specifications for your CPU.
Receiving data via an existing communications connection:
If the EN_R parameter is set to the value "1", receipt of data is enabled. When receiving
data (rising edge at the EN_R parameter), the CONT parameter must have the value TRUE
in order to establish or maintain a connection.
The received data is entered in a receive area. You specify the length of the receive area
either with the LEN parameter (if LEN <> 0) or with the length information of the DATA
parameter (if LEN = 0) in accordance with the protocol variant used. If you use purely
symbolic values at the DATA parameter, the LEN parameter must have the value "0".
After data has been received successfully, the signal state at the DONE parameter is "1".
If errors occur in the data transfer, the DONE parameter is set to "0".
Terminating the communications connection:
The communications connection is terminated when the CONT parameter is set to "0".
TRCV_C is executed again when the COM_RST parameter is set. This terminates the existing
communications connection and a new connection is established. If data is being received
when it executes again, this can lead to a loss of data.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2422 System Manual, 01/2013,
Receive modes of TRCV_C
The following table shows how the received data is entered in the receive area.
Protocol variant Availability of data in the receive
area
connection_type parameter of
the connection description
LEN
parameter
RCVD_LEN
parameter
TCP
(Ad-hoc mode)
The data is immediately
available.
B#16#11 65535 1 to 1472
TCP (Data receipt
with specified
length)
The data is available as soon as
the data length specified at the
LEN parameter has been fully
received.
B#16#11 1 to 8192 Identical to the
value at the
LEN parameter
ISO on TCP
(protocol-
controlled data
transfer)
The data is available as soon as
the data length specified at the
LEN parameter has been fully
received.
B#16#12 1 to 8192 Identical to the
value at the
LEN parameter
TCP (ad-hoc mode)
The ad-hoc mode is only available with the TCP protocol variant. You set ad-hoc mode by
assigning the value "65535" to the LEN parameter. The length of the receive area is defined
by the pointer at the DATA parameter. The data length actually received is output at the
RCVD_LEN parameter. A maximum of 1472 bytes can be received.
TCP (data receipt with specified length)
You use the value of the LEN parameter to specify the length for the data receipt. The data
specified at the DATA parameter is available in the receive area as soon as the length specified
at the LEN parameter has been completely received.
ISO-on-TCP (protocol-controlled data transfer)
With the ISO-on-TCP protocol variant, data is transferred protocol-controlled. The receive area
is defined by the LEN and DATA parameters.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2423
Parameter
The following table shows the parameters of the "TRCV_C" instruction:
Parameter Declaration Data type Memory area Description
EN_R Input BOOL I, Q, M, D, L Receive enable
CONT Input BOOL I, Q, M, D, L Controls the communications connection:
0: Automatically disconnect communications
connection after data have been sent
1: Establish and maintain the communications
connection
When receiving data (rising edge at the EN_R
parameter), the CONT parameter must have the
value TRUE in order to establish or maintain a
connection.
LEN Input UINT I, Q, M, D, L or
constant
Maximum length of the data to be received. If you
use purely symbolic values at the DATA parameter,
the LEN parameter must have the value "0".
CONNECT InOut TCON_Param D Pointer to the connection description
See also: Auto-Hotspot
DATA InOut VARIANT I, Q, M, D, L Pointer to the receive area
COM_RST InOut BOOL I, Q, M, D, L Restarts the instruction:
0: Irrelevant
1: Complete restart of the instruction causing an
existing connection to be terminated
DONE Output BOOL I, Q, M, D, L Status parameter with the following values:
0: Job not yet started or is still executing
1: Job executed without errors
BUSY Output BOOL I, Q, M, D, L Status parameter with the following values:
0: Job not yet started or already completed
1: Job not yet completed. A new job cannot be
started
ERROR Output BOOL I, Q, M, D, L Status parameter ERROR:
0: No error
1: Error occurred
STATUS Output WORD I, Q, M, D, L Status of the instruction
RCVD_LEN Output UINT I, Q, M, D, L Amount of data actually received in bytes
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
Parameters BUSY, DONE, and ERROR
You can check the status of the execution with the BUSY, DONE, ERROR, and STATUS
parameters. The BUSY parameter indicates the processing status. With the DONE parameter,
you can check whether or not a job executed successfully. The ERROR parameter is set when
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2424 System Manual, 01/2013,
errors occurred during execution of "TRCV_C". The error information is output at the STATUS
parameter.
The following table shows the relationship between the BUSY, DONE, and ERROR
parameters:
BUSY DONE ERROR Description
1 - - The job is being processed.
0 1 0 The job was completed successfully.
0 0 1 The job ended with an error. The cause of the error is output at the STATUS parameter.
0 0 0 No new job was assigned.
Parameters ERROR and STATUS
ERROR STATUS*
(W#16#...)
Description
0 0000 Job executed without errors
0 7000 No job processing active
0 7001 Start execution of the job
Establish connection
Wait for connection partner
0 7002 Data is being received
0 7003 Connection is being terminated
0 7004 Connection established and monitored
No job processing active
1 8085 The LEN parameter is larger than the highest permitted value.
The value at the LEN or DATA parameter was changed after the first call.
1 8086 The ID parameter is outside the permitted range.
1 8087 Maximum number of connections reached; no additional connection possible
1 8088 The value at the LEN parameter does not correspond to the receive area set at the DATA parameter.
1 8089 The CONNECT parameter does not point to a data block.
1 8091 Maximum nesting depth exceeded.
1 809A The CONNECT parameter points to a field that does not correspond to the length of the connection
description.
1 809B The ID of the local device (local_device_id) in the connection description does not correspond to
the CPU.
1 80A0 Group error for error codes W#16#80A1 and W#16#80A2.
1 80A1 Connection or port already being used by user.
Communications error:
The specified connection has not yet been established.
The specified connection is being terminated.
Transfer via this connection is not possible.
The interface is being re-initialized.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2425
ERROR STATUS*
(W#16#...)
Description
1 80A2 Local or remote port is being used by the system.
1 80A3 Attempt being made to re-establish an existing connection.
Attempt being made to terminate a non-existent connection.
1 80A4 IP address of the remote endpoint of the connection is invalid, in other words, it matches the IP
address of the local partner.
1 80A7 Communications error: You called the instruction with COM_RST = 1 before the send job was
complete.
1 80B2 The CONNECT parameter points to a data block that was generated with the attribute "Only store
in load memory".
1 80B3 Inconsistent parameter assignment: Group error for error codes W#16#80A0 to W#16#80A2,
W#16#80A4, W#16#80B4 to W#16#80B9.
1 80B4 You have violated one or both of the following conditions for passive connection establishment
(active_est = FALSE) when using the ISO-on-TCP protocol variant (connection_type = B#16#12):
"local_tsap_id_len >= B#16#02", and/or "local_tsap_id[1] = B#16#E0".
1 80B5 Only passive connection establishment is permitted for connection type 13 = UDP.
1 80B6 Parameter assignment error in the connection_type parameter of the data block for connection
description.
1 80B7
Error in one of the following parameters of the data block for connection description: block_length,
local_tsap_id_len, rem_subnet_id_len, rem_staddr_len, rem_tsap_id_len, next_staddr_len.
1 80C3 All connection resources are in use.
A block with this ID is already being processed in a different priority group.
1 80C4
Temporary communications error:
The connection cannot be established at this time.
The interface is receiving new parameters or the connection is being established.
The configured connection is being removed by a "TDISCON" instruction.
The connection used is being terminated by a call with COM_RST= 1.
1 8722 Error in the CONNECT parameter: Invalid source area (area not declared in data block).
1 873A Error in the CONNECT parameter: Access to connection description is not possible (no access to
data block).
1 877F Error in the CONNECT parameter: Internal fault
1 8922 DATA parameter: Invalid target area; the area does not exist in the DB.
1 8924 DATA parameter: Area error in the VARIANT pointer.
1 8932 DATA parameter: The DB number is too high.
1 893A CONNECT parameter: Access to specified connection data not possible (e.g. because the DB
does not exist).
1 897F DATA parameter: Internal error, e.g. invalid VARIANT reference.
1 8A3A DATA parameter: No access to the data area, for example because the data block does not exist.
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2426 System Manual, 01/2013,
Note
Error messages of the instructions "TCON", "TRCV" and "TDISCON"
Internally, the TRV_C instruction uses the "TCON (Page 2427)", "TRCV (Page 2435)" and
"TDISCON (Page 2430)" instructions. The error messages of these instructions are contained
in the respective descriptions.
Other
TCON: Establishing a communication connection
TCON: Establishing a communication connection (V1.0)
Description
You use the "TCON" instruction to set up and establish a communication connection. Once
the connection has been set up and established, it is automatically maintained and monitored
by the CPU. "TCON" is executed asynchronously.
The connection data specified for the CONNECT and ID parameters are used to set up the
communication connection. To establish the connection, a rising edge must be detected at the
REQ parameter. If connection establishment is successful, the DONE parameter is set to "1".
Number of possible connections
For information on the number of possible communication connections, please refer to the
technical specifications for your CPU.
Connection with TCP and ISO-on-TCP
Both communication partners call the "TCON" instruction to set up and establish the
communication connection. During parameter assignment, you specify which partner is the
active communication end point and which is the passive one.
If the connection aborts, for example due to a line break or due to the remote communication
partner, the active partner attempts to reestablish the configured connection. You do not have
to call "TCON" again.
An existing connection is terminated and the connection set up is removed when the
"TDISCON (Page 2430)" instruction is executed or when the CPU changes to STOP mode.
To set up and establish the connection again, you will need to execute "TCON" again.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2427
Parameter
The following table shows the parameters of the "TCON" instruction:
Parameter Declaration Data type Memory area Description
REQ Input BOOL I, Q, M, D, L Starts the job to establish the connection
specified in the ID upon a rising edge.
ID Input CONN_OUC
(WORD)
L, D or constant Reference to the assigned connection.
Range of values: W#16#0001 to W#16#0FFF
CONNECT InOut TCON_Param D Pointer to the connection description
See also: Auto-Hotspot
DONE Output BOOL I, Q, M, D, L Status parameter with the following values:
0: Job not yet started or still in progress
1: Job executed without errors
BUSY Output BOOL I, Q, M, D, L Status parameter with the following values:
0: Job not yet started or already completed
1: Job not yet completed. A new job cannot
be started
ERROR Output BOOL I, Q, M, D, L Status parameter ERROR:
0: No error
1: Error occurred
STATUS Output WORD I, Q, M, D, L Status of the instruction
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
Parameters BUSY, DONE, and ERROR
You can check the status of the execution with the BUSY, DONE, ERROR, and STATUS
parameters. The BUSY parameter indicates the processing status. You use the DONE
parameter to check whether or not a job has been executed successfully. The ERROR
parameter is set when errors occurred during execution of "TCON". The error information is
output at the STATUS parameter.
The following table shows the relationship between the BUSY, DONE, and ERROR
parameters:
BUSY DONE ERROR Description
1 0 0 The job is being processed.
0 1 0 The job was completed successfully.
0 0 1 The job ended with an error. The cause of the error is output at the STATUS parameter.
0 0 0 No new job was assigned.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2428 System Manual, 01/2013,
Parameters ERROR and STATUS
ERROR STATUS*
(W#16#...)
Explanation
0 0000 Connection successfully established.
0 7000 No job processing active
0 7001 Start job execution, establish connection.
0 7002 Connection is being established (REQ irrelevant).
1 8086 The ID parameter is outside the valid range.
1 8087 Maximum number of connections reached; no additional connection possible
1 8089 The CONNECT parameter does not point to a data block.
1 809A The CONNECT parameter points to a field that does not correspond to the length of the
connection description.
1 809B The ID of the local device in the connection description does not correspond to the CPU.
1 80A0 Group error for error codes W#16#80A1 and W#16#80A2.
1 80A1 Connection or port already being used by user.
1 80A2 Local or remote port is being used by the system.
1 80A3 Attempt being made to re-establish an existing connection.
1 80A4 IP address of the remote endpoint of the connection is invalid, which means it corresponds to
the IP address of the local partner.
1 80A5 Connection ID is already in use.
1 80A7 Communication error: You executed "TDISCON (Page 2430)" before "TCON" had completed.
1 80B2 The CONNECT parameter points to a data block that was generated with the attribute "Only
store in load memory".
1 80B3 Inconsistent parameter assignment: Group error for error codes W#16#80A0 to W#16#80A2,
W#16#80A4, W#16#80B4 to W#16#80B9.
1 80B4 You have violated one or more of the following conditions for passive connection establishment
with the ISO-on-TCP protocol variant (connection_type = B#16#12):
local_tsap_id_len >= B#16#02
local_tsap_id[1] = B#16#E0
With local_tsap_id_len >= B#16#03, local_tsap_id[1] is an ASCII character.
local_tsap_id[1] is an ASCII character and local_tsap_id_len >= B#16#03.
1 80B5 Only passive connection establishment is permitted for connection type 13 = UDP.
1 80B6 Parameter assignment error in the connection_type parameter of the data block for connection
description
1 80B7 Error in one of the following parameters of the data block for connection description:
block_length, local_tsap_id_len, rem_subnet_id_len, rem_staddr_len, rem_tsap_id_len,
next_staddr_len.
1 80B8 Parameter in the local connection description differs from parameter ID.
1 80C3 All connection resources are in use.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2429
ERROR STATUS*
(W#16#...)
Explanation
1 80C4 Temporary communication error:
The connection cannot be established at this time.
The interface is currently receiving new parameters.
The configured connection is currently being removed by a "TDISCON (Page 2430)"
instruction.
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
TDISCON: Terminate communication connection
Description
The "TDISCON" instruction terminates a communications connection from the CPU to a
communication partner.
Functional description
"The TDISCON" instruction works asynchronously, which means its job processing extends
over multiple calls. You start the job for terminating a connection by calling the "TDISCON"
instruction with REQ = 1.
After "TDISCON" has been successfully executed, the ID specified for "TCON" is no longer
valid and cannot be used for sending or receiving.
The job status is indicated by the output parameters BUSY and STATUS. Here, STATUS
corresponds to the output parameter RET_VAL of the asynchronous instructions (see also:
Meaning of the parameters REQ, RET_VAL and BUSY with asynchronous instructions
(Page 1420)).
The following table shows the relationship between BUSY, DONE, and ERROR. Using this
table, you can recognize the current status of "TDISCON" or when the establishment of the
connection is completed.
BUSY DONE ERROR Description
TRUE FALSE FALSE The job is being processed.
FALSE TRUE FALSE Job successfully completed.
FALSE FALSE TRUE The job ended with an error. The cause of the error can be found in the STATUS
parameter.
FALSE FALSE FALSE The instruction was not assigned a (new) job.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2430 System Manual, 01/2013,
Parameter
The following table shows the parameters of the instruction "TDISCON":
Parameter Declaration Data type Memory area Description
S7-1200 S7-1500
REQ Input BOOL I, Q, M, D, L or
constant
I, Q, M, D, L, T, C
or constant
Control parameter REQUEST starts the
job for terminating the connection
specified by ID. The job starts on a rising
edge.
ID Input CONN_OU
C (WORD)
D, L or constant D, L or constant Reference to the connection to the remote
partner or between the user program and
the communication level of the operating
system that is to be terminated. ID must
be identical to the corresponding
parameter ID in the local connection
description.
Range of values: W#16#0001 to
W#16#0FFF
DONE Output BOOL I, Q, M, D, L I, Q, M, D, L Status parameter DONE:
0: Job not yet started or still executing.
1: Job executed without errors.
BUSY Output BOOL I, Q, M, D, L I, Q, M, D, L BUSY = 1: The job is not yet
completed.
BUSY = 0: The job is completed.
ERROR Output BOOL I, Q, M, D, L I, Q, M, D, L Status parameter ERROR:
ERROR=1: Error occurred during
processing. STATUS supplies
detailed information on the type of
error
STATUS Output WORD I, Q, M, D, L I, Q, M, D, L Status parameter STATUS: Error
information
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
Parameters ERROR and STATUS
ERROR STATUS*
(W#16#...)
Explanation
0 0000 Connection terminated successfully
0 7000 No job processing active
0 7001 Start of job processing, connection being terminated
0 7002 Intermediate call (REQ irrelevant), connection being terminated
1 8086 The ID parameter is not in the permitted range
1 80A3 Attempt being made to terminate a non-existent connection
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2431
ERROR STATUS*
(W#16#...)
Explanation
1 80C4 Temporary communication error: The interface is receiving new parameters or the connection is
currently being established.
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
TSEND: Send data via communication connection
Description
You use the "TSEND" instruction to send data over an existing communication connection.
"TSEND" is executed asynchronously.
You specify the send area with the DATA parameter. This includes the address and the
length of the data to be sent. All data types except BOOL and Array of BOOL can be used
for the data to be sent.
The send job is executed when a rising edge is detected at the REQ parameter.
With the LEN parameter, you specify the maximum number of bytes sent with a send job.
When data is transferred with TCP, the "TSEND" provides no information about the
length of the data sent to "TRCV (Page 2435)".
When data is transferred with ISO-on-TCP, the length of the data sent is communicated
to "TRCV (Page 2435)".
The data to be sent must not be edited until the send job is completed. If the send job
executes successfully, the DONE parameter is set to "1". Signal state "1" at the DONE
parameter is not confirmation that the data sent has already been read out by the
communications partner.
Parameter
The following table shows the parameters of the "TSEND" instruction:
Parameter Declaration Data type Memory area Description
S7-1200 S7-1500
REQ Input BOOL I, Q, M, D, L or
constant
I, Q, M, D, L, T,
C or constant
Starts the send job on a rising edge.
ID Input CONN_OU
C (WORD)
D, L or constant D, L or constant Reference to the connection established with
"TCON".
Range of values: W#16#0001 to W#16#0FFF
LEN Input UINT I, Q, M, D, L I, Q, M, D, L Maximum number of bytes to be sent with the
job. If you use purely symbolic values at the
DATA parameter, the LEN parameter must
have the value "0".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2432 System Manual, 01/2013,
Parameter Declaration Data type Memory area Description
S7-1200 S7-1500
DATA InOut VARIANT I, Q, M, D I, Q, M, D Pointer to the send area containing the
address and the length of the data to be sent.
The address references:
The process image input
The process image output
A bit memory
A data block
DONE Output BOOL I, Q, M, D, L I, Q, M, D, L Status parameter with the following values:
0: Job not yet started or still in progress
1: Job executed without errors
BUSY Output BOOL I, Q, M, D, L I, Q, M, D, L Status parameter with the following values:
0: Job not yet started or already completed
1: Job not yet completed. A new job
cannot be started.
ERROR Output BOOL I, Q, M, D, L I, Q, M, D, L Status parameter with the following values:
0: No error
1: Error occurred
STATUS Output WORD I, Q, M, D, L I, Q, M, D, L Status of the instruction
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
Parameters LEN and DATA
With LEN = 0 , all the data specified with the DATA parameter is sent.
If the number of bytes at the LEN parameter is larger than the length of the data to be sent
that was defined with the DATA parameter, the error code 8088 is output at the STATUS
parameter (see description of the STATUS parameter in the following).
If LEN > 0, with elementary data types, the length of LEN must correspond to the length of
the data to be sent in bytes. If the length of the data does not match for elementary data
types, the data will not be sent and the error code 8088 is output at the STATUS parameter.
If a structure (Struct) is referenced via the DATA parameter, LEN can be shorter than the
structure. In this case, only the data up to the length of the LEN parameter is transferred.
If an array is referenced via the DATA parameter, LEN can be shorter than the entire array.
The length of LEN must, however, be an integer multiple of the length of a single array
element. If not, the data will not be sent and the error code 8088 is output at the STATUS
parameter.
With data types STRING and WSTRING, all data are transferred if the parameter LEN =
0. When LEN > 0, the length must be at least the maximum number of bytes plus two
additional bytes which contain the length information. You will find more detailed information
on the structure of the data types in: "Overview of the valid data types (Page 899)".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2433
Parameters BUSY, DONE, and ERROR
You can check the status of the execution with the BUSY, DONE, ERROR, and STATUS
parameters. The BUSY parameter indicates the processing status. With the DONE parameter,
you can check whether or not a job executed successfully. The ERROR parameter is set when
errors occurred during execution of "TSEND". The error information is output at the STATUS
parameter.
The following table shows the relationship between the BUSY, DONE, and ERROR
parameters:
BUSY DONE ERROR Description
1 - - The job is being processed.
0 1 0 The job was completed successfully.
0 0 1 The job ended with an error. The cause of the error is specified in the STATUS parameter.
0 0 0 No new job was assigned.
Note
Because "TSEND" is executed asynchronously, you must keep the data in the send area
consistent until the DONE parameter or the ERROR parameter changes to the value "1".
Parameters ERROR and STATUS
ERROR STATUS*
(W#16#...)
Description
0 0000 Send job completed without error.
0 7000 No job processing active.
0 7001 Start of job execution, data is being sent.
When processing this job, the operating system accesses the data in the DATA send area.
0 7002 Job executing (REQ irrelevant).
When processing this job, the operating system accesses the data in the DATA send area.
1 8085 The LEN parameter is greater than the highest permitted value (65536).
DATA and LEN parameters both have the value "0".
With UDP only: The number of bytes to be sent is not in the permitted range (1..1472).
1 8086 The ID parameter is outside the permitted address range (1..0xFFF).
1 8088 The LEN parameter is greater than the area specified in DATA.
1 80A1 Communication error:
The specified connection has not yet been established.
The specified connection is being terminated. Transfer via this connection is not possible.
The interface is being re-initialized.
1 80C3 A block with this ID is already being processed in a different priority group.
Internal lack of resources.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2434 System Manual, 01/2013,
ERROR STATUS*
(W#16#...)
Description
1 80C4 Temporary communication error:
The connection cannot be established to the partner at this time.
The interface is receiving new parameter settings or the connection is being established.
1 80C5 Connection terminated by the communication partner.
1 80C6 Network error. Communication partner cannot be reached.
1 80C7 Execution timeout.
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
TRCV: Receive data via communication connection
Description
You use the "TRCV" instruction to receive data over an existing communication connection.
"TRCV" is executed asynchronously.
Receipt of data is enabled when the EN_R parameter is set to the value "1". The received data
is entered in a receive area. You specify the length of the receive area either with the LEN
parameter (if LEN <> 0) or with the length information of the DATA parameter (if LEN = 0),
depending on the protocol variant being used.
After successful receipt of data, the NDR parameter is set to the value "1". You can query the
amount of data actually received at the RCVD_LEN parameter.
Receive modes of "TRCV"
The following table shows how the received data is entered in the receive area.
Protocol variant Availability of data in the
receive area
connection_type
parameter of the
connection
description
LEN parameter RCVD_LEN
parameter
TCP
(Ad-hoc mode)
The data is immediately
available.
B#16#11 65535 1 to 1472
TCP
(Receipt of data with
specified length)
The data is available as soon
as the data length specified at
the LEN parameter has been
fully received.
B#16#11 1 to 8192 Identical to the
value at the LEN
parameter
ISO on TCP
(Protocol-controlled
data transfer)
The data is available as soon
as the data length specified at
the LEN parameter has been
fully received.
B#16#12 1 to 1452, if a CP is
used.
1 to 8192, if no CP
is used.
Identical to the
value at the LEN
parameter
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2435
TCP (Ad-hoc mode)
The ad-hoc mode is only available with the TCP protocol variant. You set ad-hoc mode by
assigning the value "65535" to the LEN parameter. The length of the receive area is defined
by the pointer at the DATA parameter. The data length actually received is output at the
RCVD_LEN parameter. A maximum of 1472 bytes can be received.
TCP (Receipt of data with specified length)
You use the value of the LEN parameter to specify the length for the data receipt. The data
specified at the DATA parameter is available in the receive area as soon as the length specified
at the LEN parameter has been completely received.
ISO on TCP (Protocol-controlled data transfer)
With the ISO-on-TCP protocol variant, data is transferred protocol-controlled.
The receive area is defined by the LEN and DATA parameters.
Parameter
The following table shows the parameters of the "TRCV" instruction:
Parameter Declaration Data type Memory area Description
S7-1200 S7-1500
EN_R Input BOOL I, Q, M, D, L or
constant
I, Q, M, D, L, T, C
or constant
Receive enable
ID Input CONN_OU
C (WORD)
D, L or constant D, L or constant Reference to the connection established
with "TCON".
Range of values: W#16#0001 to
W#16#0FFF
LEN Input UINT I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
Length of the receive area in bytes. If you
use purely symbolic values at the DATA
parameter, the LEN parameter must have
the value "0".
DATA InOut VARIANT I, Q, M, D I, Q, M, D Pointer to the receive area
NDR Output BOOL I, Q, M, D, L I, Q, M, D, L Status parameter with the following values:
0: Job not yet started or still in progress
1: Job executed without errors
BUSY Output BOOL I, Q, M, D, L I, Q, M, D, L Status parameter with the following values:
0: Job not yet started or already
completed
1: Job not yet completed. A new job
cannot be started
ERROR Output BOOL I, Q, M, D, L I, Q, M, D, L Status parameter ERROR:
0: No error
1: Error occurred
STATUS Output WORD I, Q, M, D, L I, Q, M, D, L Status of the instruction
RCVD_LEN Output UINT I, Q, M, D, L I, Q, M, D, L Amount of data actually received in bytes
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2436 System Manual, 01/2013,
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
Parameters LEN, DATA, and RCVD_LEN
If LEN = 0, the received data is saved in the receive area specified at the DATA parameter.
The number of bytes received is indicated at the RCVD_LEN parameter.
If the length specified at the LEN parameter is greater than the length of the data received
at the DATA parameter, the error code 8088 is output at the STATUS parameter (see
description of the STATUS) parameter in the following.
If LEN > 0, with elementary data types, the length of LEN must correspond to the length of
the data to be sent in bytes. If the length of the data does not match for elementary data
types, the data will not be received and the error code 8088 is output at the STATUS
parameter.
If a structure (Struct) is referenced via the DATA parameter, LEN can be shorter than the
structure. In this case, only the data up to the length of the LEN parameter is transferred.
If the DATA parameter references a data block with optimized access, the total length of
the data to be received must be specified as the length for the LEN parameter. Alternatively,
the LEN parameter is set to "0". If the length of the data does not match for elementary data
types, the data will not be received and the error code 8088 is output at the STATUS
parameter.
If an array is referenced via the DATA parameter, the length specified at the LEN parameter
can be shorter than the entire array. The length at the LEN parameter must, however, be
an integer multiple of the length of a single array element. If not, the data will not be sent
and the error code 8088 is output at the STATUS parameter.
If a data type STRING is referenced via the DATA parameter, the length specified at the
LEN parameter may not be >=1 and <=2.
If a data type WSTRING is referenced via the DATA parameter, the length specified at the
LEN parameter may not be >=1 and <=5.
Parameters BUSY, NDR, and ERROR
You can check the status of execution with the BUSY, NDR, ERROR, and STATUS
parameters. The BUSY parameter indicates the processing status. With the NDR parameter,
you can check whether or not a job executed successfully. The ERROR parameter is set when
errors occurred during execution of TRCV. The error information is output at the STATUS
parameter.
The following table shows the relationship between the BUSY, NDR, and ERROR parameters:
BUSY NDR ERROR Description
1 - - The job is being processed.
0 1 0 The job was completed successfully.
0 0 1 The job ended with an error. The cause of the error is output at the STATUS parameter.
0 0 0 No new job was assigned.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2437
Note
Because "TRCV" is executed asynchronously, the data in the receive area is only consistent
when the NDR parameter is set to the value "1".
Parameters ERROR and STATUS
ERROR STATUS*
(W#16#...)
Explanation
0 0000 Job executed successfully. The current length of the received data is output at the RCVD_LEN
parameter.
0 7000 Block not ready to receive.
0 7001 Block is ready to receive, receive job was activated.
0 7002 Interim call, the receive job is executing.
Note: While the job is being processed, data is written to the receive area. This means that an error
can lead to inconsistent data in the receive area.
1 8085 The LEN parameter is larger than the highest permitted value.
The value of the LEN or DATA parameter was changed after the first call.
Both LEN parameters and the DATA parameter have the value "0" or LEN is longer than the
maximum permitted value (65536).
1 8086 The ID parameter is outside the permitted address range (1 .. 0x0FFF).
1 8088 Receive area is too small.
The value at the LEN parameter is larger than the receive area set at the DATA parameter.
1 80A1 Communication error:
The specified connection has not yet been established.
The specified connection is being terminated. Receive job over this connection is not possible.
The connection is being re-initialized.
1 80B3 Inconsistent parameter assignment
1 80C3 A block with this ID is already being processed in a different priority group.
Internal lack of resources.
1 80C4 Temporary communication error:
The connection cannot be established to the partner at this time.
The interface is receiving new parameter settings or the connection is being established.
1 80C5 The remote partner has terminated the connection.
1 80C6 The remote partner cannot be reached (network error).
1 80C7 Execution timeout.
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2438 System Manual, 01/2013,
Structure of the address information for the remote partner with UDP
Overview
With "TUSEND (Page 2440)", you transfer the address information of the receiver at the
ADDR parameter. This address information must have the structure specified below.
With "TURCV (Page 2443)", you receive the address of the sender of the received data at
the ADDRparameter. This address information must have the structure specified below.
Data block for the address information of the remote partner
You must create a DB that contains one or more data structures as per PLC data type
"TADDR_PARAM".
In the ADDR parameter of "TUSEND (Page 2440)", you transfer a pointer of type VARIANT
to the address of the corresponding remote partner (e.g. P#DB100.DBX0.0 USINT 8). This
pointer is received in the ADDR parameter of "TURCV (Page 2443)".
Configuration of the address information for the remote partner for "TADDR_PARAM"
Byte Parameter Data type Start value Description
0 to 3 rem_ip_addr ARRAY [1..4] of USINT B#16#00 ... IP address of the remote partner, e.g. 192.168.002.003:
rem_ip_addr[1] = B#16#C0 (192)
rem_ip_addr[2] = B#16#A8 (168)
rem_ip_addr[3] = B#16#02 (002)
rem_ip_addr[4] = B#16#03 (003)
4 to 5 rem_port_nr UINT B#16#00 ... remote port no. (possible values see: Auto-Hotspot):
rem_port_nr[1] = high byte of the port no. in
hexadecimal notation
rem_port_nr[2] = low byte of port no. in hexadecimal
notation
6 to 7 reserved WORD B#16#00 ... Not used. Assign "0" to this parameter.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2439
TUSEND: Send data via Ethernet (UDP)
Description
The "TUSEND" instruction sends data to the remote partner addressed by the ADDR
parameter using UDP.
WARNING
Data transfer via UDP
Data transferred via UDP to RFC 768 to the remote partner are sent without
acknowledgement and are therefore unsecured. This means the data can be lost without any
indication at the block.
Note
For sequential send operations to different partners, you only need to adjust the ADDR
parameter when calling "TUSEND". You do not need to call the "TCON (Page 2427)" and
"TDISCON (Page 2430)" instructions again.
Functional description
"The TUSEND" instruction works asynchronously, which means its job processing extends
over multiple calls. You start the send operation by calling "TUSEND" with REQ = 1.
The job status is indicated by the output parameters BUSY and STATUS. Here, STATUS
corresponds to the output parameter RET_VAL of the asynchronous instructions.
See also: Meaning of the parameters REQ, RET_VAL and BUSY with asynchronous
instructions (Page 1420).
The following table shows the relationship between BUSY, DONE, and ERROR. Using this
table, you can determine the current status of "TUSEND" or when the send process is
concluded.
BUSY DONE ERROR Description
TRUE irrelevant irrelevant The job is being processed.
FALSE TRUE FALSE Job successfully completed.
FALSE FALSE TRUE The job ended with an error. The cause of the error can be found in the STATUS
parameter.
FALSE FALSE FALSE The instruction was not assigned a (new) job.
Note
Due to the asynchronous operation of "TUSEND", make sure the data in the send area
remains consistent until the DONE parameter or the ERROR parameter has the value TRUE.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2440 System Manual, 01/2013,
Parameter
The following table shows the parameters of the instruction "TUSEND":
Parameter Declaration Data type Memory area Description
S7-1200 S7-1500
REQ Input BOOL I, Q, M, D, L or
constant
I, Q, M, D, L, T, C
or constant
Control parameter REQUEST starts the
send job on a rising edge.
The data is transferred from the area
specified by DATA and LEN.
ID Input WORD M, D or constant M, D or constant Reference to the associated connection
between the user program and the
communication layer of the operating
system. ID must be identical to the
associated parameter ID in the local
connection description.
Range of values: W#16#0001 to
W#16#0FFF
LEN Input UINT I, Q, M, D, L I, Q, M, D, L Number of bytes to be sent with the job
Range of values: 1 to 1472
DONE Output BOOL I, Q, M, D, L I, Q, M, D, L Status parameter DONE:
0: Job not yet started or still executing.
1: Job executed without errors.
BUSY Output BOOL I, Q, M, D, L I, Q, M, D, L BUSY = 1: The job is not yet completed.
A new job cannot be triggered.
BUSY = 0: The job is completed.
ERROR Output BOOL I, Q, M, D, L I, Q, M, D, L Status parameter ERROR:
ERROR=1: An error has occurred
during processing, STATUS supplies
detailed information on the type of error.
STATUS Output WORD M, D M, D Status parameter STATUS: Error
information
DATA InOut VARIANT I, Q, M, D I, Q, M, D Send area, contains address and length
The address refers to:
The process image input
The process image output
A bit memory
A data block
ADDR InOut TADDR_P
aram
D D Pointers to the address of the recipient (e.g.
P#DB100.DBX0.0 USINT 8)
See also: Structure of the address
information for the remote partner with
UDP (Page 2439)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2441
Note
Create the data block for the ADDR parameter using the "Add new block" dialog, by selecting
the type "TADDR_Param".
For additional information on valid data types, refer to "Overview of the valid data types
(Page 899)".
Parameters ERROR and STATUS
ERROR STATUS*
(W#16#...)
Explanation
0 0000 Send job completed without error
0 7000 No job processing active
0 7001 Start of job processing, data being sent
Note: During this processing phase, the operating system accesses the data in the DATA send
area.
0 7002 Intermediate call (REQ irrelevant), job is being processed
Note: During this processing phase, the operating system accesses the data in the DATA send
area.
1 8085 The LEN parameter has the value "0" or is greater than the highest permitted value.
1 8086 The ID parameter is not in the permitted range
0 8088 The LEN parameter is greater than the memory area specified in DATA.
1 8089 The ADDR parameter does not point to a data block
1 80A1 Communication error:
The specified connection between user program and communication layer of the operating
system has not yet been established.
The specified connection between the user program and the communication layer of the
operating system is currently being terminated. Transmission over this connection is not
possible.
The interface is being reinitialized.
1 80A4 IP address (at the ADDR parameter) of the remote connection end point is invalid; it may
correspond to the local partner's own IP address.
1 80B3 The protocol variant (connection_type parameter in the connection description) is not set to
UDP. Please use "TSEND (Page 2432)".
ADDR parameter: Invalid information for port no.
1 80C3 A block with this ID is already being processed in a different priority class.
Internal lack of resources.
1 80C4 Temporary communication error:
The connection between the user program and the communication layer of the operating system
cannot be established at this time.
New parameter settings are being assigned to the interface.
1 80C5 The remote partner has terminated the connection.
1 80C6 The remote partner cannot be reached (network error).
1 80C7 Execution timeout.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2442 System Manual, 01/2013,
ERROR STATUS*
(W#16#...)
Explanation
1 8xyy General error information
See also: Evaluating errors with output parameter RET_VAL (Page 1422)
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
TURCV: Receive data via Ethernet (UDP)
Description
The "TURCV" instruction receives data via UDP. After successful completion of "TURCV", the
ADDR parameter will show you the address of the remote partner (the sender).
WARNING
Unsecured data transfer
Data transferred via UDP to RFC 768 to the remote partner are sent without
acknowledgement and are therefore unsecured. This means the data can be lost without any
indication at the block.
Functional description
"The TURCV" instruction works asynchronously, which means its job processing extends over
multiple calls. You start the receive job by calling "TURCV" with EN_R = 1.
The job status is indicated by the output parameters BUSY and STATUS. Here, STATUS
corresponds to the output parameter RET_VAL of the asynchronous instructions
See also: Meaning of the parameters REQ, RET_VAL and BUSY with asynchronous
instructions (Page 1420).
The following table shows the relationship between BUSY, NDR, and ERROR. Using this table,
you can determine the current status of TURCV or when the receive process is concluded.
BUSY NDR ERROR Description
TRUE irrelevant irrelevant The job is being processed.
FALSE TRUE FALSE Job successfully completed.
FALSE FALSE TRUE The job ended with an error. The cause of the error can be found in the STATUS
parameter.
FALSE FALSE FALSE The instruction was not assigned a (new) job.
Note
Due to the asynchronous operation of "TURCV", the data in the receive area is only consistent
when the NDR parameter has the value TRUE.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2443
Parameter
The following table shows the parameters of the instruction "TURCV":
Parameter Declaration Data type Memory area Description
S7-1200 S7-1500
EN_R Input BOOL I, Q, M, D, L or
constant
I, Q, M, D, L, T,
C or constant
Control parameter enabled to receive: When
EN_R = 1, "TURCV" is ready to receive. The
receive job is being processed.
ID Input WORD M, D or constant M, D or constant Reference to the associated connection
between the user program and the
communication layer of the operating system.
ID must be identical to the corresponding
parameter ID in the local connection description.
Value range: W#16#0001 to W#16#0FFF
LEN Input UINT I, Q, M, D, L I, Q, M, D, L Length of the receive area in bytes: 0
(recommended) or 1 to 1472
NDR Output BOOL I, Q, M, D, L I, Q, M, D, L Status parameter NDR:
NDR = 0: Job not yet started or still running
NDR = 1: Job successfully completed
ERROR Output BOOL I, Q, M, D, L I, Q, M, D, L Status parameter ERROR:
ERROR=1: Error occurred during
processing. STATUS supplies detailed
information on the type of error
BUSY Output BOOL I, Q, M, D, L I, Q, M, D, L BUSY = 1: The job is not yet completed. A
new job cannot be triggered.
BUSY = 0: The job is completed.
STATUS Output WORD M, D M, D Status parameter STATUS: Error information
RCVD_LEN Output UINT I, Q, M, D, L I, Q, M, D, L Amount of data actually received, in bytes
DATA InOut VARIANT I, Q, M, D I, Q, M, D Receive area
The address references:
The process image input
The process image output
A bit memory
A data block
ADDR InOut TADDR_
Param
D D Pointers to the address of the receiver (for
example, P#DB100.DBX0.0 byte 8), see also:
Structure of the address information for the
remote partner with UDP (Page 2439)
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2444 System Manual, 01/2013,
Parameters ERROR and STATUS
ERROR STATUS*
(W#16#...)
Explanation
0 0000 New data were accepted. The current length of the received data is shown in RCVD_LEN.
0 7000 Block not ready to receive
0 7001 Block is ready to receive, receive job was activated
0 7002 Intermediate call, receive job being processed
Note: During this processing phase, "TURCV" writes data to the receive area. For this reason, an
error could result in inconsistent data in the receive area.
1 8085 The LEN parameter is greater than the largest permitted value, or you changed the value of the
LEN or DATA parameter since the first call
1 8086 The ID parameter is not in the permitted range
1 8088 Receive area is too small.
Value in LEN is higher than the receive area specified by DATA
1 8089 The ADDR parameter does not point to a valid data block.
1 80A1 Communication error:
The specified connection between user program and communication layer of the operating
system has not yet been established.
The specified connection between the user program and the communication layer of the
operating system is currently being terminated. A receive job over this connection is not
possible.
New parameter settings are being assigned to the interface.
1 80A4 IP address (at the ADDR parameter) of the remote connection end point is invalid; it may
correspond to the local partner's own IP address.
1 80B3 The protocol variant (connection_type parameter in the connection description) is not set to UDP.
Please use "TRCV (Page 2435)".
1 80B7 With UDP only: The length at ADDR parameter does not correspond to 8 bytes.
1 80C3 A block with this ID is already being processed in a different priority class.
Internal lack of resources.
1 80C4 Temporary communication error: New parameter settings are being assigned to the interface.
1 80C5 The remote partner has terminated the connection.
1 80C6 The remote partner cannot be reached (network error).
1 80C7 Execution timeout.
1 80C9 With RFC1006 / UDP: The received data is longer than expected (size of receive buffer exceeded).
1 8xyy General error information
See also: Evaluating errors with output parameter RET_VAL (Page 1422)
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
See also
TCON: Establishing a communication connection (V1.0) (Page 2427)
TDISCON: Terminate communication connection (Page 2430)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2445
T_RESET: Resetting the connection
Description
The "T_RESET" instruction terminates and then reestablishes an existing connection.
The local end points of the connection are retained. They are generated automatically:
If a connection has been configured and loaded to the CPU.
If a connection has been generated by the user program, for example, by calling the
instruction "TCON (Page 2427)".
The "T_RESET" instruction can be executed for all connection types regardless of whether
the local interface of the CPU or the interface of a CM/CP was used for the connection. An
exception to this is connections for data transfer in ad-hoc mode with TCP, as such connections
cannot be referenced with a connection ID.
Once the instruction "T_RESET" has been called using the REQ parameter, the connection
specified with the ID parameter is terminated and, if necessary, the data send and receive
buffer cleared. Canceling the connection also cancels any data transfer in progress. There is
therefore a risk of losing data if data transfer is in progress. The CPU defined as the active
connection partner will then automatically attempt to restore the interrupted communication
connection. You therefore do not need to call the "TCON (Page 2427)" instruction to reestablish
the communication connection.
The output parameters DONE, BUSY and STATUS indicate the status of the job.
Parameter
The following table shows the parameters of the "T_RESET" instruction:
Parameter Declaration Data type Memory area Description
REQ Input BOOL I, Q, M, D, L, T, C or
constant
Control parameter REQUEST starts the job for
terminating the connection specified by ID.
The job starts on a rising edge.
ID Input CONN_OUC
(WORD)
L, D or constant Reference to the connection to the passive
partner which is to be terminated. ID must be
identical to the corresponding parameter ID in
the local connection description.
Range of values: W#16#0001 to W#16#0FFF
DONE Output BOOL I, Q, M, D, L Status parameter DONE
0: Job not yet started or still executing.
1: Job executed without errors.
BUSY Output BOOL I, Q, M, D, L Status parameter BUSY
0: Job is complete.
1: Job is not yet complete.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2446 System Manual, 01/2013,
Parameter Declaration Data type Memory area Description
ERROR Output BOOL I, Q, M, D, L Status parameter ERROR
0: No error occurred.
1: Error occurred during processing. The
STATUS parameter supplies detailed
information on the type of error
STATUS Output WORD I, Q, M, D, L Status parameter STATUS
Error information (see "STATUS parameter"
table).
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
STATUS parameter
STATUS*
(W#16#...)
Explanation
0000 No error.
0001 Connection has not been established.
7001 Connection termination launched.
7002 Connection being terminated.
8081 Unknown connection specified at the ID parameter.
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
T_CONFIG: Configure interface
Description T_CONFIG
Description
The "T_CONFIG" instruction is used for the program-controlled configuration of the integrated
PROFINET interfaces of the CPU or the interface of a CP/CM. The existing configuration data
is overwritten.
You can make the following interface configuration settings:
IP parameters: IP address, subnet mask, router address
PROFINET IO device name (if the CPU is operated as a PROFINET IO device)
You store the configuration data in a data block (CONF_DB parameter).
You can make the program-controlled setting of the IP configuration with the "T_CONFIG"
instruction as an alternative to configuration in the device configuration. It only takes effect,
however, if you explicitly specified in the hardware configuration that IP address parameters
are assigned differently.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2447
Functional description
The "T_CONFIG" instruction works asynchronously, which means its execution extends over
multiple calls. You start the transfer operation by calling "T_CONFIG" with REQ = 1. Only one
job can be active at any time.
The block is edge-triggered, which means the block must be activated again following BUSY=
FALSE using REQ=FALSE to enable the instance.
The job status is indicated by the output parameters BUSY and STATUS.
The following table shows the relationship between BUSY, DONE, and ERROR. Using this
table, you can determine the current status of the instruction and when the transfer of
configuration data is concluded.
BUSY DONE ERROR Description
TRUE irrelevant irrelevant The job is being processed.
FALSE TRUE FALSE Job successfully completed.
FALSE FALSE TRUE The job ended with an error. The cause of the error can be found in the
STATUS parameter.
FALSE FALSE FALSE The instruction was not assigned a (new) job.
Parameter
The following table shows the parameters of the "T_CONFIG" instruction:
Parameter Declaration Data type Memory area Description
S7-1200 S7-1500
REQ Input BOOL I, Q, M, D, L or
constant
I, Q, M, D, L, T,
C or constant
Calling the instruction with REQ = 1 starts
processing of the instruction.
INTERFAC
E
Input HW_INTERFA
CE
I, Q, M, D, L or
constant
I, Q, M, D, L or
constant
Hardware identification of the interface
(see "Properties" in the Inspector window
of the device configuration). The hardware
ID is stored in the system constants of the
PLC tags.
CONF_DA
TA
(Page
2450)
InOut VARIANT D D Pointer to a data block in which you store
the connection data. Use the pointer to
reference a higher-level Struct element
containing the Header, Addr and NOS
fields as subelements (refer to the
description of the CONF_DATA
parameter).
DONE Output BOOL I, Q, M, D, L I, Q, M, D, L The status parameter indicates if the job
was executed without errors:
0: Processing not yet complete.
1: Processing of instruction finished
successfully.
BUSY Output BOOL I, Q, M, D, L I, Q, M, D, L Status of the instruction:
0: Processing of the instruction has not
started, completed or canceled yet.
1: Processing of instruction in progress
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2448 System Manual, 01/2013,
Parameter Declaration Data type Memory area Description
S7-1200 S7-1500
ERROR Output BOOL I, Q, M, D, L I, Q, M, D, L Error display
0: No error
1: Error
STATUS Output DWORD I, Q, M, D, L I, Q, M, D, L Status display
For meaning in connection with the
parameters DONE and ERROR see under
displays of the instruction.
ERR_LOC Output DWORD I, Q, M, D, L I, Q, M, D, L Error location (fieldId and id of the subfield
in which an error has occurred at a
parameter)
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
Parameters ERROR and STATUS
ERROR STATUS
(DW#16#..)
ERR_LOC* Explanation
0 00000000 0 Job execution terminated without error
0 00700000 0 No job processing active
0 00700100 0 Start of job execution
0 00700200 0 Intermediate call (REQ
irrelevant)
1 C08xyy00 0 General error information
See also: Evaluating errors with output parameter RET_VAL (Page 1422)
1 C0808000 0 Hardware identification at parameter INTERFACE invalid.
1 C0808100 0 Hardware identification at parameter INTERFACE is not assigned to the supported
PROFINET interface.
1 C0808700 0 Incorrect length of the data block at the CONF_DATA parameter.
1 C0808800 f, 0 Field_type has an invalid value.
1 C0808900 f, 0 The parameter fieldid has an invalid value or was used several times.
1 C0808A00 f, 0 Incorrect number for subfield_cnt parameter or incorrect length at Length
parameter.
1 C0808B00 f, s The parameter Id of a subfield contains an invalid value.
1 C0808C00 f, s Error when placing subfield (incorrect subfield, incorrect sequence or multiple use
of subfield).
1 C0808D00 f, s The parameter Lenght of a subfield contains an incorrect or invalid value.
1 C0808E00 f, s The parameter Mode of a subfield contains an incorrect or invalid value.
1 C0809000 f, s The parameters of the subfield are write-protected. E.g. parameters are specified
via configuration or PNIO mode is enabled.
1 C0809100 f, s Reserved
1 C0809400 f, s The parameter value in the subfield is not defined or invalid.
1 C0809500 f, s The value of a subfield parameter is inconsistent with another parameter value.
1 C080C200 0 Transfer cannot be carried out (e.g. because the interface is not reachable).
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2449
ERROR STATUS
(DW#16#..)
ERR_LOC* Explanation
1 C080C300 0 Insufficient resources (for example, multiple calling of "T_CONFIG" with different
parameters)
1 C080C400 0 Temporary communication error
1 C080D200 0 Call not possible / not supported by the PROFINET interface
* In the table above, f is the field_id and s the id of the subfield in which the error occurred.
Parameter CONF_DATA
Structure of the DBs of the configuration data
The CONF_DATA parameter of the "T_CONFIG" instruction points to a global data block (DB),
in which you store the configuration data.
The DB consists of a IF_CONF_Header structure and the IF_CONF_V4 and / or
IF_CONF_NOS structures:
The structure IF_CONF_Header has to be at the start of the DB. Use the structure to
determine the number of subfields you want to use.
The structures IF_CONF_V4 and IF_CONF_NOS are the subfields used in the DB which
contain the actual configuration data. The respective parameters of the two subfields
correspond largely to the structure in the device properties.
All three structures must be defined below a higher-level structure (in the following example
the Struct Element "Conf_Data"). The following figure shows the data block structure.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2450 System Manual, 01/2013,
Interconnection of the data block in the CONF_DATA parameter
In the CONF_DATA parameter, call the higher-level Struct element of the data block (in the
example above the Struct element "Conf_Data"; the call in the parameter is achieved by
specifying the data block followed by the name of the Struct element:
"Name_of_DB".Conf_data).
Field IF_CONF_Header
Use the field IF_CONF_Header to select how many subfields you want to use during execution
of "T_CONFIG".
Byte Parameter Data type Start value Description
0 ... 1 FieldType UINT Field type: Must always be 0.
2 ... 3 FieldId UINT Error ID: Must always be 0.
4 ... 5 SubfieldCount UINT Total number of subfields in the structure
General parameters of the subfields
The subfields "Addr" and "Nos" contain the following general parameters:
Id
This parameter identifies the respective field and may not be altered.
Length
This parameter specifies the actual length of the subfield. If a field contains a parameter of
the data type String or Array, it may be that the maximum length of the parameter is not
exhausted. In this case the actual length of the subfield is less than the maximum length.
Mode
The following values are permitted for this parameter:
1: Permanent validity of the configuration data
2: Temporary validity of the configuration data including the deletion of existing
permanent configuration data
Subfield IF_CONF_V4
Use the subfield IF_CONF_V4 to specify the Ethernet addresses that you want to assign to
the interface of the CPU.
Byte Parameter Data type Start value Description
0 ... 1 Id UINT 30 Subfield identifier
2 ... 3 Length UINT 18 Length of the subfield in bytes
4 ... 5 Mode UINT Validity of addressing:
1: permanent
2: temporary
6 ... 9 InterfaceAddress IP_V4 * IP address
10 ... 12 SubnetMask IP_V4 * Subnet mask
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2451
Byte Parameter Data type Start value Description
14 ... 16 DefaultRouter IP_V4 * Router address
* The data type IP_V4 is a structure of 4 BYTE, which includes the respective address of the respective parameter (e.g. at
parameter SubnetMask the four-digit address of the subnet mask of the IP protocol).
Subfield IF_CONF_NOS
Use the subfield IF_CONF_NOS to specify the station name to be assigned during execution
of the instruction "T_CONFIG".
Byte Parameter Data type Start value Description
0 ... 1 Id UINT 40 Subfield identifier
2 ... 3 Length UINT 246 Length of the subfield in bytes
4 ... 5 Mode UINT Validity of the station name change:
1: permanent
2: temporary
6 ... 244 NoS ARRAY
[1...240] of
Byte
Station name: You must occupy the ARRAY from
the first byte. If the ARRAY is longer than the station
name to be assigned, you must enter a zero byte
after the actual station name (in conformity with IEC
61185-6-10). Otherwise, NoS is rejected and the
"T_CONFIG" instruction enters the error code
DW#16#C0809400 in STATUS. If you occupy the
first byte with zero, the station name is deleted.
The station name is subject to the following limitations:
The name must be specified in ASCII code.
Restricted to a total of 240 characters (lower case letters, numbers, dash, or dot)
No name component within the station name, which means a character string between two
dots may not exceed 63 characters.
No special characters such as umlauts, brackets, underscore, slash, blank space, etc. The
only special character permitted is the dash.
The station name must not begin or end with the "-" character.
The station name must not begin with a number.
The station name form n.n.n.n (n = 0, ... 999) is not permitted.
The station name must not begin with the string "port-xyz" or "port-xyz-abcde" (a, b, c, d,
e, x, y, z = 0, ... 9).
Note
You can also create an ARRAY NoS that is shorter than 240 bytes, but not less than 2
bytes. In this case, you must adjust the "Length" (length of subfield) tag accordingly.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2452 System Manual, 01/2013,
9.8.5.3 WEB server
WWW: Synchronizing user-defined web pages
Description
The instruction WWW initializes the Web server of the CPU or synchronizes user-defined web
pages with the user program in the CPU.
User-defined web pages together with the web server make it possible for the CPU to access
freely designed web pages of the CPU with a web browser.
Use script instructions (such as Javascript) and HTML code in user-defined web pages to
transfer data via a web browser for further processing to the CPU and to display data from the
operand area of the CPU in the web browser. Call the WWW instruction in the user program
for synchronization of the user program and the web server as well as initialization.
Initialization
User-defined web pages are "packaged" in data blocks for processing by the CPU. You will
have to generate data blocks from the source files (HTML files, screens, Javascript files, ...)
during configuration. The Web Control DB takes on a special role (default: DB 333). It contains
status and control information as well as links to additional data blocks with coded web pages.
The data blocks with coded web pages are called fragment DBs.
When the data block is downloaded into the CPU, the CPU does not "know" that user-defined
web pages are coded inside it. The instruction "WWW" in the startup OB, for example, will
inform the CPU which DB is the Web Control DB. The user-defined web pages can be accessed
via a web browser after this initialization.
Synchronization
If you want the user program to interact with the user-defined web pages, then the instruction
WWW must be used in the cyclical program part.
Examples of interaction between user program and web page:
Check received data
Compiling and returning data for web browser making request
In this case it must be possible to evaluate the current status information and the web server
must receive control information, such as release of a web page requested by a web browser.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2453
Parameter
The following table shows the parameters of the instruction "WWW":
Parameter Declaration Data type Description
CTRL_DB Input BLOCK_DB Data block that describes the user-defined web
pages (web control DB)
RET_VAL Output INT Error information
For additional information on valid data types, refer to Overview of the valid data types
(Page 899).
Parameter RET_VAL
Error code
(W#16#...)
Explanation
0000 No error occurred. There are no requests by web pages that have to be released by
the user program.
00xy x: indicates if an error has occurred during initialization of the web control DB
(CTRL_DB):
x=0: No errors occurred.
x=1: Error occurred. The error is coded in the byte "CTRL_DB.last_error" of the web
control DB, see description of web control DB.
y: Number of the pending request. Several requests are possible (e. g. requests "0"
and "1" are pending: y="3".
y="1": Request "0"
y="2": Request "1"
y="4": Request "2"
y="8": Request "3"
803A The specified web control DB does not exist on the CPU.
8081 Incorrect version or incorrect format of the web control DB
80C1 There are no resources to initialize the web application.
See also
Overview of the valid data types (Page 899)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2454 System Manual, 01/2013,
9.8.5.4 Communications processor
SIMATIC NET CPs/CMs
Telecontrol
Telecontrol instructions
TC_CON: Establish connection via the GSM network
Meaning
The TC_CON instruction allows an S71200 with a CP 12427 to establish a connection of the
following types:
ISOONTCP
Connection partner is a CP 12427.
ISOONTCP connections are used only in "GPRS direct" mode.
UDP
Any connection partner is possible.
SMS
The connection partner is an SMS client.
Telecontrol connection
The connection partner is either a telecontrol server or another station that can be reached
via the telecontrol server.
A TC_CON establishes exactly one connection. Depending on the mode of the CP 1242-7 and
the protocol you are using, a maximum of 3 to 5 simultaneous connections with unique IDs
(see below) are supported per CP. You will find the maximum number of simultaneous
connections in the performance data of the CP.
The CONNECT parameter uses a data block (DB) with the structure of a system data type
(SDT) for the connection description.
The required connection type is defined using a connection-specific SDT "TCON_..." (see
below). For each of the connection types listed above, one of the following SDTs must be
assigned:
TCON_IP_RFC for ISOONTCP connections
TCON_IP_V4 for UDP connections
TCON_PHONE for SMS connections
TCON_WDC for telecontrol connections
The "ActiveEstablished" parameter of these SDTs also specifies whether or not connection
establishment is active or passive.
For parameter settings for these SDTs, see TCON_...: SDTs for the telecontrol connection
establishment (Page 2470).
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2455
The ID parameter references the GPRS connection. The ID is assigned and must be unique
within the CPU.
The INTERFACE parameter references the GPRS interface of the required local CP. This must
be taken from STEP 7.
Call interface in FBD representation
TC_CON
CONN_OUC
BOOL
TCON_Param
HW_lNTERFACE
DONE lD
CONNECT
lNTERFACE
REQ
STATUS
ERROR
BUSY
BOOL
WORD
BOOL
BOOL
Explanation of the formal parameters
The following table explains all the formal parameters for the TC_CON instruction.
Parameter Declaration Data type Range of values Description
REQ INPUT BOOL 0, 1 The instruction is started and the status
codes initialized on a rising edge.
Updating of the DONE, ERROR and
STATUS status codes when there is a
positive edge.
ID INPUT CONN_OUC
(WORD)
1...07FF
h
Reference to the relevant connection.
The ID is assigned.
The value of ID is also required by the
system data type (SDT) of the CONNECT
parameter.
INTERFACE INPUT HW_INTERFA
CE
Reference to the interface of the local
CP 12427 (see STEP 7 > CP
configuration > Telecontrol interface >
"Hardware identifier")
CONNECT INOUT TCON_Param See also "TCON_...: SDTs for
telecontrol connection
establishment"
Reference to a data block for connection
establishment.
The SDTs of the type TCON_IP_RFC,
TCON_IP_V4, TCON_PHONE or
TCON_WDC specify the structure of the
data block suitable for the relevant
connection.
In the SDTs, note the parameter
"ActiveEstablished" (active / passive
connection establishment).
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2456 System Manual, 01/2013,
Parameter Declaration Data type Range of values Description
ENO OUTPUT BOOL 0: Error
1: Error-free
Enable output
If there is a runtime error with the
instruction, ENO = 0 is set.
BUSY OUTPUT BOOL 0: Execution of the instruction
not started, completed or
aborted
1: The instruction is executing
Display of the processing status of the
instruction
DONE OUTPUT BOOL 0: -
1: The instruction executed
successfully
This parameter indicates whether or not
the job was completed without errors.
For the meaning in conjunction with the
parameters ERROR and STATUS, refer
to Codes of the instruction.
ERROR OUTPUT BOOL 0: -
1: Error
Error code
For the meaning in conjunction with the
parameters DONE and STATUS, refer to
Codes of the instruction.
STATUS OUTPUT WORD Status code
For the meaning in conjunction with the
parameters DONE and ERROR, refer to
Codes of the instruction.
The codes BUSY, DONE and ERROR
The codes of DONE and ERROR are relevant only when BUSY = 0.
BUSY DONE ERROR Meaning
0 0 0 No job being executed
You will find all other code combinations of DONE and ERROR in the following table.
When called, the instruction remains in the BUSY = 1 state for several seconds. In the following
situations, the BUSY state = 1 can last for a longer time:
On active ISO-on-TCP connections if the partner cannot be reached.
On passive connections when no frame is received.
The codes DONE, ERROR and STATUS
The following table shows the condition codes formed based on DONE, ERROR and STATUS
that must be evaluated by the user program.
DONE ERROR STATUS Meaning
1 0 0000
H
Job executed without errors
0 0 7000
H
No job processing active (first instruction call)
0 0 7001
H
Job processing started (first instruction call)
0 0 7002
H
Job processing already active (renewed instruction call when BUSY = 1)
0 1 8086
H
Illegal value for ID
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2457
DONE ERROR STATUS Meaning
0 1 8087
H
Maximum number of connections reached, no further connection possible
0 1 80E3
H
The ID is already being used by another connection.
0 1 80E6
H
No query in progress (instruction call not started)
0 1 80E8
H
Remote partner cannot be reached. Check the connection parameters.
In the "GPRS direct" mode, the message is output if the partner can be reached but is
not accepting a connection request.
0 1 80EB
H
Request temporarily denied (TC_CON has already been called with the same destination
address.)
0 1 80EC
H
Opening the Listener Port failed:
Check the connection parameters.
0 1 80F2
H
The CP is in the wrong mode:
Telecontrol connections are permitted only in "Telecontrol" mode.
ISOONTCP connections are permitted only in "GPRS direct" mode.
0 1 80F3
H
No free connection endpoint for sending data:
Use less connections or
Use less passive connections or
Turn off NTP.
Remember the maximum number of simultaneous connections of the CP 1242-7.
0 1 80F4
H
Connection endpoint cannot be generated:
Repeat the call. If necessary, check the connection parameters.
0 1 80F6
H
Format error of a parameter in the called data block (wrong length, wrong format or invalid
value)
Check the configuration of the "TC_CON..." SDT.
TC_DISCON: Terminate connection via the GSM network
Meaning
The TC_DISCON instruction on an S71200 with CP 12427 terminates an ISOONTCP, UDP,
SMS or telecontrol connection that was established with the TC_CON instruction.
You will find detailed information on the connection types in the description of the TC_CON
instruction.
TC_DISCON terminates the connection to the telecontrol server only logically. If you want the
connection to the telecontrol server to be terminated physically, configure the connection as
a "Temporary connection" in the "telecontrol server" parameter group in STEP 7.
At the TCP/IP level, the connection is retained. Temporary stations terminate the connection
automatically after sending the data.
The ID parameter references the GPRS connection. The ID must be unique within the CPU
and the same as the ID used with TC_CON.
The INTERFACE parameter references the GPRS interface of the required local CP. The value
must be the same as that used by TC_CON for INTERFACE.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2458 System Manual, 01/2013,
Call interface in FBD representation
TC_DlSCON
CONN_OUC
BOOL
HW_lNTERFACE
DONE lD
lNTERFACE
REQ
STATUS
ERROR
BUSY
BOOL
WORD
BOOL
BOOL
Explanation of the formal parameters
The following table explains all the formal parameters for the TC_DISCON instruction
Parameter Declaration Data type Range of values Description
REQ INPUT BOOL 0, 1 The instruction is started and the status
codes initialized on a rising edge.
Updating of the DONE, ERROR and
STATUS status codes when there is a
positive edge.
ID INPUT CONN_OUC
(WORD)
1...07FF
h
Reference to the relevant connection
INTERFACE INPUT HW_INTERFA
CE
Reference to the interface of the local
CP 12427 (see STEP 7 > CP
configuration > Telecontrol interface >
"Hardware identifier")
ENO OUTPUT BOOL 0: Error
1: Error-free
Enable output
If there is a runtime error with the
instruction, ENO = 0 is set.
BUSY OUTPUT BOOL 0: Execution of the instruction
not started, completed or
aborted
1: The instruction is executing
Display of the processing status of the
instruction
DONE OUTPUT BOOL 0: -
1: The instruction executed
successfully
This parameter indicates whether or not
the job was completed without errors.
For the meaning in conjunction with the
parameters ERROR and STATUS, refer
to Codes of the instruction.
ERROR OUTPUT BOOL 0: -
1: Error
Error code
For the meaning in conjunction with the
parameters DONE and STATUS, refer to
Codes of the instruction.
STATUS OUTPUT WORD Status code
For the meaning in conjunction with the
parameters DONE and ERROR, refer to
Codes of the instruction.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2459
The codes BUSY, DONE and ERROR
The codes of DONE and ERROR are relevant only when BUSY = 0.
BUSY DONE ERROR Meaning
0 0 0 The instruction has not yet been called.
You will find all other code combinations of DONE and ERROR in the following table.
Note
When called, the instruction remains in the BUSY = 1 state for several seconds.
The codes DONE, ERROR and STATUS
The following table shows the condition codes formed based on DONE, ERROR and STATUS
that must be evaluated by the user program.
DONE ERROR STATUS Meaning
1 0 0000
H
Job executed without errors
0 0 7000
H
No job processing active (first instruction call)
0 0 7001
H
Job processing started (first instruction call)
0 0 7002
H
Job processing already active (renewed instruction call when BUSY = 1)
0 1 8086
H
Illegal value for ID
0 1 80E4
H
Unknown ID: No connection with this ID has been established by TC_CON.
0 1 80E6
H
No query in progress (instruction call not started)
0 1 80F5
H
Invalid connection endpoint:
Connection establishment by TC_CON failed or
Connection terminated by remote partner.
0 1 80F6
H
Format error of a parameter in the called data block (wrong length, wrong format or invalid
value)
Check the configuration of the "TC_CON..." SDT.
TC_SEND: Send data via the GSM network
Meaning
The TC_SEND instruction allows the sending of data via programmed connections of the
following types:
ISOONTCP connections
UDP connections
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2460 System Manual, 01/2013,
SMS connections
The sending of SMS messages is supported only if this was set up in the STEP 7
configuration of the CP.
Telecontrol connections
Note
Sending SMS messages to multiple recipients
If you want to send an identical SMS message to several recipients, you need to establish
a connection to each recipient.
You will find more detailed information on the connection types in the description of the
TC_CON instruction.
The ID parameter references the GPRS connection. The value of ID must correspond to the
value used for ID by TC_CON.
The INTERFACE parameter references the GPRS interface of the required local CP. The value
must be the same as that used by TC_CON for INTERFACE.
The amount of data to be sent is specified with the LEN parameter.
The size of the data area specified in DATA must be at least as large as the number of bytes
configured for LEN. Permitted data types in the data area specified in DATA are all except
BOOL and ARRAY of BOOL.
The destination address (connection partner) for the data to be sent is configured in the
TC_CON instruction.
Call interface in FBD representation
TC_SEND
CONN_OUC
BOOL
UlNT
HW_lNTERFACE
DONE lD
LEN
lNTERFACE
REQ
DATA
STATUS
ERROR
BUSY
BOOL
WORD
BOOL
BOOL
VARlANT
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2461
Explanation of the formal parameters
The following table explains all the formal parameters for the TC_SEND instruction.
Parameter Declaration Data type Range of values Description
REQ INPUT BOOL 0, 1 The instruction is started and the status
codes initialized on a rising edge.
Updating of the DONE, ERROR and
STATUS status codes when there is a
positive edge.
ID INPUT CONN_OUC
(WORD)
1...07FF
h
Reference to the relevant connection
INTERFACE INPUT HW_INTERFA
CE
Reference to the interface of the local
CP 12427 (see STEP 7 > CP
configuration > Telecontrol interface >
"Hardware identifier")
LEN INPUT UINT 1...2048 Number of bytes of data to be sent,
maximum 2048. The value should match
the size of the range of DATA.
DATA INOUT VARIANT Address reference to the send data area
of the CPU *
ENO OUTPUT BOOL 0: Error
1: Error-free
Enable output
If there is a runtime error with the
instruction, ENO = 0 is set.
BUSY OUTPUT BOOL 0: Execution of the instruction
not started, completed or
aborted
1: The instruction is executing
Display of the processing status of the
instruction
DONE OUTPUT BOOL 0: -
1: The instruction executed
successfully
This parameter indicates whether or not
the job was completed without errors. **
For the meaning in conjunction with the
parameters ERROR and STATUS, refer
to Codes of the instruction.
ERROR OUTPUT BOOL 0: -
1: Error
Error code
For the meaning in conjunction with the
parameters DONE and STATUS, refer to
Codes of the instruction.
STATUS OUTPUT WORD Status code
For the meaning in conjunction with the
parameters DONE and ERROR, refer to
Codes of the instruction.
* For special features of the DATA parameter for SMS texts, refer to the next section.
** After sending a frame, TC_SEND sets DONE = 1. Note the following response:
The loss of an ISO-on-TCP connection is only recognized by the sender after 1 to 2 minutes. The transferred data may be lost
although TC_SEND has set DONE = 1 at the sender.
If an ISO-on-TCP connection is aborted after receiving a frame before TC_RECV was started, the transferred data may be
lost even if TC_SEND sets DONE = 1 at the sender.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2462 System Manual, 01/2013,
Configuring SMS texts with the DATA parameter
The instruction sends the data referenced by the pointer of the type VARIANT of the DATA
parameter as an SMS text.
If an operand of the data type STRING is referenced by DATA for SMS texts, the first two bytes
are transferred with length information of the string.
One option for the correct text representation of SMS messages to be sent is to convert the
text string into an Array of BYTE or Array of CHAR using the conversion function
Strg_TO_Chars. Strg_TO_Chars at the EN parameter is linked to the output parameter ENO
by TC_SEND.
For SMS texts, the CP does not support all special characters, for example umlauts (, etc.).
The specification GSM 03.38 applies. There may be additional restrictions imposed by the
GSM network provider.
The codes BUSY, DONE and ERROR
The codes of DONE and ERROR are relevant only when BUSY = 0.
BUSY DONE ERROR Meaning
0 0 0 No job being executed
You will find all other code combinations of DONE and ERROR in the following table.
The codes DONE, ERROR and STATUS
The following table shows the condition codes formed based on DONE, ERROR and STATUS
that must be evaluated by the user program.
DONE ERROR STATUS * Meaning
1 0 0000
H
Job executed without errors
0 0 7000
H
No job processing active (first instruction call)
0 0 7001
H
Job processing started (first instruction call)
0 0 7002
H
Job processing already active (renewed instruction call when BUSY = 1)
0 1 8086
H
Illegal value for ID
0 1 80E0
H
The length information under LEN is greater than the range of data to be transferred
under DATA.
or
Internal error
If you send the frames directly to the telecontrol server (mode "Telecontrol"), make
sure that the send cycle time is 1 second.
0 1 80E1
H
Timeout:
Increase the value of the "Connection monitoring time" in the configuration of the CP
1242-7 or
Check the connection partner.
0 1 80E4
H
Unknown ID:
First call TC_CON.
0 1 80E6
H
No query in progress (instruction call not started)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2463
DONE ERROR STATUS * Meaning
0 1 80E7
H
Data to be sent not completely transferred:
Repeat the job.
0 1 80E8
H
Remote partner cannot be reached. Check the connection parameters.
In the "GPRS direct" mode, the message is output if the partner can be reached but is
not accepting a connection request.
0 1 80E9
H
Connection establishment by remote partner:
Check the connection partner. If necessary, terminate the connection with TC_DISCON
and establish it again with TC_CON.
0 1 80EA
H
Error message from remote partner:
Check the connection partner. Enable the "TC_RECV" instruction on the
communications partner.
If necessary, terminate the connection with TC_DISCON and establish it again with
TC_CON.
0 1 80EF
H
SMS could not be sent:
Check whether the destination address (telephone number of the destination
subscriber) exists.
Check whether the inserted SIM card allows sending of SMS.
Make sure that when the data block TCON_PHONE was created, the "Standard"
option was selected for block access.
0 1 80F1
H
Sending of SMS messages is not enabled in the STEP 7 configuration of the CP:
Enalble the "Allow SMS" option in the configuration of the CP.
0 1 80F4
H
Connection endpoint cannot be generated:
Check the connection partner.
0 1 80F5
H
Invalid connection endpoint:
Connection establishment by TC_CON failed.
or
Connection terminated by remote partner: First call TC_DISCON.
0 1 80F6
H
Format error of a parameter in the called data block (wrong length, wrong format or invalid
value):
Check the configuration of the "TC_CON..." SDT.
* Further statuses that are not listed here can be found in the status display is of the "RDREC" or "WRREC" instructions in the
two middle status bytes (STATUS[2], STATUS[3]).
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2464 System Manual, 01/2013,
TC_RECV: Receive data via the GSM network
Meaning
The TC_RECV instruction allows the reception of data via programmed connections of the
following types:
ISOONTCP connections
SMS connections
To receive SMS messages, the phone number of the sender must be configured in the
STEP 7 configuration of the receiving CP (authorized phone numbers). The sender must
support the CLIP function.
The phone number of the connection partner must be entered in the "TCON_PHONE" SDT.
Wake-up SMS messages are filtered out.
Telecontrol connections
Note
Receiving SMS messages from different senders
If you want to receive SMS messages from different senders, you have two alternatives:
You configure several connections (TC_CON, TC_RECV, TC_DISCON).
or
You may only enter no telephone number for only one configured connection in the
required data block "TCON_PHONE" in the "PhoneNumber" parameter. When
receiving messages, this is then interpreted as a placeholder for all authorized
connection partners.
You will find more detailed information on the connection types in the description of the
TC_CON instruction.
The ID parameter references the GPRS connection. The value of ID must correspond to the
value used for ID by TC_CON.
The INTERFACE parameter references the GPRS interface of the required local CP. The value
must be the same as that used by TC_CON for INTERFACE.
The maximum amount of data to be received is specified with the LEN parameter.
The size of the data area specified in DATA must be at least as large as the number of bytes
configured for LEN. Permitted data types in the data area specified in DATA are all except
BOOL and ARRAY of BOOL. The received data is interpreted as if the sending partner had
used the same data types.
The DB (system data type) used for the connection description of TC_RECV must differ from
a DB used for TC_SEND.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2465
Call interface in FBD representation
TC_RECV
CONN_OUC
BOOL
UlNT
HW_lNTERFACE
BUSY lD
LEN
lNTERFACE
EN_R
DATA
ERROR
NDR
RCVD_LEN
BOOL
BOOL
BOOL
UlNT
VARlANT WORD STATUS
Explanation of the formal parameters
The following table explains all the formal parameters for the TC_RECV instruction
Parameter Declaration Data type Range of values Description
EN_R INPUT BOOL 0: Data reception locked
1: Data reception enabled
Enables / locks the reception of data.
After setting 1 to 0, the program block
receives data again.
ID INPUT CONN_OUC
(WORD)
1...07FF
h
Reference to the relevant connection
INTERFACE INPUT HW_INTERFA
CE
Reference to the interface of the local
CP 12427 (see STEP 7 > CP
configuration > Telecontrol interface >
"Hardware identifier")
LEN INPUT UINT 1...2048 (minimum) number of bytes of data to be
received, maximum 2048
DATA INOUT VARIANT Address reference to the receive data
area of the CPU *
ENO OUTPUT BOOL 0: Error
1: Error-free
Enable output
If there is a runtime error with the
instruction, ENO = 0 is set.
RCVD_LEN OUTPUT UINT Number of bytes of received data
BUSY OUTPUT BOOL 0: Execution of the instruction
not started, completed or
aborted
1: The instruction is executing
Display of the processing status of the
instruction
DONE OUTPUT BOOL 0: -
1: The instruction executed
successfully
This parameter indicates whether or not
the job was completed without errors.
For the meaning in conjunction with the
parameters ERROR and STATUS, refer
to Codes of the instruction.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2466 System Manual, 01/2013,
Parameter Declaration Data type Range of values Description
ERROR OUTPUT BOOL 0: -
1: Error
Error code
For the meaning in conjunction with the
parameters DONE and STATUS, refer to
Codes of the instruction.
STATUS OUTPUT WORD Status code
For the meaning in conjunction with the
parameters DONE and ERROR, refer to
Codes of the instruction.
* For special features of the DATA parameter for SMS texts, refer to the next section.
Configuring SMS texts with the DATA parameter
The instruction references the received SMS text with the pointer of the type VARIANT of the
DATA parameter to the data area of the CPU.
If DATA references an operand of the data type STRING for the SMS text, the first two bytes
of the SMS text will be interpreted as length information of the data type STRING and not as
SMS text.
One option for the correct text representation of SMS messages to be received is to convert
an Array of BYTE or Array of CHAR to a text string using the conversion function
Chars_TO_Strg. Chars_TO_Strg at the EN parameter is linked to the output parameter ENO
of TC_RECV.
For SMS texts, the CP does not support all special characters, for example umlauts (, etc.).
The specification GSM 03.38 applies. There may be additional restrictions imposed by the
GSM network provider.
The codes BUSY, DONE and ERROR
The codes of DONE and ERROR are relevant only when BUSY = 0.
BUSY DONE ERROR Meaning
0 0 0 No job being executed
You will find all other code combinations of DONE and ERROR in the following table.
The codes DONE, ERROR and STATUS
The following table shows the condition codes formed based on DONE, ERROR and STATUS
that must be evaluated by the user program.
DONE ERROR STATUS * Meaning
1 0 0000
H
Job executed without errors
0 0 7000
H
No job processing active (first instruction call)
0 0 7001
H
Job processing started (first instruction call)
0 0 7002
H
Job processing already active (renewed instruction call when BUSY = 1)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2467
DONE ERROR STATUS * Meaning
0 1 80A3
H
An attempt is made to re-establish an existing connection.
An attempt is made to terminate a non-existent connection.
0 1 80E0
H
The size of the data received for the range specified by DATA is greater than the
length information in LEN.
or
Internal error
0 1 8086
H
Illegal value for ID
0 1 80E4
H
Unknown ID:
First call TC_CON.
0 1 80E6
H
No query in progress (instruction call not started)
0 1 80F5
H
Invalid connection endpoint:
Connection establishment by TC_CON failed.
or
Connection terminated by remote partner: First call TC_DISCON.
0 1 80F6
H
Format error of a parameter in the called data block (wrong length, wrong format or invalid
value)
Check the configuration of the "TC_CON..." SDT.
* Further statuses that are not listed here can be found in the status display is of the "RDREC" or "WRREC" instructions in the
two middle status bytes (STATUS[2], STATUS[3]).
TC_CONFIG: Transferring configuration data to a CP
Meaning
With the TC_CONFIG instruction, parameters of a the CP 12427 configured in STEP 7 can
be modified. The configured values are not overwritten retentively. The overwritten values
remain valid until TC_CONFIG is called again or until the station starts up again (cold restart
after cycling power).
If the STEP 7 configuration data of the CP needs to be changed permanently, the instruction
needs to be called again each time the station restarts (cold restart) or a modified project must
be downloaded to the station.
The CONFIG parameter points to the memory area with the configuration data. The
configuration data is stored in a data block (DB). The structure of the DB is specified by the
system data type (SDT) IF_CONF.
The configuration data to be modified on the CP is put together as necessary in blocks in
IF_CONF "IF_CONF_..." for the individual parameters.
Parameters that are not intended to change as a result of the instruction are not entered in
IF_CONF. They retain the value configured in STEP 7.
For detail information on assigning value to IF_CONF, refer to the section IF_CONF: SDT for
telecontrol configuration data (Page 2475).
The INTERFACE parameter references the GPRS interface of the required local CP.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2468 System Manual, 01/2013,
Call interface in FBD representation
TC_CONFlG
HW_lNTERFACE
BOOL
VARlANT
DONE lNTERFACE
CONFlG
REQ
STATUS
ERROR
BUSY
BOOL
WORD
BOOL
BOOL
Explanation of the formal parameters
The following table explains all the formal parameters for the TC_CONFIG instruction
Parameter Declaration Data type Range of values Description
REQ INPUT BOOL 0, 1 The instruction is started and the status
codes initialized on a rising edge.
Updating of the DONE, ERROR and
STATUS status codes when there is a
positive edge.
INTERFACE INPUT HW_INTERFA
CE (WORD)
Reference to the interface of the local
CP 12427
CONFIG INOUT VARIANT See also "IF_CONF: SDT for
telecontrol configuration data
Reference to the memory area with the
collected configuration data to be modified
ENO OUTPUT BOOL 0: Error
1: Error-free
Enable output
If there is a runtime error with the
instruction, ENO = 0 is set.
BUSY OUTPUT BOOL 0: Execution of the instruction
not started, completed or
aborted
1: The instruction is executing
Display of the processing status of the
instruction
DONE OUTPUT BOOL 0: -
1: The instruction executed
successfully
This parameter indicates whether or not
the job was completed without errors.
For the meaning in conjunction with the
parameters ERROR and STATUS, refer
to Codes of the instruction.
ERROR OUTPUT BOOL 0: -
1: Error
Error code
For the meaning in conjunction with the
parameters DONE and STATUS, refer to
Codes of the instruction.
STATUS OUTPUT WORD Status code
For the meaning in conjunction with the
parameters DONE and ERROR, refer to
Codes of the instruction.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2469
The codes BUSY, DONE and ERROR
The codes of DONE and ERROR are relevant only when BUSY = 0.
BUSY DONE ERROR Meaning
0 0 0 No job being executed
You will find all other code combinations of DONE and ERROR in the following table.
The codes DONE, ERROR and STATUS
The following table shows the condition codes formed based on DONE, ERROR and STATUS
that must be evaluated by the user program.
DONE ERROR STATUS Meaning
1 0 0000
H
Job executed without errors
0 0 7000
H
No job processing active (first instruction call)
0 0 7001
H
Job processing started (first instruction call)
0 0 7002
H
Job processing already active (renewed instruction call when BUSY = 1)
0 1 80E6
H
No query in progress (instruction call not started)
0 1 80EB
H
Query temporarily rejected (the CP is currently being configured by STEP 7).
0 1 80F6
H
Format error of a parameter in the called data block (wrong length, wrong format or invalid
value)
Check the "IF_CONF" SDT.
0 1 80F7
H
Wrong ID in the parameter fields of the configuration data:
Check the "IF_CONF" SDT.
Other error messages
Other error messages
The following error messages are used for diagnostics purposes. You can obtain more
information from the Siemens hotline.
DONE ERROR STATUS Meaning
0 1 80E0
H
Internal error
You should also note the possible meaning with the TC_SEND and TC_RECV
instructions.
TCON_...: SDTs for the telecontrol connection establishment
System data types TCON_... for the TC_CON instruction
To configure a telecontrol connection using the TC_CON instruction, the CONNECT parameter
of the instruction is used for the connection description.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2470 System Manual, 01/2013,
The connection description is specified by the structure of the system data type (SDT). The
structure of the relevant SDT contains the parameters necessary to establish the connection
with the remote communications partner.
For different connection types that depend on the remote communications partner, the
following SDTs are used:
TCON_IP_RFC for ISO-on-TCP connections to IPv4 stations with CP 12427
TCON_IP_V4 for UDP connections to IPv4 stations (sending only)
TCON_PHONE for connections to SMS clients
TCON_WDC for connections to telecontrol servers or stations that can be reached via the
telecontrol server.
The parameter assignment of the connection description is made in a data block of the same
type as the SDT.
Creating a DB of the type TCON_...
You will need to type in the data types of the relevant DBs with the keyboard. They are not
displayed in the selection list. The data types are not case-sensitive.
To create a TCON_... DB, follow the steps outlined below:
1. Create a data block of the type "global DB" with block access "Standard".
2. Create an SDT in the table of the parameter configuration of the DB by assigning the name
and typing in the required type (for example "TCON_IP_RFC") in the cell of the data type.
The SDT and its parameters are created (see below).
3. Configure the parameters that are described below for each SDT type.
Reserved bits are not displayed.
System data type TCON_IP_RFC for connections to IPv4 stations
This connection type is supported only on ISOonTCP connections to communications
partners with a fixed IP address. The CP must be configured for the "GPRS direct" mode.
Table 9-73 Parameters of TCON_IP_RFC
Byte Parameter Data type Initial value Description
0 ... 1 InterfaceID HW_ANY Reference to the interface of the local CP 12427 (see
STEP 7 > CP configuration > Telecontrol interface >
"Hardware identifier")
2 ... 3 ID CONN_OUC 1...07FF
h
Reference to the GPRS connection. The ID is
assigned and must be unique within the CPU.
Here, the same value as that of the ID parameter of
the TC_CON instruction must be used.
4 ConnectionType BYTE W#16#0C Protocol variant 12 (C
h
): ISOonTCP connection
5 ActiveEstablished BOOL Identifier for the type of connection establishment:
0: Passive connection establishment
1: Active connection establishment
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2471
Byte Parameter Data type Initial value Description
6 ... 7 - - - - reserved -
8 ... 11
RemoteAddress IP_V4 IP address of the connection partner
ADDR Array [1...4] of
Byte
IP address of the relevant connection partner
12 ...
13
RemoteTSelector TSelector Remote T selector
TSelLen UINT Length of the remote T selector "RemoteTSelector"
14 ...
45
TSel Array [1...32]
of Byte
any Remote transport selector of the connection
When "ActiveEstablished" = 1:
With active connection establishment, the T
selector of the local partner must be the same as
the T selector of the connection partner (passive
connection establishment on the remote partner).
When "ActiveEstablished" = 0 correspondingly
(passive connection establishment local, active
connection establishment remote)
46 ...
47
LocalTSelector TSelector Local T selector
TSelLen UINT Length of the local T selector "LOCAL_TSel"
48 ...
79
TSel Array [1...32]
of Byte
any Local transport selector of the connection
When "ActiveEstablished" = 1:
With active connection establishment, the T
selector of the local partner must be the same as
the T selector of the connection partner (passive
connection establishment on the remote partner).
When "ActiveEstablished" = 0 correspondingly
(passive connection establishment local, active
connection establishment remote)
System data type TCON_IP_V4 for connections to IPv4 stations
This connection type is supported only for sending on UDP connections to communications
partners with a fixed IP address.
To receive, ActiveEstablished = 0 must be set.
Table 9-74 Parameters of TCON_IP_V4
Byte Parameter Data type Initial value Description
0 ... 1 InterfaceID HW_ANY Reference to the interface of the local CP 12427 (see
STEP 7 > CP configuration > Telecontrol interface >
"Hardware identifier")
2 ... 3 ID CONN_OUC 1...07FF
h
Reference to the GPRS connection. The ID is
assigned and must be unique within the CPU.
Here, the same value as that of the ID parameter of
the TC_CON instruction must be used.
4 ConnectionType BYTE W#16#0B Protocol variant 11 (B
h
): UDP connection
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2472 System Manual, 01/2013,
Byte Parameter Data type Initial value Description
5 ActiveEstablished BOOL Identifier for the type of connection establishment:
0: Passive connection establishment
Setting for sending and receiving data.
1: Active connection establishment
Setting for sending data only.
6 ... 7 - - - - reserved -
8 ... 11
RemoteAddress IP_V4 IP address of the connection partner
ADDR Array [1...4] of
Byte
IP address of the relevant connection partner
12 ...
13
RemotePort UINT 1...65535 IP port of the connection partner
Not relevant if ActiveEstablished = 0
14 ...
15
LocalPort UINT 1...65535 Local IP port ("0" is not permitted)
Not relevant if ActiveEstablished = 1
System data type TCON_PHONE for SMS connections
Note
Authorized phone numbers
The CP only accepts an SMS if the sending communication partner is authorized based on
its phone number. These numbers are in configured for the CP in STEP 7 in the "authorized
phone numbers" list.
SMS text
Programmed SMS texts for SMS messages to be sent are accessed using the DATA
parameter of the TC_SEND instruction.
The text of a received SMS message is assigned to the address area of the CPU by the
DATA parameter of the TC_RECV instruction.
Table 9-75 Parameters of TCON_PHONE
Byte Parameter Data type Initial value Description
0 ... 1 InterfaceID HW_ANY Reference to the interface of the local CP 12427 (see
STEP 7 > CP configuration > Telecontrol interface >
"Hardware identifier")
2 ... 3 ID CONN_OUC 1...07FF
h
Reference to the GPRS connection. The ID is
assigned and must be unique within the CPU.
Here, the same value as that of the ID parameter of
the TC_CON instruction must be used.
4 ConnectionType BYTE W#16#0E Protocol variant 14 (E
h
): SMS connection
5 ActiveEstablished BOOL Identifier for the type of connection establishment (not
relevant for the CP 1242-7):
0: Passive connection establishment (not relevant
here)
1: Active connection establishment
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2473
Byte Parameter Data type Initial value Description
6...7 - - - - reserviert -
8 ... 31 PhoneNumber STRING[22] Call number of the connection partner
Permitted values: Plus character (+) and numbers
Note the exact notation of the international dialing
code of the relevant phone number assigned by the
network provider ("+" character or zeros).
Without an entry for the PhoneNumber parameter, no
connection partner is specified and SMS messages
can be received reception from all authorized
connection partners.
Note the following during startup: Without an entry,
TC_RECV first delivers the oldest received SMS
message.
System data type TCON_WDC for connections to telecontrol servers or remote stations
You can configure the connection to the telecontrol server assigned to the S71200 or to a
remote station that can be reached via the telecontrol server with TCON_WDC. The address
data of the telecontrol server assigned to the CP can be found in STEP 7 in the "Telecontrol
interface > Mode" tab of the CP. The telecontrol server or a remote station is addressed using
the host name or the IP address.
The "RemoteWdcAddress" parameter of TCON_WDC specifies the Access ID of the
connection partner.
Table 9-76 Parameters of TCON_WDC
Byte Parameter Data type Initial value Description
0 ... 1 InterfaceID HW_ANY Reference to the interface of the local CP 12427 (see
STEP 7 > CP configuration > Telecontrol interface >
"Hardware identifier")
2 ... 3 ID CONN_OUC 1...07FF
h
Reference to the GPRS connection. The ID is
assigned and must be unique within the CPU.
Here, the same value as that of the ID parameter of
the TC_CON instruction must be used.
4 ConnectionType BYTE W#16#0F Protocol variant 15 (F
h
): Telecontrol connection using
an IP address
5 ActiveEstablished BOOL Identifier for the type of connection establishment:
0: Passive connection establishment
1: Active connection establishment
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2474 System Manual, 01/2013,
Byte Parameter Data type Initial value Description
6 ... 7 - - - - reserved -
8 ... 11 RemoteWdcAddress DWORD Specifies the Access ID (hex). The access ID depends
on the connection partner.
Connection to a remote CP:
The access ID is made up of the following:
STEP 7 project number
Station number
Slot
If the remote station has more than one GPRS-
CP and you do not want to specify the path,
the last byte for the slot must be set to 0.
You will find the access ID in the STEP 7 project
in the "CP authentication of the CP" parameter
group.
Connection to the telecontrol server:
Access ID = 0
To only write to the process image of the CP:
Access ID = DW#16#FEEDDADA
IF_CONF: SDT for telecontrol configuration data
Structure of the system data type IF_CONF for the TC_CONFIG instruction
The CONFIG parameter of the TC_CONFIG instruction references the memory area with the
configuration data of the CP 1242-7 to be modified. The configuration data stored in a data
block is described as a structure of the system data type (SDT) IF_CONF.
IF_CONF is made up of a header followed by fields that correspond to the parameters or
parameter areas of the CP in the device properties of the STEP 7 project.
The CP configuration data to be modified is collected together as IF_CONF fields. Parameters
that will not be modified are ignored in the IF_CONF structure and remain as they were
configured in the STEP 7 project.
Creating the DB and the IF_CONF structures
You can create the parameters of the CP within the IF_CONF DB in one or more structures
each with one or more fields.
You will need to type in the data types of the fields using the keyboard. They are not displayed
in the selection list. The data types are not case-sensitive.
Follow the steps below to create IF_CONF:
1. Create a data block of the type "global DB" with block access "Standard".
2. Create a structure (data type "Struct") in the table of the parameter configuration of the DB.
You can specify any name.
3. Under this structure add a header by assigning the name of the header and typing it in in
the cell of the data type "IF_CONF_Header".
The header of the structure and its three parameters (see below) is created.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2475
4. Create a field for the first parameter to be changed by typing in the required data type (for
example "IF_CONF_APN") in the cell of the data type.
5. Repeat the last step for all parameters you want to change on the CP using the TC_CONFIG
instruction.
6. Finally, update the number of fields in the header in the "subfieldCnt" parameter.
Header of IF_CONF
Table 9-77 IF_CONF_Header
Byte Parameter Data type Initial value Description
0 ... 1 fieldType UINT Field type: Must always be 0.
2 ... 3 fieldId UINT Field ID: Must always be 0.
4 ... 5 subfieldCnt UINT Total number of fields contained in the structure
General parameters of the parameter fields
Each field has the following general parameters:
Id
This parameter identifies the field and must not be modified.
Length
This parameter indicates the length of the field. The value serves as information.
Fields with strings and / or arrays have a variable length. Due to hidden bytes, the actual
length of fields can be greater than the sum of the displayed parameters.
Mode
The following values are permitted to these parameters:
Table 9-78 Values of "Mode"
Value Meaning
1 Permanent validity of the configuration data
Not relevant for the CP 12427
2 Temporary validity of the configuration data, including deleting of existing permanent
configuration data
The permanent configuration data is replaced by the parameter fields of IF_CONF.
Field for the parameter area "GPRS access"
Table 9-79 IF_CONF_APN
Parameter Data type Initial value Description
Id UINT 4 ID of the parameter field
Length UINT Length of the parameter field in bytes: 174
Mode UINT Validity (1: permanent, 2: temporary)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2476 System Manual, 01/2013,
Parameter Data type Initial value Description
AccesspointGPRS STRING [98] APN: Name of the access point of the GSM network
provider to the Internet
AccesspointUser STRING [42] APN user name
AccesspointPassword STRING [22] APN password
Field for the parameter area "CP identification"
Table 9-80 IF_CONF_Login
Parameter Data type Initial value Description
Id UINT 5 ID of the parameter field
Length UINT Length of the parameter field in bytes: 54
Mode UINT Validity (1: permanent, 2: temporary)
ModemName STRING [22] Access ID
The value cannot be set.
ModemPassword STRING [22] Telecontrol password (max. 20 characters)
Field for the parameter area "Telecontrol server access"
This field is only used when the telecontrol server is addressed with a name that can be
resolved by DNS. If the telecontrol server is addressed with its IP address, the
"IF_CONF_TCS_IP_V4" field is used.
In STEP 7, the corresponding data is located in the "Mode" parameter area.
If there is more than one telecontrol server, use the field once per server.
Table 9-81 IF_CONF_TCS_Name
Parameter Data type Initial value Description
Id UINT 6 ID of the parameter field
Length UINT Length of the parameter field in bytes: 266
Mode UINT Validity (1: permanent, 2: temporary)
TcsName - - - reserved -
STRING [254] Name of the telecontrol server that can be resolved by DNS
RemotePort UINT Port of the telecontrol server
Rank UINT Priority of the server [1, 2]
1 = main telecontrol server,
2 = substitute telecontrol server
Field for the parameter area "Telecontrol server access"
This field is only used when the telecontrol server is addressed by its IP address. If the
telecontrol server is addressed by its DNS name, the "IF_CONF_TCS_Name" field is used.
In STEP 7, the corresponding data is located in the "Mode" parameter area.
If there is more than one telecontrol server, use the field once per server.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2477
Table 9-82 IF_CONF_TCS_IP_v4
Parameter Data type Initial value Description
Id UINT 7 ID of the parameter field
Length UINT Length of the parameter field in bytes: 14
Mode UINT Validity (1: permanent, 2: temporary)
RemoteAddress IP_V4 IP address of the telecontrol server
RemotePort UINT Port of the telecontrol server
Rank UINT Priority of the server [1, 2]
1 = main telecontrol server,
2 = substitute telecontrol server
Field for the "Mode" parameter area
In STEP 7, the corresponding data is located in the parameter areas "Mode" and Modem
settings".
Table 9-83 IF_CONF_GPRS_Mode
Parameter Data type Initial value Description
Id UINT 8 ID of the parameter field
Length UINT Length of the parameter field in bytes: 10
Mode UINT Validity (1: permanent, 2: temporary)
GPRSmode UINT Mode of the CP:
0 = Telecontrol
1 = GPRS direct
TemporaryStation BOOL Bit 0: Temporary connection
If this option is selected, the CP only establishes a
temporary connection to send data. Once the frames have
been transferred, the CP terminates the connection again.
1: activated (temporary connection)
0: deactivated (permanent connection)
SMS_Enabled BOOL Bit 1: Allow SMS
Selecting the option allows the S7 station to send SMS
messages.
1: activated (SMS allowed)
0: deactivated (no SMS)
Field for the "SMSC" parameter
In STEP 7, the corresponding data is located in the parameter area "Modem settings".
Table 9-84 IF_CONF_SMS_Provider
Parameter Data type Initial value Description
Id UINT 10 ID of the parameter field
Length UINT Length of the parameter field in bytes: 28
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2478 System Manual, 01/2013,
Parameter Data type Initial value Description
Mode UINT Validity (1: permanent, 2: temporary)
SMSProvider STRING [20] Node number of the SMS center (SMSC) of the GSM
network provider with which the contract was signed for
this station.
Field for the "PIN" parameter
In STEP 7, the corresponding data is located in the parameter area "Modem settings".
Table 9-85 IF_CONF_PIN
Parameter Data type Initial value Description
Id UINT 11 ID of the parameter field
Length UINT Length of the parameter field in bytes: 16
Mode UINT Validity (1: permanent, 2: temporary)
Pin STRING [8] PIN of the SIM card inserted in the SIM card
The parameter is not relevant if the PIN was correctly
configured. If the PIN was incorrectly configured, the
correct PIN can be entered.
Field for monitoring times
In STEP 7, the corresponding data is located in the parameter areas "Keepalive timeout" and
Operating mode".
Table 9-86 IF_CONF_TC_Timeouts
Parameter Data type Initial value Description
Id UINT 12 ID of the parameter field
Length UINT Length of the parameter field in bytes: 12
Mode UINT Validity (1: permanent, 2: temporary)
KeepAliveTimeout - Reserved - (cannot be set)
SendTimeout UINT Connection monitoring time: Monitoring time of the
connection to the communications partner (seconds)
Relevant in the modes "Telecontrol" and "GPRS direct"
RedialTimeout UINT Dialing repetition delay: Basic value for the wait time until
the next attempt to establish a connection following an
unsuccessful connection establishment. After every 3
attempts, the basic value is doubled up to a maximum of
900 s. Range of values: 10 to 600 s. If a substitute
telecontrol server is configured, the CP attempts to connect
to it at the 4th dialin attempt. Example: Basic value 20
results in the following dialing intervals: three times 20 s,
three times 40 s, three times 80 s etc. up to a maximum of
900 s.
Not relevant for SMS connections
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2479
Field for the "Wake up right" parameter area
Table 9-87 IF_CONF_WakeupList
Parameter Data type Initial value Description
Id UINT 13 ID of the parameter field
Length UINT Length of the parameter field in bytes: 246
Mode UINT Validity (1: permanent, 2: temporary)
WakeupPhone [1...10] ARRAY
[1...10] of
STRING [22]
Phone number subscriber authorized to wake up
The asterisk (*) at the end of a call number is used a
placeholder for direct dialing numbers.
Field for the "Preferred GSM networks" parameter area
Table 9-88 IF_CONF_PrefProvider
Parameter Data type Initial value Description
Id UINT 14 ID of the parameter field
Length UINT Length of the parameter field in bytes: 46
Mode UINT Validity (1: permanent, 2: temporary)
Provider [1...5] ARRAY [1...5]
of STRING [6]
Alternative GSM networks with priority 1 to 5 into which the
CP dials. Up to 5 networks can be configured. No. 1 with
highest priority, no. 5 with lowest priority.
Entry of the Public Land Mobile Network (PLMN) of the
network provider consisting of Mobile Country Code (MCC)
and Mobile Network Code (MNC).
Example (test network of Siemens AG): 26276
Field for the "DNS configuration" parameter area
Table 9-89 IF_CONF_DNS
Parameter Data type Initial value Description
Id UINT 16 ID of the parameter field
Length UINT Length of the parameter field in bytes: 14
Mode UINT Validity (1: permanent, 2: temporary)
DNS_IP [1] IP_V4 IP address of the 1st domain name system server
DNS_IP [2] IP_V4 IP address of the 2nd domain name system server
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2480 System Manual, 01/2013,
Field for the "Time-of-day synchronization" parameter area
Table 9-90 IF_CONF_NTP
Parameter Data type Initial value Description
Id UINT 17 ID of the parameter field
Length UINT Length of the parameter field in bytes: 24
Mode UINT Validity (1: permanent, 2: temporary)
NTP_IP [1] ARRAY [1...4]
of IP_V4
IP address of NTP server 1
... ... (IP address of NTP server 2...3)
NTP_IP [4] ARRAY [1...4]
of IP_V4
IP address of NTP server 4
Block for activating / deactivating TeleService users
SDT for activating or deactivating TeleService users already configured in the STEP 7 project
of the CP. In STEP 7, the corresponding data can be found in the parameter area "TeleService
settings" > "TeleService user management".
Table 9-91 IF_CONF_GPRS_UserList
Parameter Data type Initial value Description
Id UINT 19 ID of the parameter field
Length UINT Length of the parameter field in bytes: 506
Mode UINT Validity (1: permanent, 2: temporary)
GPRS_User [1...10] ARRAY
[1...10] of
GPRS_User
TeleService user no. 1 to max. no. 10
The array is formed from the parameter records for the TeleService users ("GPRS_User"
[1...n]).
Table 9-92 GPRS_User [n] (parameter for TeleService user)
Parameter Data type Initial value Description
UserName [n] STRING [22] TeleService user name
Password [n] STRING [22] - The string must be empty! -
Diag_Allowed [n] BOOL - Reserved - (cannot be set)
Teleserv_Allowed [n] BOOL Activation of the TeleService user
0 = user is deactivated
1 = user is activated
FW_Load_Allowed [n] BOOL - Reserved - (cannot be set)
Field for setting the parameters for TeleService access (DNS name of the server)
Access data of the TeleService server (switching station).
In STEP 7, the corresponding data is located in the parameter area "TeleService settings".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2481
If there is more than one TeleService server, use the field once per server.
Table 9-93 IF_CONF_TS_Name
Parameter Data type Initial value Description
Id UINT 20 ID of the parameter field
Length UINT Length of the parameter field in bytes: 266
Mode UINT Validity (1: permanent, 2: temporary)
ts_name String [254] Name of the TeleService server that can be resolved by
DNS
RemotePort UINT Port of the engineering station
Rank UINT Priority of the server [1] or [2]
1 = server 1, 2 = server 2
Field for setting the parameters for TeleService access (IP address of the server)
Access data of the TeleService server (switching station).
In STEP 7, the corresponding data is located in the parameter area "TeleService settings".
If there is more than one TeleService server, use the field once per server.
Table 9-94 IF_CONF_TS_IF_V4
Parameter Data type Initial value Description
Id UINT 21 ID of the parameter field
Length UINT Length of the parameter field in bytes: 14
Mode UINT Validity (1: permanent, 2: temporary)
RemoteAddress IP_V4 IP address of the TeleService server
RemotePort UINT Port of the TeleService server
Rank UINT Priority of the server [1] or [2]
1 = server 1, 2 = server 2
Point-to-point
PORT_CFG: Configure communication parameters dynamically
Description
The instruction "PORT_CFG" allows dynamic configuration of communications parameters for
a point-to-point communications port.
You set up the original static configuration of the port in the hardware configuration. You can
change this configuration by executing the "PORT_CFG" instruction. You can also use this
function to save created blocks in libraries and to avoid configuration in the hardware
configuration when you reuse it.
With "PORT_CFG" you can influence the following communications parameter settings:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2482 System Manual, 01/2013,
Parity
Baud rate
Number of bits per character
Number of stop bits
Type and properties of flow control
The changes made by the "PORT_CFG" instruction are not stored permanently on the target
system.
You can transfer serial data via the electrical connections RS-232 (half and full duplex) and
RS-485 (half duplex).
Parameters
The following table shows the parameters of the "PORT_CFG" instruction:
Parameter Declaration Data type Memory area Description
REQ Input BOOL I, Q, M, D, L Activates the configuration change on a rising edge
PORT Input PORT
(UINT)
D, L or constant Identification of the communication port (HW-ID)
PROTOCOL Input UINT I, Q, M, D, L or
constant
Transmission protocol:
0: Point-to-point communication protocol
1..n: Future definition for specific transmission
protocols
BAUD Input UINT I, Q, M, D, L or
constant
Baud rate of the port:
1: 300 baud
2: 600 baud
3: 1200 baud
4: 2400 baud
5: 4800 baud
6: 9600 baud (default)
7: 19200 baud
8: 38400 baud
9: 57600 baud
10: 76800 baud
11: 115200 baud
PARITY Input UINT I, Q, M, D, L or
constant
Parity of the port:
1: No parity (default)
2: Even parity
3: Odd parity
4: Mark parity
5: Space parity
DATABITS Input UINT I, Q, M, D, L or
constant
Bits per character:
1: 8 bits per character (default)
2: 7 bits per character
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2483
Parameter Declaration Data type Memory area Description
STOPBITS Input UINT I, Q, M, D, L or
constant
Number of stop bits:
1: 1 stop bit (default)
2: 2 stop bits
FLOWCTRL Input UINT I, Q, M, D, L or
constant
Data flow control:
1: None (default)
2: XON/XOFF
3: Hardware flow control (RTS always activated)
4: Hardware flow control (RTS can be deactivated
during transmission)
XONCHAR Input CHAR D Indicates the character used as XON character. The
character DC1 (11H) is set as default.
XOFFCHAR Input CHAR D Indicates the character used as XOFF character. The
character DC3 (13H) is set as default.
WAITIME Input UINT I, Q, M, D, L or
constant
Specifies the wait time for XON or CTS after the start
of the transmission.
The specified value must be greater than 0. 2000
milliseconds are set as default.
DONE Output BOOL I, Q, M, D, L Status parameter with the following values:
0: Job not yet started or is still executing
1: Job executed without errors
ERROR Output BOOL I, Q, M, D, L Status parameter with the following values:
0: No error
1: Error occurred
STATUS Output WORD I, Q, M, D, L Status of the instruction
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
STATUS parameter
Error code*
(W#16#...)
Description
80A0 The specified protocol is invalid.
80A1 The specified baud rate is invalid.
80A2 The specified parity rate is invalid.
80A3 The specified number of bits per character is invalid.
80A4 The specified number of stop bits is invalid.
80A5 The specified type of flow control is invalid.
80A6 Incorrect value at the WAITTIME parameter
When the data flow control is enabled, the value at the WAITTIME parameter must be greater than zero.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2484 System Manual, 01/2013,
Error code*
(W#16#...)
Description
80A7 Invalid values at XONCHAR and XOFFCHAR parameters.
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
You will find more detailed information on general error codes of the communication
instructions in: "General status information of the communications blocks (Page 2500)".
SEND_CFG: Configure serial transmission parameters dynamically
Description
The instruction "SEND_CFG" allows dynamic configuration of serial transmission parameters
for a point-to-point communications port. All the messages waiting for transfer are discarded
after execution of SEND_CFG.
You set up the original static configuration of the port in the hardware configuration. You can
change this configuration by executing the "SEND_CFG" instruction. You can also use this
function to save created blocks in libraries and to avoid configuration in the hardware
configuration when you reuse it. With "SEND_CFG" you can influence the following
transmission parameter settings:
Time between the activation of RTS (Request to Send) and the start of the transmission
Time between the end of transmission and the deactivation of RTS
Define bit times for breaks
The changes made by the "SEND_CFG" instruction are not stored permanently on the target
system.
You can transfer serial data via the electrical connections RS-232 (half and full duplex) and
RS-485 (half duplex).
Parameters
The following table shows the parameters of the "SEND_CFG" instruction:
Parameter Declaration Data type Memory area Description
REQ Input BOOL I, Q, M, D, L Activates the configuration change on a rising edge
PORT Input PORT
(UINT)
D, L or constant Identification of the communication port (HW-ID)
RTSONDLY Input UINT I, Q, M, D, L or
constant
The time that should elapse after activating RTS until
the start of transmission.
Valid values for this parameter are as follows:
0 (default)
0 to 65535 ms in steps of 1 ms
This parameter does not apply to RS-485 modules.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2485
Parameter Declaration Data type Memory area Description
RTSOFFDLY Input UINT I, Q, M, D, L or
constant
Time that should elapse after the end of transmission
until deactivation of RTS.
Valid values for this parameter are as follows:
0 (default)
0 to 65535 ms in steps of 1 ms
This parameter does not apply to RS-485 modules.
BREAK Input UINT I, Q, M, D, L or
constant
Specifies the bit times for a break, which are sent at
the start of the message.
12 bit times are set as default. A maximum of 25000
bit times can be specified.
IDLELINE Input UINT I, Q, M, D, L or
constant
Specifies the bit times for idle line after the break at
the start of the message.
12 bit times are set as default. A maximum of 25000
bit times can be specified.
DONE Output BOOL I, Q, M, D, L Status parameter with the following values:
0: Job not yet started or is still executing
1: Job executed without errors
ERROR Output BOOL I, Q, M, D, L Status parameter with the following values:
0: No error
1: Error occurred
STATUS Output WORD I, Q, M, D, L Status of the instruction
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
STATUS parameter
Error code*
(W#16#...)
Description
80B0 The configuration of a transmission interruption is not permitted.
80B1 The specified break time exceeds the permitted maximum of 25000 bit times.
80B2 The specified time for idle line exceeds the permitted maximum of 25000 bit times.
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
You will find more detailed information on general error codes of the communication
instructions in: "General status information of the communications blocks (Page 2500)".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2486 System Manual, 01/2013,
RCV_CFG: Configure serial receive parameters dynamically
Description
The instruction "RCV_CFG" allows dynamic configuration of serial receive parameters for a
point-to-point communications port. You can use this instruction to configure the conditions
that specify the start and end of the message to be transmitted. The receipt of messages that
correspond to these conditions can be enabled by the "RCV_PTP (Page 2495)" instruction.
You set up the original static configuration of the port in the properties of the hardware
configuration. Execute the "RCV_CFG" instruction in your program to change the configuration.
You can also use this function to save created blocks in libraries and to avoid configuration in
the hardware configuration when you reuse it. The changes made by the "RCV_CFG"
instruction are not stored permanently on the target system.
All the messages waiting for transfer are discarded after execution of the "RCV_CFG"
instruction.
Parameters
The following table shows the parameters of the "RCV_CFG" instruction:
Parameter Declaration Data type Memory area Description
REQ Input BOOL I, Q, M, D, L Activates the configuration change on a
rising edge.
PORT Input PORT (UINT) D, L or constant Identification of the communication port
(HW-ID)
CONDITIONS Input CONDITIONS D, L Data structure defining the conditions for
start and end of data transmission.
DONE Output BOOL I, Q, M, D, L Status parameter with the following values:
0: Job not yet started or is still executing
1: Job executed without errors
ERROR Output BOOL I, Q, M, D, L Status parameter with the following values:
0: No error
1: Error occurred.
STATUS Output WORD I, Q, M, D, L Status of the instruction
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
Data type CONDITIONS
You can use the CONDITIONS structure to define the start and end conditions for the message
transmission. The structure CONDITIONS is included in the instance DB of the "RCV_CFG"
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2487
instruction. Use the structure CONDITIONS to define the start and end conditions when the
transmission of a message is complete and when the next message transfer is to start:
You define the start conditions for the data transfer in the START structure.
You define the end conditions for the data transfer in the END structure.
You can define one or more start and end conditions for this. If you specify multiple start or
end conditions these are linked by an OR logic instruction.
The following table shows the "CONDITIONS" structure:
Parameters Data type Description
START STRUCT Start conditions
STARTCOND UINT Specifies the start condition (details, see below).
The start condition can be specified as a 16-bit hexadecimal value. Possible values
for the start condition are:
1: Start character
2: Any character (default)
4: Line break
8: Idle line
16: Character string 1
32: Character string 2
64: Character string 3
128: Character string 4
Multiple start conditions can also be defined at the STARTCOND parameter. The
total from the values of the individual conditions is specified for this. If, for example,
you want to define "Idle line" OR "Character string 1" OR "Character string 4" as
start condition, the value "152" must be specified.
IDLETIME UINT Specifies the maximum idle time of the line before receipt is started.
Valid values for this parameter are as follows:
40 bit times (default)
0 to 2500 bit times
STARTCHAR BYTE Specifies the start character. This setting is only enabled when the configured start
condition is "Start character".
Valid values for this parameter are as follows:
02 (STX): Default setting
B#16#00 to B#16#FF
SEQ[1].CTL BYTE Character string 1: Control sequence for each character
You can use the bit position of the character to define which characters of the
character string will be considered or ignored. To evaluate the characters, the
corresponding bits have to be set.
Bit 0: 1 character
Bit 1: 2 characters
Bit 2: 3 characters
Bit 3: 4 characters
Bit 4: 5 characters
A character is ignored when the corresponding bit is reset.
SEQ[1].STR CHAR[5] Character string 1: Start character (5 characters)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2488 System Manual, 01/2013,
Parameters Data type Description
SEQ[2].CTL BYTE Character string 2: Ignore/compare control sequence for each character
SEQ[2].STR CHAR[5] Character string 2: Start character (5 characters)
SEQ[3].CTL BYTE Character string 3: Ignore/compare control sequence for each character
SEQ[3].STR CHAR[5] Character string 3: Start character (5 characters)
SEQ[4].CTL BYTE Character string 4: Ignore/compare control sequence for each character
SEQ[4].STR CHAR[5] Character string 4: Start character (5 characters)
END STRUCT End conditions
ENDCOND UINT Specifies the end condition (details, see below).
The end condition can be specified as a 16-bit hexadecimal value. Possible values
for the end condition are:
1: Reply timeout
2: Message timeout
4: Timeout within the character string
8: Maximum length
16: N+LEN+M; the information on the message length in integrated in the
message and will be evaluated.
32: Character string 1
Multiple end conditions can also be defined at the ENDCOND parameter. The total
from the values of the individual end conditions is specified for this. If, for example,
you want to define the end condition "Maximum length" OR "Sequence 1", the
value "40" must be specified.
MAXLEN UINT Specifies the maximum number of characters in a message.
Valid values* for this parameter are as follows:
1 character (default)
0 to 1024 characters
This setting is only enabled if the "Maximum length" end condition is set at the
ENDCOND parameter.
N UINT Offset of the length field in the message
Valid values for this parameter are as follows:
0 characters (default)
0 to 1024 characters
This setting is only enabled if the "N+LEN+M" end condition is set at the
ENDCOND parameter.
LENGTHSIZE UINT Size of the length field in bytes
Valid values* for this parameter are as follows:
0 bytes (default)
1 byte
2 bytes
4 bytes
This setting is only enabled if the "N+LEN+M" end condition is set at the
ENDCOND parameter.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2489
Parameters Data type Description
LENGTHM UINT Specifies the number of end characters that follow the length field but are not
contained in the length of the message.
Valid values for this parameter are as follows:
0 characters (default)
0 to 255 characters
This setting is only enabled if the "N+LEN+M" end condition is set at the
ENDCOND parameter.
RCVTIME UINT Specifies the maximum duration for the receipt of the first character of a message.
Valid values for this parameter are as follows:
200 ms (default)
0 to 65535 ms in steps of 1 ms
This setting is only enabled if the "Reply timeout" end condition is set at the
ENDCOND parameter.
MSGTIME UINT Specifies the maximum duration of the receipt of a message.
Valid values for this parameter are as follows:
200 ms (default)
0 to 65535 ms in steps of 1 ms
This setting is only enabled if the "Message timeout" end condition is set at the
ENDCOND parameter.
CHARGAP UINT Specifies the time interval between received consecutive characters.
Valid values for this parameter are as follows:
12 bit times (default)
0 to 2500 bit times
This setting is only enabled if the "Timeout within the character string" end
condition is set at the ENDCOND parameter.
SEQ.CTL BYTE Character string: Control sequence for each character
You can use the bit position of the character to define which characters of the
character string will be considered or ignored. To evaluate the characters, the
corresponding bits have to be set.
Bit 0: 1 character
Bit 1: 2 characters
Bit 2: 3 characters
Bit 3: 4 characters
Bit 4: 5 characters
A character is ignored when the corresponding bit is reset.
SEQ.STR CHAR[5] Character string: Start character (5 characters)
* These value ranges also apply to the corresponding hardware settings for specifying the end of message.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2490 System Manual, 01/2013,
Start conditions for the message receipt (STARTCOND parameter)
The start of the message is recognized by the receiver if a configured start condition applies.
The following conditions can be defined as start conditions for message receipt:
Start character: The start of a message is recognized when a certain character occurs. This
character is stored as first character of the message. All characters received before the
start character are rejected.
Any character: Any character can define the start of a message. This character is stored
as first character of the message.
Line break: The start of a message is recognized if the received data stream is interrupted
for longer than one character length.
Idle line: The start of a message is recognized when the send transmission line is in the
idle state for a certain time (specified in bit times) followed by renewed transmission of
characters.
Character string (sequence): The start of a message is recognized when a specified
character sequence occurs in the data stream. You can specify up to four character
sequences with up to five characters each.
Example: A received hexadecimal message includes the following characters: "68 10 aa
68 bb 10 aa 16". The configured start character sequences are listed in the following
table. Start character sequences will be evaluated once the first character 68H
has been received successfully. After the fourth character has been received successfully
(the
second 68H), the start condition "1" has been met. Once the start conditions have been
met,
evaluation of the end conditions will start.
Processing of the start character sequence can end due to different errors in parity,
framing or time intervals between characters. These errors will prevent
reception of the message, because the start condition has not
been met.
Start condition First character First character +1 First character +2 First character +3 First character +4
1 68H xx xx 68H xx
2 10H aaH xx xx xx
3 dcH aaH xx xx xx
4 e5H xx xx xx xx
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2491
End conditions for the message receipt (ENDCOND parameter)
The start of a message is recognized by the receiver if a configured end condition applies. The
following conditions can be defined as end conditions for message receipt:
Reply timeout: The receipt of messages will end when the specified maximum duration for
the receipt of a character is exceeded. The maximum duration is defined at the RCVTIME
parameter. The defined time starts to run down as soon at the last transmission is completed
and the RCV_PTP instruction enables the receipt of the message. If no character was
received within the defined time (RCVTIME), the RCV_PTP instruction reports an error.
Message timeout: The receipt of messages will end when the specified maximum duration
for the receipt of a message is exceeded. The maximum duration is defined at the
MSGTIME parameter. The defined time starts to run down as soon as the first character of
the message is received.
Timeout within the character string: The receipt of messages will end when the time interval
between the receipt of two consecutive characters is longer than the value at the CHARGAP
parameter.
Maximum length: The receipt of messages will end when the length of the message defined
at the MAXLEN parameter is exceeded.
Reading message length (N+LEN+M): The receipt of messages will end when a certain
message length is reached. This length is calculated by the values of the following
parameters:
N: Position of the character in the message from which the length field begins.
LENGTHSIZE: Size of the length field in bytes
LENGTHM: Number of end characters that follow the length field. These characters are
not taken into account in the evaluation of the message length.
Character string: The receipt of messages will end when a defined character sequence is
received. The character string can contain a maximum of five characters. For each
character of the character string, you can use the bit position to define if this will be
considered or ignored in the evaluation.
STATUS parameter
Error code*
(W#16#...)
Description
80C0 Error in start condition
80C1 Error in end condition
No end condition defined
80C2 Receive interrupt enabled
80C3 A value that is equal to 0 or greater than 4132 was entered at the MAXLEN parameter while the "Maximum
length" end condition was set.
80C4 A value that is greater than 4131 was entered at the N parameter while the "N+LEN+M" end condition was
set.
80C5 A value that is equal to 0 or invalid was entered at the LENGTHSIZE parameter while the "N+LEN+M" end
condition was set.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2492 System Manual, 01/2013,
Error code*
(W#16#...)
Description
80C6 A value that is greater than 255 was entered at the LENGTHM parameter while the "N+LEN+M" end condition
was set.
80C7 A message length greater than 4132 was calculated while the "N+LEN+M" end condition was set.
80C8 A value that is equal to 0 was entered at the RCVTIME parameter while the "Reply timeout" end condition
was set.
80C9 A value that is equal to 0 or greater than 2500 was entered at the CHARGAP parameter while the "Timeout
within a character string" end condition was set.
80CA A value that is equal to 0 or greater than 2500 was entered at the IDLETIME parameter while the "Idle line"
start condition was set.
80CB All characters of the character string are marked as "Don't care" even though "Character string" is set as
the end condition.
80CC All characters of the character string are marked as "Don't care" even though "Character string" is set as
the start condition.
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
You will find more detailed information on general error codes of the communication
instructions in: "General status information of the communications blocks (Page 2500)".
SEND_PTP: Transmit send buffer data
Description
You use the "SEND_PTP" instruction to start the transmission of data. The "SEND_PTP"
instruction does not execute the actual transmission of the data. The data of the send buffer
is transmitted to the relevant point-to-point communication module (CM). The CM executes
the actual transmission.
Parameters
The following table shows the parameters of the "SEND_PTP" instruction:
Parameter Declaration Data type Memory area Description
REQ Input BOOL I, Q, M, D, L Enables the requested transmission on a rising edge
of this enable input. The content of buffer is
transmitted to the point-to-point communication
module (CM).
PORT Input PORT
(UINT)
D, L or constant Identification of the communication port (HW-ID)
BUFFER Input VARIANT I, Q, M, D, L or
constant
Pointer to the start address of the send buffer.
Boolean values or Array of BOOL are not supported.
LENGTH Input UINT I, Q, M, D, L or
constant
Length of the send buffer
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2493
Parameter Declaration Data type Memory area Description
PTRCL Input BOOL I, Q, M, D, L or
constant
This parameter selects the buffer for normal point-to-
point communication or for specific Siemens
protocols implemented in the connected CM.
FALSE = point-to-point operations controlled by the
user program (only valid option)
DONE Output BOOL I, Q, M, D, L Status parameter with the following values:
0: Job not yet started or is still executing
1: Job executed without errors
ERROR Output BOOL I, Q, M, D, L Status parameter with the following values:
0: No error
1: Error occurred
STATUS Output WORD I, Q, M, D, L Status of the instruction
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
STATUS parameter
Error code*
(W#16#...)
Description
7000 The send operation is not active.
7001 The send operation is processing the first call.
7002 The send operation is processing subsequent calls (queries following the first call).
8080 The identifier entered for the communications port number is invalid.
8088 The length of the LENGHT parameter does not correspond to the length of data to be sent. See also:
Parameters LENGHT and BUFFER.
80D0 A new send request was received while a transmission was taking place.
80D1 The transmission was interrupted because the CTS signal was not confirmed within the specified wait
time.
80D2 The send request was interrupted because the communications partner (DCE) signaled that it was not
willing to receive (DSR).
80D3 The send request was interrupted because the maximum size of the waiting loop was exceeded (more
than 1024 Byte).
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
You will find more detailed information on general error codes of the communication
instructions in: "General status information of the communications blocks (Page 2500)".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2494 System Manual, 01/2013,
Parameters LENGTH and BUFFER
The minimum data size that can be sent by the "PTP_SEND" instruction is one byte. The
parameter BUFFER defines the size of the data to be sent. You can use neither the BOOL nor
the Array of BOOL data type for the BUFFER parameter.
LENGTH parameter BUFFER parameter Description
LENGTH = 0 Not used The complete data is sent as defined by the BUFFER parameter. If
LENGTH = 0, you do not need to specify the number of bytes
transferred.
LENGTH > 0 Elementary data type The LENGTH value must contain the byte count of this data type.
Otherwise, data is not transferred and error 8088 is output.
STRUCT The LENGTH value can contain a byte count that is smaller than
the complete byte length of the structure. In this case, only the first
LENGTH bytes are transferred.
ARRAY The LENGTH value can contain a byte count that is smaller than
the complete byte length of the field. In this case, only the field
elements that fit completely in the LENGTH bytes are transferred.
The LENGTH value must be a multiple of the byte count of the data
elements. Otherwise, STATUS = 8088, ERROR = 1, and no data is
transferred.
STRING The complete memory arrangement of the character sequence
format will be transmitted as well as the information about maximum
length of the character string and the actual length of the character
string.
The LENGTH value must contain bytes for maximum length, actual
length, and the characters of the character string.
With the data type STRING, all lengths and characters have the size
of one byte.
If a character string is used for the BUFFER parameter, the
LENGTH value must also contain two bytes for the two length fields.
RCV_PTP: Enable receive messages
Description
With the RCV_PTP instruction you enable receipt of a sent message. Each message must be
enabled individually. The sent data is only available in the receive area when the message
has been acknowledged by the relevant communications partner.
Parameters
The following table shows the parameters of the "RCV_PTP" instruction:
Parameter Declaration Data type Memory area Description
EN_R Input BOOL I, Q, M, D, L Enables receipt on a rising edge
PORT Input PORT
(UINT)
D, L or constant Identification of the communication port (HW-ID)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2495
Parameter Declaration Data type Memory area Description
BUFFER Input VARIANT I, Q, M, D, L or
constant
Points to the start address of the receive buffer. Do not
use a tag of the type STRING in the receive buffer.
NDR Output BOOL I, Q, M, D, L Status parameter with the following values:
0: Job not yet started or is still executing
1: Job executed without errors
ERROR Output BOOL I, Q, M, D, L Status parameter with the following values:
0: No error
1: Error occurred
STATUS Output WORD I, Q, M, D, L Status of the instruction
LENGTH Output UINT I, Q, M, D, L Length of the message in the receive buffer
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
STATUS parameter
Error code*
(W#16#....)
Description
80E0 Receipt of messages was terminated because the receive buffer is full.
80E1 Receipt of messages was terminated as a result of a parity error.
80E2 Receipt of messages was terminated as a result of a framing error.
80E3 Receipt of messages was terminated as a result of an overflow error.
80E4 Receipt of messages was terminated because the calculated message length (N+LEN+M) exceeds the
size of the receive buffer.
8080 The identifier entered for the communications port number is invalid.
8088 A data type STRING is referenced via the BUFFER parameter.
0094 Receipt of messages was terminated because the maximum character length was received.
0095 Receipt of messages was terminated as a result of a timeout.
0096 Receipt of messages was terminated because of a timeout within the character string.
0097 Receipt of messages was terminated as a result of a reply timeout.
0098 Receipt of messages was terminated because the "N+LEN+M" length condition has been satisfied.
0099 Receipt of messages was terminated because the character string defined as the end condition was
received.
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
You will find more detailed information on general error codes of the communication
instructions in: "General status information of the communications blocks (Page 2500)".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2496 System Manual, 01/2013,
RCV_RST: Delete receive buffer
Description
With the "RCV_RST" instruction, you delete the receive buffer of a communications partner.
Parameters
The following table shows the parameters of the "RCV_RST" instruction:
Parameter Declaration Data type Memory area Description
REQ Input BOOL I, Q, M, D, L Enables deleting of the receive buffer on a rising
edge
PORT Input PORT (UINT) D, L or constant Identification of the communication port (HW-ID)
DONE Output BOOL I, Q, M, D, L Status parameter with the following values:
0: Job not yet started or is still executing
1: Job executed without errors
ERROR Output BOOL I, Q, M, D, L Status parameter with the following values:
0: No error
1: Error occurred
STATUS Output WORD I, Q, M, D, L Status of the instruction
You will find more detailed information on general
error codes of the communication instructions in:
"General status information of the communications
blocks (Page 2500)".
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
SGN_GET: Query RS-232 signals
Description
With the "SGN_GET" instruction, you query the current state of several signals of an RS-232
communications module.
Parameters
The following table shows the parameters of the "SGN_GET" instruction:
Parameter Declaration Data type Memory area Description
REQ Input BOOL I, Q, M, D, L or
constant
Enables the query on a rising edge
PORT Input PORT (UINT) D, L or constant Identification of the communication port (HW-ID)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2497
Parameter Declaration Data type Memory area Description
NDR Output BOOL I, Q, M, D, L Is set for one cycle if new data are ready for
sending and the instruction was executed error-
free.
DTR Output BOOL I, Q, M, D, L Data terminal ready, module ready
DSR Output BOOL I, Q, M, D, L Data set ready, communications partner ready
RTS Output BOOL I, Q, M, D, L Send request, module ready to send
CTS Output BOOL I, Q, M, D, L Clear to send, communications partner can
receive data (reaction to RTS = ON of the
module).
DCD Output BOOL I, Q, M, D, L Data carrier detect, received signal level
RING Output BOOL I, Q, M, D, L Ring display, display of an incoming call
ERROR Output BOOL I, Q, M, D, L Status parameter with the following values:
0: No error
1: Error occurred
STATUS Output WORD I, Q, M, D, L Status of the instruction
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
STATUS parameter
Error code*
(W#16#....)
Description
80F0 The communication module is an RS-485 module and no signals are available.
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
You will find more detailed information on general error codes of the communication
instructions in: "General status information of the communications blocks (Page 2500)".
SGN_SET: Set RS-232 signals
Description
With the "SGN_SET" instruction, you set the status of the output signals of an RS-232
communications module.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2498 System Manual, 01/2013,
Parameters
The following table shows the parameters of the "SGN_SET" instruction:
Parameter Declaration Data type Memory area Description
REQ Input BOOL I, Q, M, D, L or
constant
Activates the action on a rising edge
Initial value: FALSE
PORT Input PORT (UINT) D, L or constant Identification of the communication port (HW-ID)
Initial value: 0
SIGNAL Input BYTE I, Q, M, D, L or
constant
Specifies the signals to be set:
Set 01H = RTS
Set 02H = DTR
Set 04H = DSR
Initial value: FALSE
RTS Input BOOL I, Q, M, D, L or
constant
Send request, module ready to send
Initial value: FALSE
DTR Input BOOL I, Q, M, D, L or
constant
Data terminal ready, module ready
Initial value: FALSE
DSR Input BOOL I, Q, M, D, L or
constant
Data set ready (applies only to interfaces of the
DCE type)
Initial value: FALSE
DONE Output BOOL I, Q, M, D, L Status parameter with the following values:
0: Job not yet started or is still executing
1: Job executed without errors
Initial value: FALSE
ERROR Output BOOL I, Q, M, D, L Status parameter with the following values:
0: No error
1: Error occurred
Initial value: FALSE
STATUS Output WORD I, Q, M, D, L Status of the instruction
Initial value: 0
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
STATUS parameter
Error code*
(W#16#...)
Description
80F0 The communication module is an RS-485 module and no signals are available.
80F1 No signals are settable because H/W flow control is enabled.
80F2 The DSR signal cannot be set because the module is a DTE device.
80F3 The DTR signal cannot be set because the module is a DCE device.
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2499
You will find more detailed information on general error codes of the communication
instructions in: "General status information of the communications blocks (Page 2500)".
General status information of the communications blocks
General information on execution status of the communications blocks
The following table shows which general information can be output at the STATUS parameter
of the communications blocks:
Error code*
(W#16#....)
Description
8070 All internal instance memory is in use
8080 The identifier entered for the communications port is invalid
8081 Timeout, module error, internal error
8085 Error specifying the length at the LENGHT parameter. The specified length is "0" or greater than the
maximum permitted value.
8090 Message length invalid, module invalid, message invalid
8091 Incorrect version in parameterization message
8092 Invalid record length in parameterization message
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
USS
Overview of USS instructions
Introduction
The USS instructions control the operation of drives that support the universal serial interface
(USS). With the USS instructions, you can communicate with more than one drive via an
RS-485 connection.
To do this, you require a CM 1241 RS-485 communications module or a CB 1241 RS-485
communications board. Up to three CM 1241 RS-485 modules and one CB 1241 RS-485 board
can be installed in an S7-1200 CPU.
Each RS-485 port can operate up to sixteen drives.
The USS protocol uses a master/slave network for communication via a serial bus. The master
uses an address parameter to send a message to a selected slave. A slave itself can never
send without previously receiving a request. Direct exchange of messages between slaves is
not possible. USS communication works in half duplex mode.
The following figure shows an example of a USS network diagram:
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2500 System Manual, 01/2013,
S7-1200 CPU CM 1241
RS-485 modules
USS drives network 1
USS drives network 2
1 2 3 4 5 6 10 9 8 7 11 16 15 14 13 12
1 2 3 4 5
Requirements for using the USS protocol
General requirements for setting up a drive
The use of 4 PKW words must be set up for the drives.
The drives can be configured for 2, 4, 6 or 8 PZD words.
The number of PZD words in the drive must correspond to the PZD_LEN input of the
"USS_DRIVE (Page 2505)" instruction of the drive.
The baud rate of all drives must match the baud rate of the BAUD input parameter of the
"USS_PORT (Page 2504)" instruction.
The drive must be set up for remote control.
USS must be specified for the desired frequency value on the COM connection of the drive.
1 to 16 must be set as the drive address. This address must correspond to the address of
the DRIVE input parameter of the "USS_DRIVE (Page 2505)" instruction.
To control the direction of the drive, the polarity of the drive desired value must be set up.
The RS-485 network must be connected correctly.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2501
Definition: PKW / PZD area
The PKW area relates to the handling of the parameter-identifier-value interface.
The PKW interface is not a physical interface but describes a mechanism that controls the
exchange of parameters between two communications partners, in other words, reading
and writing parameter values, parameter descriptions and corresponding texts and the
handling of parameter changes due to spontaneous messages. All the tasks handled via
the PKW interface are essentially tasks for operator control and monitoring, service and
diagnostics.
The PZD area includes the signals required for automation:
Control word(s), and setpoint(s) from the master to the slave
Status word(s), and actual value(s) from the slave to the master.
Both areas together result in the user data field. This is transferred by the master to the slave
as a job frame or by the slave to the master as a reply frame.
Description
Each communication module CM 1241 RS485 supports a maximum of 16 drives. A single
instance data block contains temporary memory and buffer functions for all drives in the USS
network that are connected to a PtP communications module you installed. The USS
instructions for these drives have shared access to the information in this data block.
CM 1241 RS485
oder
CB 1241 RS485
USS_RPM
2
2
2
USS_WPM
1
4
5
6
7
8
9
10
11
12
13
15
14
16
USS_PORT
Drive 1
Drive 2
USS_DRV
DRlVE
DRlVE
DRlVE
3
Drive 2 data
USS_DRV_DB
USS_DRV_DB
USS_DRV_DB USS_DB
The communications
module supports up to
16 drives. Enter 1 to 16
as the box input for the
drive parameter.
The data block USS_DRV_DB is a
buffer that you can only access
indirectly via the USS operations.
Reserved for
PTP
COM data
50 bytes
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2502 System Manual, 01/2013,
All drives (max. 16) that are connected to an RS485 port are part of the same USS network.
All drives that are connected to a different RS485 port are part of a different USS network.
As the S7-1200 supports up to three CM 1241 RS485 modules, you can set up up to three
USS networks, each having a maximum of 16 drives, thus a total of 48 USS drives are
supported.
Each USS network is managed via a unique data block (three data blocks are required for
three USS networks with three CM 1241 RS485 modules). All instructions that belong to a
USS network must share this data block. This includes all "USS_DRIVE (Page 2505)",
"USS_PORT (Page 2504)", "USS_RPM (Page 2508)", and "USS_WPM (Page 2509)"
instructions for controlling all drives in a USS network.
The instruction "USS_DRIVE (Page 2505)" is a function block (FB). When you insert the
instruction "USS_DRIVE" in the editor, the "Call options" dialog will ask you to assign a DB
to the instruction.
If this is the first "USS_DRIVE" instruction in this program for this USS network, you can
accept the default DB assignment (or, if necessary, change the name) and the new DB
will be created.
If, however, this is not the first "USS_DRIVE" instruction for this network, you must select
the DB that was previously assigned to this USS network in the drop-down list in the
"Call options" dialog.
All "USS_PORT (Page 2504), USS_RPM (Page 2508)", and "USS_WPM (Page 2509)"
instructions are functions (FCs). When you insert these FCs in the editor, no DB is assigned.
Instead, you have to assign the DB in question to the USS_DB input of these instructions
(double-click on the parameter field and then on the icon to display the available DBs).
The instruction "USS_PORT (Page 2504)" controls communication between the CPU and
the drives via the PtP communications module. Whenever this instruction is called,
communication with a drive is processed. Your program must call this function quickly
enough so that the drives do not report a timeout. The instruction can be called from the
main program or any interrupt OB.
The function block "USS_DRIVE (Page 2505)" gives your program access to a specified
drive in the USS network. Its inputs and outputs correspond to the states and operating
functions of the drive. If there are 16 drives in the network, "USS_DRIVE" must be called
at least 16 times in your program, i.e., once for each drive. How quickly these blocks are
called depends on the required speed for controlling drive functions.
You can only call the instruction "USS_DRIVE" from the main program OB.
CAUTION
Call "USS_DRIVE", "USS_RPM", "USS_WPM" only from the main program OB. The
instruction "USS_PORT" can be called from any OB, it is usually called from a time-delay
interrupt OB. If the instruction "USS_PORT" is interrupted during execution, this may result
in unexpected errors.
The "USS_RPM" and "USS_WPM" instructions are used to read and write the operating
parameters of the drive. These parameters control the internal mode of operation of the drive.
A definition of these parameters can be found in the drive manual.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2503
Your program may also contain any number of these instructions; however only one read or
write request can be active for a drive. You may only call the instructions "USS_RPM" and
"USS_WPM" from the main program OB.
Calculating the time for communication with the drive
Communication with the drive is runs asynchronous to the cycle of the S7-1200. The S7-1200
runs through several cycles before communication with a drive is completed.
The interval of "USS_PORT" is the time required for a drive transaction. The following table
shows the minimum intervals for "USS_PORT" for each baud rate. Calling the "USS_PORT"
more frequently than the "USS_PORT" interval will not increase the number of transactions.
The timeout interval of the drive is the period of time available to a transaction if 3 attempts
are required to complete the transaction due to communications errors. By default, up to 2
further attempts are made for each transaction with the USS protocol.
Baud rate Calculated minimum interval for calling
USS_PORT (ms)
Drive message interval timeout per
drive (ms)
1200 790 2370
2400 405 1215
4800 212.5 638
9600 116.3 349
19200 68.2 205
38400 44.1 133
57600 36.1 109
115200 28.1 85
USS_PORT: Edit communication via USS network
Description
The "USS_PORT" instruction handles communication over the USS network. In the program,
use one "USS_PORT" instruction per PtP communications port to control the transmission to
or from one drive.
All USS instructions that are assigned to one USS network and one PtP communications port
must use the same instance data block.
Call
Your program must execute the "USS_PORT" instruction often enough to prevent timeouts in
the drive. You should therefore call the "USS_PORT" instruction from a cyclic interrupt OB to
prevent drive timeouts and keep the most recent USS data updates available for
"USS_DRIVE (Page 2505)" calls.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2504 System Manual, 01/2013,
Parameters
The following table shows the parameters of the "USS_PORT" instruction:
Parameter Declaration Data type Memory area Description
PORT Input PORT D, L or constant PtP communications port identifier
Constant that can be referenced within the
"Constants" tab of the default tag table.
BAUD Input DINT I, Q, M, D, L or
constant
Baud rate for USS communication.
USS_DB InOut USS_BASE D Reference to the instance DB of the "USS_DRIVE
(Page 2505)" instruction.
ERROR Output BOOL I, Q, M, D, L ERROR is set to TRUE if an error occurs. A
corresponding error code will be output at the
STATUS output.
STATUS
(Page 2510)
Output WORD I, Q, M, D, L Status value of the request. It indicates the result of
the cycle or initialization. Additional information is
available in the "USS_Extended_Error (Page 2510)"
tag for some status codes.
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
USS_DRIVE: Swap data with drive
Description
The "USS_DRIVE" instruction exchanges data with the drive by creating request messages
and interpreting the drive response messages. A separate instruction must be used for each
drive, but all USS instructions assigned to one USS network and one PtP communications
module must use the same instance data block. You must create the DB name when you place
the first "USS_DRIVE" instruction. Then reuse this DB that was created when the initial
instruction was inserted.
When the "USS_DRIVE" instruction is executed the first time, the drive indicated by the USS
address (parameter DRIVE) is initialized in the instance DB. After this initialization, subsequent
"USS_PORT (Page 2504)" instructions can start communication with the drive at this drive
number.
Changing the drive number requires a PLC STOP to RUN mode transition that initializes the
instance DB. Input parameters are configured in the USS send buffer, and outputs are read
from a "previous" valid response buffer if any exists. There is no data transmission during
execution of the "USS_DRIVE" instruction. Communication with the drives takes place when
"USS_PORT (Page 2504)" is executed. "USS_DRIVE" only configures the messages to be
sent and interprets data received in a previous request.
You can control the drive direction of rotation using either the DIR (BOOL) input or using the
sign (positive or negative) at the SPEED_SP (REAL) input. The following table explains how
these inputs work together to determine the drive direction, assuming the motor is wired for
forward rotation.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2505
SPEED_SP DIR Direction of rotation of drive
Value > 0 0 Reverse
Value > 0 1 Forward
Value < 0 0 Forward
Value < 0 1 Reverse
Parameters
Expand the box to display all the parameters by clicking the bottom of the box. The parameter
connections that are grayed are optional and do not need to be assigned.
The following table shows the parameters of the "USS_DRIVE" instruction:
Parameter Declaration Data type Memory area Description
RUN Input BOOL I, Q, M, D, L or
constant
Drive start bit: If this parameter has the value TRUE,
this input enables the drive to run at the preset speed.
OFF2 Input BOOL I, Q, M, D, L or
constant
"Electrical stop" bit: If this parameter has the value
FALSE, this bit cause the drive to coast to a stop
without braking.
OFF3 Input BOOL I, Q, M, D, L or
constant
Fast stop bit - If this parameter has the value FALSE,
this bit causes a fast stop by braking the drive.
F_ACK Input BOOL I, Q, M, D, L or
constant
Fault acknowledge bit - This bit resets the fault bit on
a drive. This bit is set after the fault is cleared to
indicate to the drive that it no longer needs to indicate
the previous fault.
DIR Input BOOL I, Q, M, D, L or
constant
Drive direction control - This bit is set to indicate that
the direction is forward (when SPEED_SP is positive).
DRIVE Input USINT I, Q, M, D, L or
constant
Drive address: This input is the address of the USS
drive. The valid range is drive 1 to drive 16.
PZD_LEN Input USINT I, Q, M, D, L or
constant
Word length - This is the number of words of PZD
data. Valid values are 2, 4, 6, or 8 words. The default
is 2.
SPEED_SP Input REAL I, Q, M, D, L or
constant
Speed setpoint - This is the speed of the drive as a
percentage of configured frequency. A positive value
specifies forward direction (when DIR has the value
TRUE).
CTRL3 Input WORD I, Q, M, D, L or
constant
Control word 3 - A value written to a user-configurable
parameter on the drive. The user must configure this
on the drive. Optional parameter
CTRL4 Input WORD I, Q, M, D, L or
constant
Control word 4 - A value written to a user-configurable
parameter on the drive. The user must configure this
on the drive. Optional parameter
CTRL5 Input WORD I, Q, M, D, L or
constant
Control word 5 - A value written to a user-configurable
parameter on the drive. The user must configure this
on the drive. Optional parameter
CTRL6 Input WORD I, Q, M, D, L or
constant
Control word 6 - A value written to a user-configurable
parameter on the drive. The user must configure this
on the drive.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2506 System Manual, 01/2013,
Parameter Declaration Data type Memory area Description
CTRL7 Input WORD I, Q, M, D, L or
constant
Control word 7 - A value written to a user-configurable
parameter on the drive. The user must configure this
on the drive. Optional parameter
CTRL8 Input WORD I, Q, M, D, L or
constant
Control word 8 - A value written to a user-configurable
parameter on the drive. The user must configure this
on the drive. Optional parameter
NDR Output BOOL I, Q, M, D, L New data ready - If this parameter has the value
TRUE, the bit indicates that the output contains data
from a new communication request.
ERROR Output BOOL I, Q, M, D, L Error occurred - If this parameter has the value TRUE,
this indicates that an error has occurred and the
STATUS output is valid. All other outputs are set to
zero on an error. Communication errors are only
reported at the ERROR and STATUS outputs of the
"USS_PORT" instruction.
STATUS
(Page 2510)
Output WORD I, Q, M, D, L Status value of the request. It indicates the result of
the cycle. This is not a status word returned from the
drive.
RUN_EN Output BOOL I, Q, M, D, L Run enabled - This bit indicates whether the drive is
running.
D_DIR Output BOOL I, Q, M, D, L Drive direction - This bit indicates whether the drive
is running forward.
INHIBIT Output BOOL I, Q, M, D, L Drive inhibited - This bit indicates the state of the
inhibit bit on the drive.
FAULT Output BOOL I, Q, M, D, L Drive fault - This bit indicates that the drive has
registered a fault. The user must eliminate the fault
and then set the F_ACK bit to clear this bit.
SPEED Output REAL I, Q, M, D, L Drive current speed (scaled value of drive status word
2) - The value of the speed of the drive as a
percentage of configured speed.
STATUS1 Output WORD I, Q, M, D, L Drive status word 1 - This value contains fixed status
bits of a drive.
STATUS3 Output WORD I, Q, M, D, L Drive status word 3 - This value contains a user-
configurable status word on the drive.
STATUS4 Output WORD I, Q, M, D, L Drive status word 4 - This value contains a user-
configurable status word on the drive.
STATUS5 Output WORD I, Q, M, D, L Drive status word 5 - This value contains a user-
configurable status word on the drive.
STATUS6 Output WORD I, Q, M, D, L Drive status word 6 - This value contains a user-
configurable status word on the drive.
STATUS7 Output WORD I, Q, M, D, L Drive status word 7 - This value contains a user-
configurable status word on the drive.
STATUS8 Output WORD I, Q, M, D, L Drive status word 8 - This value contains a user-
configurable status word on the drive.
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2507
USS_RPM: Readout parameters from the drive
Description
The "USS_RPM" instruction reads a parameter from the drive. All USS functions that are
assigned to one USS network and one PtP communications module must use the same
instance data block. "USS_RPM" must be called from the main program OB.
Parameter
The following table shows the parameters of the "USS_RPM" instruction:
Parameter Declaration Data type Memory area Description
REQ Input BOOL I, Q, M, D, L Send request: If this parameter has the value TRUE,
it indicates that a new read request is desired. This is
ignored if the request for this parameter is already
pending.
DRIVE Input USINT I, Q, M, D, L or
constant
Drive address: This input is the address of the USS
drive. The valid range is drive 1 to drive 16.
PARAM Input UINT I, Q, M, D, L or
constant
Parameter number: This input specifies which drive
parameter is written. The range of this parameter is 0
to 2047. See your drive manual for details on how to
access any parameters above this range.
INDEX Input UINT I, Q, M, D, L or
constant
Parameter index: This input specifies which drive
parameter index is to be written. This is a 16-bit value
where the least significant byte is the actual index
value with a range of (0 to 255). The most significant
byte may also be used by the drive and is drive-
specific. See your drive manual for additional
information.
USS_DB InOut USS_BASE D Reference to the instance DB that is created and
initialized when a "USS_DRIVE" instruction is
inserted in your program.
DONE Output BOOL I, Q, M, D, L If this parameter has the value TRUE, it indicates that
the VALUE output holds the previously requested
read parameter value.
This bit is set when the "USS_DRIVE" instruction
recognizes the read response from the drive.
This bit is reset when either:
you request the response data via another
"USS_RPM" poll
or
the second of the next two calls of "USS_DRIVE
(Page 2505)" is executed
ERROR Output BOOL I, Q, M, D, L Error occurred - If this parameter has the value TRUE,
this indicates that an error has occurred and the
STATUS output is valid. All other outputs are set to
zero on an error. Communication errors are only
reported at the ERROR and STATUS outputs of the
"USS_PORT (Page 2504)" instruction.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2508 System Manual, 01/2013,
Parameter Declaration Data type Memory area Description
STATUS
(Page 2510)
Output WORD I, Q, M, D, L This is the status value of the request. It indicates the
result of the read request. Additional information is
available in the "USS_Extended_Error (Page 2510)"
tag for some status codes.
VALUE Output VARIANT I, Q, M, D, L This is the value of the parameter that was read and
is valid only when the DONE bit has the value TRUE.
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
USS_WPM: Change parameters in the drive
Description
The "USS_WPM" instruction modifies a parameter in the drive. All USS functions that are
assigned to one USS network and one PtP communications module must use the same
instance data block. "USS_WPM" must be called from the main program OB.
Note
EEPROM write operations
Beware of overusing the EEPROM write operation. Minimize the number of EEPROM write
operations to extend the EEPROM life.
Parameter
The following table shows the parameters of the "USS_WPM" instruction:
Parameter Declaration Data type Memory area Description
REQ Input BOOL I, Q, M, D, L Send request: If this parameter has the value TRUE, it
indicates that a new write request is desired. This is
ignored if the request for this parameter is already
pending.
DRIVE Input USINT I, Q, M, D, L or
constant
Drive address: This input is the address of the USS
drive. The valid range is drive 1 to drive 16.
PARAM Input UINT I, Q, M, D, L or
constant
Parameter number: This input specifies which drive
parameter is written. The range of this parameter is 0 to
2047. See your drive manual for details on how to
access any parameters above this range.
INDEX Input UINT I, Q, M, D, L or
constant
Parameter index: This input specifies which drive
parameter index is to be written. This is a 16-bit value
where the least significant byte is the actual index value
with a range of (0 to 255). The most significant byte may
also be used by the drive and is drive-specific. See your
drive manual for additional information.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2509
Parameter Declaration Data type Memory area Description
EEPROM Input BOOL I, Q, M, D, L or
constant
Store to drive EEPROM: If this parameter has the value
TRUE, values written to the drive parameter will be
stored in the drive EEPROM. If this parameter has the
value FALSE, the value written is only temporarily saved
and will be lost the next time the drive is switched on.
VALUE Input VARIANT I, Q, M, D, L or
constant
The value of the parameter that is to be written. It must
be valid on the transition of REQ.
USS_DB InOut USS_BASE D This is a reference to the instance DB that is created
and initialized when a "USS_DRIVE (Page 2505)"
instruction is inserted in your program.
DONE Output BOOL I, Q, M, D, L If this parameter has the value TRUE, the VALUE input
was written to the drive.
This bit is set when the "USS_DRIVE (Page 2505)"
instruction recognizes the write response from the drive.
This bit is reset when either:
You request the drive's confirmation that the write
operation has been completed via another "USS_WPM"
query or when the second of the next two calls of
"USS_DRIVE (Page 2505)" is executed.
ERROR Output BOOL I, Q, M, D, L Error occurred: If this parameter has the value TRUE,
this indicates that an error has occurred and the
STATUS output is valid. All other outputs are set to zero
on an error. Communication errors are only reported at
the ERROR and STATUS outputs of the "USS_PORT
(Page 2504)" instruction.
STATUS
(Page 2510)
Output WORD I, Q, M, D, L This is the status value of the request. It indicates the
result of the write request. Additional information is
available in the "USS_Extended_Error (Page 2510)" tag
for some status codes.
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
Parameter STATUS of USS instructions
STATUS parameter
The following table contains the status codes of the USS operation that are output at the
STATUS output of the USS instructions:
STATUS*
(W#16#....)
Description
0000 No error
8180 The length of the drive response did not match the characters received from the drive. The drive number
where the error occurred is returned in the "USS_Extended_Error" tag. See the extended error description
below this table.
8181 The parameter VALUE is not of the data type WORD, REAL, or DWORD
8182 User supplied a parameter value of the type word and received a DWORD or REAL from the drive in the
response
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2510 System Manual, 01/2013,
STATUS*
(W#16#....)
Description
8183 User supplied a parameter value of the type DWORD or REAL and received a word from the drive in the
response
8184 Response telegram from drive had a bad checksum. The drive number where the error occurred is returned
in the "USS_Extended_Error" tag. See the extended error description below this table.
8185 Illegal drive address (valid drive address range: 1-16)
8186 Speed set point out of valid range (valid speed SP range: -200% to 200%)
8187 Wrong drive number responded to the request sent. The drive number where the error occurred is returned
in the "USS_Extended_Error" tag. See the extended error description below this table.
8188 Illegal PZD word length specified (valid range = 2, 4, 6 or 8 words)
8189 Illegal baud rate was specified
818A Parameter request channel is in use by another request for this drive
818B Drive has not responded to requests and retries. The drive number where the error occurred is returned in
the "USS_Extended_Error" tag. See the extended error description below this table.
818C Drive returned an extended error on a parameter request operation. See the extended error description
below this table.
818D Drive returned an invalid access error on a parameter request operation. See your drive manual for
information of why parameter access may be limited
818E Drive has not been initialized: This error code is output at "USS_RPM (Page 2508)" or "USS_WPM
(Page 2509)" if the "USS_DRIVE (Page 2505)" instruction has not been called at least once for this drive.
This prevents the initialization of the first cycle of "USS_DRIVE (Page 2505)" from overwriting a pending
parameter read or write request since it initializes the drive as a new entry. To eliminate this error, call the
"USS_DRIVE (Page 2505)" instruction for this drive.
80Ax-80Fx Specific errors returned from PtP (Point-to-Point) communication instructions called by the USS library:
These error code values are not modified by the USS library and are defined in the PtP instruction
descriptions.
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
USS_Extended_Error - USS drive extended error codes
USS drives support read and write access to a drives internal parameters. This feature allows
distributed control and configuration of the drive. Drive parameter access operations can fail
due to errors such as values out of range or invalid requests in a drives current mode. The
drive generates an error code that is output in the "USS_Extended_Error" variable in the
instance DB of the "USS_DRIVE (Page 2505)" instruction. This error code value is only valid
for the last execution of the "USS_RPM (Page 2508)" or "USS_WPM (Page 2509)" instruction.
The drive error code is put into the "USS_Extended_Error" tag when the value of STATUS is
hexadecimal 818C. The error code of "USS_Extended_Error" depends on the drive variant.
See the drive's manual for a description of the extended error codes for read and write
parameter operations.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2511
MODBUS
MB_COMM_LOAD: Configure port on the PtP module for Modbus RTU
Description
The "MB_COMM_LOAD" instruction configures a port for communication using the Modbus
RTU protocol. The following hardware can be used for this:
Up to three point-to-point modules (PtP) CM 1241 RS485 or CM 1241 RS232
A communications board CB 1241 RS485 in addition to this
After configuration of the port, you communicate over Modbus by executing the "MB_SLAVE"
or "MB_MASTER" instruction.
Call
"MB_COMM_LOAD" must be called once to configure the port for the Modbus RTU protocol.
On completion of the configuration, the port can be used by the "MB_MASTER (Page 2514)"
and "MB_SLAVE (Page 2522)" instructions.
"MB_COMM_LOAD" only needs to be called again if one of the communication parameters
has to be modified. Each "MB_COMM_LOAD" call deletes the communications buffer. To avoid
data loss during communication, you should not call the instruction unnecessarily.
One instance of "MB_COMM_LOAD" must be used to configure the port of each
communication module that is used for Modbus communication. You assign a unique
"MB_COMM_LOAD" instance data block for each port that you use. The S7-1200 CPU is
limited to three communication modules.
An instance data block is assigned when you insert the "MB_MASTER (Page 2514)" or
"MB_SLAVE (Page 2522)" instruction. This instance data block is referenced when you specify
the MB_DB parameter on the "MB_COMM_LOAD" instruction.
Parameters
The following table shows the parameters of the instruction "MB_COMM_LOAD":
Parameter Declaration Data type Memory area Description
REQ Input BOOL I, Q, M, D, L Execution of the instruction on a rising edge.
PORT Input PORT I, Q, M, D, L or
constant
ID of the communications port:
After you have inserted the communications
module in the device configuration, the port ID
appears in the drop-down list at the PORT box
connection. This constant can also be referenced
within the "Constants" tab of the tag table.
BAUD Input UDINT I, Q, M, D, L or
constant
Baud rate selection:
300, 600, 1200, 2400, 4800, 9600, 19200, 38400,
57600, 76800, 115200
All other values are invalid.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2512 System Manual, 01/2013,
Parameter Declaration Data type Memory area Description
PARITY Input UINT I, Q, M, D, L or
constant
Parity selection:
0 None
1 Odd
2 Even
FLOW_CTRL Input UINT I, Q, M, D, L or
constant
Flow control selection:
0 (default) No flow control
1 Hardware flow control with RTS always ON
(does not apply to RS485 ports)
2 - Hardware flow control with RTS switched
RTS_ON_DLY Input UINT I, Q, M, D, L or
constant
RTS on-delay selection:
0 (default) No delay of RTS active until the first
character of the message is transmitted.
1 to 65535 Delay in milliseconds of "RTS
active" until the first character of the message
is transmitted (does not apply to RS-485 ports).
RTS delays must be applied independent of the
FLOW_CTRL selection.
RTS_OFF_DLY Input UINT I, Q, M, D, L or
constant
RTS off-delay selection:
0 (default) No delay after the last character
transmitted until "RTS inactive"
1 to 65535 Delay in milliseconds after the last
character transmitted until "RTS inactive" (does
not apply to RS-485 ports). RTS delays must be
applied independent of the FLOW_CTRL
selection.
RESP_TO Input UINT I, Q, M, D, L or
constant
Response timeout:
Time in milliseconds allowed by "MB_MASTER
(Page 2514)" for the slave to respond. If the slave
does not respond in this time, "MB_MASTER
(Page 2514)" repeats the request or terminates the
request with an error if the specified number of
retries has been sent.
5 ms to 65535 ms (default = 1000 ms).
MB_DB Input MB_BASE D A reference to the instance data block of the
"MB_MASTER (Page 2514)" or "MB_SLAVE
(Page 2522)" instructions. After you insert
"MB_SLAVE (Page 2522)" or "MB_MASTER
(Page 2514)" in your program, the DB identifier
appears in the drop-down list at the MB_DB box
connection.
DONE Output BOOL I, Q, M, D, L Execution of instruction completed without error.
ERROR Output BOOL I, Q, M, D, L Error:
0 No error detected
1 Indicates that an error was detected. An
error code is output in the STATUS parameter.
STATUS Output WORD I, Q, M, D, L Port configuration error code
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2513
For additional information on valid data types, refer to "Overview of the valid data types
(Page 899)".
STATUS parameter
Error code*
(W#16#...)
Description
0000 No error
8180 Invalid value for the port ID (wrong address for the communications module).
8181 Invalid baud rate value.
8182 Invalid parity value.
8183 Invalid flow control value.
8184 Invalid value for the timeout of the response (the time before which a timeout is reported must be at least
25 ms).
8185 Incorrect pointer in the MB_DB parameter to the instance DB of the "MB_MASTER (Page 2514)" or
"MB_SLAVE (Page 2522)" instruction.
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
MB_MASTER: Communicate via the PtP port as Modbus master
Description of MB_MASTER
Description
The "MB_MASTER" instruction allows your program to communicate as a Modbus master
using a port on a point-to-point module (CM) or a communications board (CB). You can access
data in one or more Modbus slave devices.
Before the "MB_MASTER" instruction can communicate with a port, "MB_COMM_LOAD
(Page 2512)" must first execute.
An instance DB is created when you insert the "MB_MASTER" instruction in your program.
You specify this instance DB in the MB_DB input parameter of the "MB_COMM_LOAD
(Page 2512)" instruction.
Rules for Modbus master communication
A port used for Modbus master requests cannot be used for "MB_SLAVE".
A port can be used for one or more "MB_MASTER" calls if the same instance DB is used.
The Modbus instructions do not use communication interrupt events to control the
communication process. Your program must poll the "MB_MASTER" instruction for
completed send and receive operations.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2514 System Manual, 01/2013,
Calling the instruction:
Call the "MB_MASTER" instruction if possible in a cyclic program OB. The instruction
can only be called in a time delay or cyclic interrupt OB.
Do not call more than one "MB_MASTER" instruction in organization blocks with different
priority classes. If a "MB_MASTER" instruction executes "preemptively" from a higher
priority class, the instruction may execute incorrectly.
Do not call the "MB_MASTER" instruction in a startup, diagnostics or time error OB.
After a transfer has started, the EN parameter (LAD/FBD) must remain set to the value "1"
until the DONE or ERROR output parameter is set to "1" by the instruction. A renewed call
by the REQ parameter while the instruction is executing causes an error. After the
instruction executes, the bit in the REQ parameter remains set for the time specified by the
BLOCKED_PROC_TIMEOUT parameter in the instance DB.
If "MB_MASTER" sends a request to a slave, make sure that "MB_MASTER" continues to
execute until the response from the slave arrives.
Parameters
The following table shows the parameters of the "MB_MASTER" instruction:
Parameters Declaration Data type Memory area Description
REQ
(Page 2517)
Input BOOL I, Q, M, D, L Request input:
0 No request
1 Request to transmit data to Modbus slave(s)
MB_ADDR Input UINT I, Q, M, D, L or
constant
Modbus RTU station address:
Default address range: 0 to 247
Extended address range: 0 to 65535
The value "0" is reserved for broadcasting a message
to all Modbus slaves. Modbus function codes 05, 06, 15,
and 16 are the only function codes supported for
broadcast.
MODE
(Page 2517)
Input USINT I, Q, M, D, L or
constant
Mode selection: Specifies the type of request: Read,
write, or diagnostics:
Refer to the Modbus functions table for details.
DATA_ADDR
(Page 2517)
Input UDINT I, Q, M, D, L or
constant
Starting address in the slave: Specifies the starting
address of the data to be accessed in the Modbus slave.
You will find the valid addresses in the Modbus functions
table.
DATA_LEN Input UINT I, Q, M, D, L or
constant
Data length: Specifies the number of bits or words to be
accessed in this request. You will find the valid lengths
in the Modbus functions table.
DATA_PTR
(Page 2519)
Input VARIANT M, D Points to the DB or bit memory address of the CPU for
the data to be written or read. For a DB, this must be
created with the "Standard - compatible with
S7-300/400" access type.
DONE Output BOOL I, Q, M, D, L 0: Transaction not completed
1: Transaction completed without error
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2515
Parameters Declaration Data type Memory area Description
BUSY Output BOOL I, Q, M, D, L 0: No "MB_MASTER" transaction in progress
1: "MB_MASTER" transaction in progress
ERROR Output BOOL I, Q, M, D, L 0: No error
1: Error, the error code is indicated by the STATUS
parameter
STATUS Output WORD I, Q, M, D, L Execution condition code
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
STATUS parameter
Table 9-95 Communications and configuration error messages of the instruction
Error code*
(W#16#....)
Description
0000 No error
80C8 Slave timeout. Check the baud rate, parity and the connectors on the slave.
80D1 The receiver issued a flow control request to suspend an active transmission and never re-enabled the
transmission within the wait time.
This error is also generated during hardware flow control if the recipient does not detect CTS within the
wait time.
80D2 The send request was aborted because no DSR signal is received from the DCE.
80E0 The message was terminated because the receive buffer is full.
80E1 The message was terminated as a result of a parity error.
80E2 The message was terminated as a result of a framing error.
80E3 The message was terminated as a result of an overrun error.
80E4 The message was terminated as a result of the specified length exceeding the total buffer size.
8180 Invalid value for the port ID.
8186 Invalid Modbus station address
8188 The MODE parameter has an invalid value for a broadcast call.
8189 Invalid data address value.
818A Invalid data length value.
818B Invalid pointer to the local data source/destination: Size not correct
818C The DATA_PTR parameter has an invalid pointer. Use a pointer to a bit memory area or a DB with the
"Standard - compatible with S7-300/400" access type.
8200 Port is busy processing a send request
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2516 System Manual, 01/2013,
Table 9-96 Error messages of the Modbus protocol
Error code*
(W#16#....)
Response code of
slave
Description
8380 - CRC error
8381 01 Function code not supported
8382 03 Data length error
8383 02 Error in the data address or address outside the valid range of DATA_PTR
8384 > 03 Data value error
8385 03 Data diagnostic code value not supported (function code 08)
8386 - Function code of the response does not match the function code of the query.
8387 - Response from wrong slave
8388 - The response of the slave to a write call is not correct. The data sent by the slave
does not match the query from the master.
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
Parameter REQ
Description
REQ = FALSE: No request
REQ = TRUE: Request to transmit data to Modbus slave(s)
You must supply this input through a positive edge-triggered contact on the first call of
"MB_MASTER" execution. The edge-triggered pulse will invoke the transmission request once.
All inputs are captured and kept unchanged for the duration of a request and response triggered
by this input.
While an instance of the "MB_MASTER" executes, no further instance of the instruction can
be called. If there is a further instance call by the REQ parameter while "MB_MASTER" is
executing, no automatic follow-on call will be started. To be able to call the instance again, the
instruction must first be completed before it can be called again by the REQ parameter.
DATA_ADDR and MODE parameters
Description
You specify the start address for data access to the Modbus slave using the DATA_ADDR
parameter.
With the MODE parameter and the Modbus address, you specify the function code to be
transferred to the Modbus slave. The following table shows the relationship between the MODE
parameter, the function code and Modbus address range.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2517
MODE Modbus
function
Data length Operation and data Modbus address
0 01 1 to 2000
1 to 1992
(1)
Read output bits:
1 to (1992 or 2000) bits per query
1 to 9999
0 02 1 to 2000
1 to 1992
(1)
Read input bits:
1 to (1992 or 2000) bits per query
10001 to 19999
0 03 1 to 125
1 to 124
(1)
Read holding register:
1 to (124 or 125) WORD per query
40001 to 49999 or
400001 to 465535
0 04 1 to 125
1 to 124
(1)
Read input WORD:
1 to (124 or 125) WORD per query
30001 to 39999
1 05 1 Writing an output bit:
One bit per query
1 to 9999
1 06 1 Writing a holding register:
1 WORD per query
40001 to 49999 or
400001 to 465535
1 15 2 to 1968
2 to 1960
(1)
Writing multiple output bits:
2 to (1960 or 1968) bits per query
1 to 9999
1 16 2 to 123
2 to 122
(1)
Writing multiple holding registers:
2 to (122 or 123) WORD per query
40001 to 49999 or
400001 to 465535
2 15 1 to 1968
2 to 1960
(1)
Writing one or more output bits:
1 to (1960 or 1968) bits per query
1 to 9999
2 16 1 to 123
2 to 122
(1)
Writing one or more holding registers:
1 to (122 or 123) WORD per query
40001 to 49999 or
400001 to 465535
11 11 0 Reading out the communications status word of the
slaves and the event counter:
The status word indicates execution of the
instruction (0: is not executing; 0xFFFF: is
executing). The event counter is incremented each
time a message is transferred successfully.
The DATA_ADDR and DATA_LEN parameters of
the "MB_MASTER" instruction are ignored with this
function.
-
80 08 1 Checking the slave status by reading the error code
(0x0000):
1 WORD per query
-
81 08 1 Resetting the event counter of the slave with the
diagnostics code 0x000A:
1 WORD per query
-
3 to 10, 12
to 79, 82 to
2555
Reserved -
(1)
For the "Extended address range", the maximum data length is reduced by one byte or one WORD depending on which
data type is used for the function.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2518 System Manual, 01/2013,
Parameter DATA_PTR
Description
The DATA_PTR parameter is a pointer to a data block or bit memory from which the data
should be written or read. If you use a data block, create a global data block with the "Standard
- compatible with S7-300/400" access type.
Data block structures for the DATA_PTR parameter
These data types are valid for reading of words of Modbus addresses 30001 to 39999,
40001 to 49999, and 400001 to 465536 and also for writing of words to Modbus addresses
40001 to 49999 and 400001 to 465536.
Standard array of WORD, UINT, or INT data types (see below).
Named WORD, UINT, or INT structure where each element has a unique name and 16
bit data type.
Named complex structure where each element has a unique name and 16 bit or 32 bit
data type.
For reading and writing of bits of Modbus addresses 00001 to 09999 and 10001 to 19999.
Standard array of Boolean data types.
Named Boolean structure of uniquely named Boolean variables.
Although not required, it is recommended that each "MB_MASTER" instruction has its own
separate memory area in a global data block. The reason for this recommendation is that
there is a greater possibility of data corruption if multiple "MB_MASTER" instructions are
reading and writing the same area of a global data block.
The memory areas for DATA_PTR do not need to be in the same global data block. You
can create one data block with multiple areas for Modbus read operations, one data block
for Modbus write operations, or one data block for each slave station.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2519
Instance DB of the "MB_MASTER" instruction
Static variables of the instance DB
The following table describes the static variables of the instance DB of the instruction that you
can use in the user program.
Variable Data type Description
MB_STATE UINT Internal status of the Modbus instruction
BLOCKED_
PROC_TIMEOUT
REAL Time between completion of the instruction call and resetting the
ACTIVE bit in the instance DB. The time buffer is used to avoid
execution of the instruction being terminated before a job has been
sent completely. The default time is 500 ms.
EXTENDED_
ADDRESSING
BOOL Configuring addressing:
0: Default address area (1 byte)
1: Extended address area (2 bytes)
For additional information, refer to the section
EXTENDED_ADDRESSING: Instance DB of the "MB_SLAVE"
instruction (Page 2525)
Sample program for a Modbus master
Networks (LAD)
Network 1: Initialize parameters of the RS-485 module only once during the first cycle.
Network 2: Read 100 words from the holding register of the slave.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2520 System Manual, 01/2013,
Network 3: This is an optional network that displays the values of the first 3 words as soon as
the read operation has executed.
Network 4: Write 64 bits to the process image output, starting at slave address Q2.0.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2521
MB_SLAVE: Communicate via the PtP port as Modbus slave
Description of MB_SLAVE
Description
The "MB_SLAVE" instruction allows your program to communicate as a Modbus slave using
a port on a point-to-point module (PtP) or a communications board (CB). A Modbus RTU master
can issue a request and then your program responds via "MB_SLAVE" execution.
You must assign a unique instance data block when you insert the "MB_SLAVE" instruction
in your program. This instance data block is used when you specify it at the MB_DB parameter
of the "MB_COMM_LOAD (Page 2512)" instruction.
Modbus communication function codes (1, 2, 4, 5, and 15) can read and write bits and words
directly in the process image input and process image output in the target system. The following
table shows the mapping of Modbus addresses to the process image in the CPU.
Modbus functions of "MB_SLAVE" S7-1200
Codes Function Data area Address range Data area CPU address
01 Read bits Output 1 to 8192 Process image output Q0.0 to Q1023.7
02 Read bits Input 10001 to 18192 Process image input I0.0 to I1023.7
04 Read words Input 30001 to 30512 Process image input IW0 to IW1022
05 Write bit Output 1 to 8192 Process image output Q0.0 to Q1023.7
15 Write bits Output 1 to 8192 Process image output Q0.0 to Q1023.7
Modbus communication function codes (function codes 3, 6, 16) use a separate holding
register. To do this, you can use bit memory or a data block with the "Standard - compatible
with S7-300/400" access type.
You specify the type of the holding register using the MB_HOLD_REG parameter of the
MB_SLAVE instruction. The following table shows the mapping of the Modbus holding register
to the DB address of MB_HOLD_REG in the target system.
Modbus functions of "MB_SLAVE" S7-1200
Codes Function Data area Address range
(WORD number)
Address in the DB
(BYTE number)
Bit memory address
(BYTE number)
03 Read words Holding
register
40001 to 49999 or DW0 to DW19998 or MW0 to CPU limit
400001 to 465535 DW0 to DW131068
06 Write word Holding
register
40001 to 49999 or DW0 to DW19998 or
400001 to 465535 DW0 to DW131068
16 Write words Holding
register
40001 to 49999 or DW0 to DW19998 or
400001 to 465535 DW0 to DW131068
The table below shows the supported Modbus diagnostic functions.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2522 System Manual, 01/2013,
S7-1200 "MB_SLAVE" Modbus diagnostic functions
Codes Subfunction Description
08 0000H Return query data echo test: The "MB_SLAVE" instruction returns the echo of a received data
word to a Modbus master.
08 000AH Clear communication event counter: The "MB_SLAVE" instruction clears the communication
event counter that is used for Modbus function 11.
11 - Get communication event counter: The "MB_SLAVE" instruction uses an internal communication
event counter for recording the number of successful Modbus read and write requests that are
sent to the Modbus slave. The counter is not incremented on any Function 8, Function 11, or
broadcast requests. It is also not incremented on any requests that result in a communication
error (for example, parity or CRC errors).
The "MB_SLAVE" instruction supports broadcast write requests from Modbus masters as long
as the requests include access to valid addresses.
Regardless of the validity of a request, "MB_SLAVE" gives no response to a Modbus master
as the result of a broadcast request.
Rules of Modbus slave communication
"MB_COMM_LOAD" must be executed to configure a port, before the "MB_SLAVE"
instruction can communicate with this port.
If a port is to respond as a slave to a Modbus master, then that port cannot be used by
"MB_MASTER (Page 2514)". Only one instance of "MB_SLAVE" can be used with a given
port.
The Modbus instructions do not use communication interrupt events to control the
communication process. Your program must control the communication process by polling
the "MB_SLAVE" instruction for completed send and receive operations.
The "MB_SLAVE" instruction must be executed periodically at a rate that allows it to make
a timely response to incoming requests from a Modbus master. It is therefore advisable to
call the instruction in a cyclic program OB. Calling the "MB_SLAVE" instruction in an
interrupt OB is possible but not advisable since it can lead to long delays in execution.
Frequency of execution of "MB_SLAVE"
The "MB_SLAVE" instruction must be executed periodically to receive each request from the
Modbus master and to respond as required. The frequency of execution of "MB_SLAVE" is
dependent upon the specified response timeout period of the Modbus master. This is illustrated
in the following diagram.
Start
interval = 3.5 character times
Master sends
Response
delay time
Slave sends
Response
timeout period
Start
interval
ADR FC Data CRC
CRC
ADR
ADR FC Data CRC
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2523
The response timeout period is the amount of time a Modbus master waits for the start of a
response from a Modbus slave. This time period is not defined by the Modbus protocol, but
rather by a parameter of each Modbus master. The frequency of execution (time between one
execution and the next execution) of "MB_SLAVE" must be based on the particular parameters
of your Modbus master. As a minimum, you should execute "MB_SLAVE" twice within the
response timeout period of the Modbus master.
Parameters
The following table shows the parameters of the "MB_SLAVE" instruction:
Parameter Declaration Data type Memory area Description
MB_ADDR Input UINT I, Q, M, D, L or
constant
Station address of the Modbus slave
Default address range: 0 to 247
Extended address range: 0 to 65535
MB_HOLD_REG Input VARIANT D Pointer to the Modbus holding register DB. The DB
must be created with the "Standard - compatible
with S7-300/400" access type.
NDR Output BOOL I, Q, M, D, L New data ready:
0: No new data
1: Indicates that new data has been written by
the Modbus master
DR Output BOOL I, Q, M, D, L Read data:
0: No data read
1: Indicates that data has been read by the
Modbus master
ERROR Output BOOL I, Q, M, D, L 0: No error detected
1: Error, a corresponding error code is output in
the STATUS
STATUS Output WORD I, Q, M, D, L Error code
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
STATUS parameter
STATUS*
(W#16#....)
Description
80C8 The specified response timeout (refer to RCVTIME or MSGTIME) is "0".
80D1 The receiver issued a flow control request to suspend an active transmission and never re-enabled the
transmission within the wait time.
This error is also generated during hardware flow control if the recipient does not detect CTS within the
wait time.
80D2 The send request was aborted because no DSR signal is received from the DCE.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2524 System Manual, 01/2013,
STATUS*
(W#16#....)
Description
80E0 The message was terminated because the receive buffer is full
80E1 The message was terminated as a result of a parity error
80E2 The message was terminated as a result of a message frame error
80E3 The message was terminated as a result of a overrun error
80E4 The message was terminated as a result of the specified length exceeding the total buffer size
8180 Invalid value for the port ID.
8186 Invalid Modbus station address
8187 Invalid pointer to MB_HOLD_REG-DB
818C Pointer to a type safe DB type MB_HOLD_REG (must be a Classic DB type)
Response code sent to Modbus master (B#16#...)
8380 No response CRC error
8381 01 Function code not supported or not supported in a broadcast
8382 03 Data length error
8383 02 Error in the data address or address outside the valid range of MB_HOLD_REG
8384 03 Data value error
8385 03 Data diagnostic code value not supported (function code 08)
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
Instance DB of the "MB_SLAVE" instruction
Static variables of the instance DB
The following table describes the static variables of the instance DB of the instruction that you
can use in the user program. Your program can write values to the HR_Start_Offset and
Extended_Addressing variables and control the Modbus slave operations.
The other variables can be read to monitor the Modbus status.
Variable Data type Description
HR_Start_Offset WORD Start address of the Modbus holding register (default = " 0")
Extended_
Addressing
BOOL Configuring addressing:
0: Default address area (1 byte)
1: Extended address area (2 bytes)
Request_Count WORD Total number of queries received by the slave
Slave_Message_
Count
WORD Number of queries sent to this specific slave
Bad_CRC_Count WORD Number of received queries with CRC errors
Broadcast_Count WORD Number of received broadcast queries
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2525
Variable Data type Description
Exception_Count WORD Number of Modbus-specific errors that require the return of an
exception
Success_Count WORD The number of requests received for this specific slave without
protocol errors
HR_Start_Offset
The addresses of the Modbus holding register start at 40001 or 400001. These addresses
correspond to the start address of the holding register in the target system memory. Using the
HR_Start_Offset variable, you can set the offset to a different start address.
Example: A holding register starts at MW 100 and has a length of 100 WORD. With an offset
of 20 in the HR_Start_Offset parameter, the holding register begins at address 40021 instead
of 40001. Each address below 40021 and above 400119 causes an addressing error.
HR_Start_Offset = 0 HR_Start_Offset = 20
Modbus word
address
S7-1200 byte
address
Modbus word
address
S7-1200 byte
address
Minimum 40001 MW100 40021 MW100
Maximum 40099 MW198 40119 MW198
Extended_Addressing
To address the Modbus slave, a single byte (default address range) or a double byte (extended
address range) can be configured. Extended addressing is used to address more than 247
devices in a single network. If you decide on extended addressing, you can address a
maximum of 64,000 addresses. Below, you will see a frame of Modbus function 1 as an
example.
Table 9-97 Slave address with one byte (byte 0)
Function 1 Byte 0 Byte 1 Byte 2 Byte 3 Byte 4 Byte 5
Request Slave
address
F code Start address Length of the coils
Valid response Slave
address
F code Length Coil data
Error response Slave
address
0x81 E code
Table 9-98 Slave address with two bytes (byte 0 and byte 1)
Function 1 Byte 0 Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6
Request Slave address F code Start address Length of the coils
Valid response Slave address F code Length Coil data
Error response Slave address 0x81 F code
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2526 System Manual, 01/2013,
Sample program for a Modbus slave
Networks (LAD)
Network 1: Initialize parameters of the RS-485 module only once during the first cycle.
Network 2: Check the requests of the Modbus master in every cycle. 100 words starting at
MW1000 are configured for the Modbus holding register.
MODBUS TCP
MB_CLIENT: Communicating via PROFINET as a Modbus TCP client
Description of MB_CLIENT
Description
The "MB_CLIENT" instruction communicates as a Modbus TCP client via the PROFINET
connection of the S7-1200 CPU. To use the instruction, you do not require any additional
hardware module. With the "MB_CLIENT" instruction, you establish a connection between the
client and the server, send requests and receive responses and control connection termination
of the Modbus TCP server.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2527
Parameter
The following table shows the parameters of the "MB_CLIENT" instruction:
Parameter Declaration Data type Description
REQ (Page 2530) Input BOOL Communications request to the Modbus TCP server on a rising
edge.
DISCONNECT
(Page 2530)
Input BOOL With this parameter, you control the establishment and termination
of the connection to the Modbus server:
0: Establish a communications connection to the specified IP
address and port number.
1: Disconnect the communications connection. No other function
is executed during connection termination.
CONNECT_ID Input UINT Unique ID to identify the connection. Each instance of the
instructions "MB_CLIENT" and "MB_SERVER (Page 2534)" must
be assigned a unique connection ID.
IP_OCTET_1 Input USINT 1. Octet of the IP address* of the Modbus TCP server.
IP_OCTET_2 Input USINT 2. Octet of the IP address* of the Modbus TCP server.
IP_OCTET_3 Input USINT 3. Octet of the IP address* of the Modbus TCP server.
IP_OCTET_4 Input USINT 4. Octet of the IP address* of the Modbus TCP server.
IP_PORT Input UINT IP port number of the server to which the client establishes the
connection and communicates using the TCP/IP protocol (default
value: 502).
MB_MODE
(Page 2530)
Input USINT Selects of the mode of the request (read, write or diagnostics).
MB_DATA_ADDR
(Page 2530)
Input UDINT Start address of the data accessed by the "MB_CLIENT" instruction.
DATA_LEN Input UINT Data length: Number of bits or words for the data access (see
MB_MODE and MB_DATA_ADDR parameters - data length).
MB_DATA_PTR
(Page 2532)
InOut VARIANT Pointer to the Modbus data register: The register is a buffer for the
data received from the Modbus server or to be sent to the Modbus
server. The pointer must reference a data block or a memory area.
The number of bits addressed in the ANY pointer must be divisible
by 8.
DONE Out BOOL The bit at output parameter DONE is set to "1" as soon as the last
job is completed without errors.
BUSY Out BOOL 0: No "MB_CLIENT " job in progress
1: "MB_ CLIENT " job in progress
ERROR Out BOOL 0: No error
1: Error occurred. The cause of error is indicated by the STATUS
parameter.
STATUS
(Page 2533)
Out WORD Error code of the instruction.
* 8-bit long component of the 32-bit IPv4 IP address of the Modbus TCP server.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2528 System Manual, 01/2013,
For additional information on valid data types, refer to "Overview of the valid data types
(Page 899)".
Note
Consistent input data during an "MB_CLIENT" call
When a Modbus client calls a Modbus instruction, the status of the input parameters is stored
internally and then compared at the next call. The comparison is used to determine whether
this particular call initialized the current request. Several "MB_CLIENT" calls can be executed
if you use a common instance DB. The values of the input parameters must not be changed,
as long as an "MB_CLIENT" instance is executing. If the input parameters are changed during
execution, "MB_CLIENT" cannot be used to check whether or not the instance is currently
executing.
Multiple client connections
A Modbus TCP client can support several TCP connections and the maximum number of
connections depends on the CPU being used. The total number of connections of one CPU,
including those of the Modbus TCP clients and server must not exceed the maximum number
of supported connections. Modbus TCP connections can also be shared by client and/or server
connections.
With individual client connections, remember the following rules:
Each "MB_CLIENT" connection must use a unique instance DB.
For each "MB_CLIENT" connection, a unique server IP address must be specified.
Each "MB_CLIENT" connection requires a unique connection ID.
The relevant individual connection ID must be used for each individual instance DB of the
instruction. The connection ID and instance DB belong together in pairs and must be unique
for each connection.
Unique numbers for the IP Ports may or may not be required depending on the server
configuration.
Static variables of the instruction
The following table describes the editable static variables of the instance data block of the
"MB_CLIENT" instruction.
Tag Data type Start value Description
Blocked_Proc_Timeo
ut
REAL 3.0 Wait time in seconds before the static tag ACTIVE is reset if there
is a blocked Modbus instance. This can, for example, occur if a client
request is output and the execution of the client function aborts
before the request was fully executed. The maximum wait time is 55
seconds.
MB_Transaction_ID WORD 1 Transaction ID of the Modbus TCP protocol. The start value of "1"
should only be changed if the Modbus TCP server requires a
different value.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2529
Tag Data type Start value Description
MB_Unit_ID WORD 65535 Unit ID of the Modbus protocol. The tag corresponds to the slave
address of the Modbus RTU protocol. Change this value only if the
Modbus TCP server can be used and as a gateway and is controlled
by the application program within the Modbus server.
RCV_TIMEOUT REAL 2.0 Time interval in seconds in which the "MB_CLIENT" instruction waits
for a response from the server.
Connected BOOL 0 Indicates whether the connection to the assigned client has been
established or not: 1 = connected, 0 = not connected.
See also
MB_CLIENT example 1: Send several requests via a TCP connection (Page 2538)
MB_CLIENT example 2: Send multiple requests via several TCP connections (Page 2539)
MB_CLIENT example 3: Coordinate several requests (Page 2540)
REQ and DISCONNECT parameters
Description
If no instance of the "MB_CLIENT" instruction is executing and if the value of the DISCONNECT
parameter is "0", a new job executes on a rising edge of the REQ parameter. If there is not yet
a connection, this is established during execution.
If the same instance of the "MB_CLIENT" instruction executes again (DISCONNECT = 0 and
REQ = 1), before the active job was executed, this is not executed on completion of the active
job. A new job can only be started on completion of the active job (REQ = 1).
You can monitor the status of execution with the DONE parameter. You can use this to monitor
the status of execution if the "MB_CLIENT" instruction is executed sequentially.
See also
Description of MB_CLIENT (Page 2527)
MB_MODE and MB_DATA_ADDR parameters
Description
Instead of a function code, the "MB_CLIENT" instruction uses the MB_MODE parameter. The
MB_DATA_ADDR parameter is used to specify the Modbus start address of the data you want
to access. The combination of the parameters MB_MODE and MB_DATA_ADDRdefines the
function code used in the current Modbus message.
The following table shows the relationship between the MB_MODE parameter, the Modbus
function and the address space.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2530 System Manual, 01/2013,
MB_MODE Modbus
function
Data length Function and data type MB_DATA_ADDR
0 01 1 to 2000 Read output bits:
1 to 2000 bits per call
1 to 9999
0 02 1 to 2000 Read input bits:
1 to 2000 bits per call
10001 to 19999
0 03 1 to 125 Read holding register:
1 to 125 WORD per call
40001 to 49999
0 04 1 to 125 Read input words:
1 to 125 WORD per call
30001 to 39999
1 05 1 Write an output bit:
One bit per call
1 to 9999
1 06 1 Write a holding register:
1 WORD per call
40001 to 49999
1 15 2 to 1968 Write multiple output bits:
2 to 1968 bits per call
1 to 9999
1 16 2 to 123 Write several holding registers:
2 to 123 WORD per call
40001 to 49999
2 15 1 to 1968 Write one or more output bits:
1 to 1968 bits per call
1 to 9999
2 16 1 to 123 Write one or more holding registers:
1 to 123 WORD per call
40001 to 49999
11 11 0 Read status word and event counter of server
communication:
The status word reflects the the processing status (0
- not processing, 0xFFFF - processing).
The event counter is incremented each time a
message is sent successfully.
The MB_DATA_ADDR and MB_DATA_LEN parameters
of the "MB_CLIENT" instruction are not evaluated when
this function executes.
-
80 08 1 Check the server status with the error code 0x0000
(return loop test - the server sends the request back):
1 WORD per call
-
81 08 1 Reset the event counter of the server with the error code
0x000A:
1 WORD per call
3 to 10,
12 to 79,
82 to 255
Reserved
See also
Description of MB_CLIENT (Page 2527)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2531
MB_DATA_PTR parameter
Description
The MB_DATA_PTR parameter is a pointer to a data buffer for storing the data read from or
written to the Modbus server. As the data buffer, you can use a global data block or a memory
area (M).
For a buffer in the memory area (M), use a pointer in the ANY format as follows: "P#bit address"
"data type" "length" (example: P#M1000.0 WORD 500).
The MB_DATA_PTR parameter uses a communications buffer:
For the communication functions of the "MB_CLIENT" instruction:
Reading and writing of 1 bit of data of the Modbus server addresses 00001 to 09999
and 10001 to 19999.
Reading of 16-bit WORD data of the Modbus server addresses 30001 to 39999 and
40001 to 49999.
Writing 16-bit WORD data of the Modbus server addresses 40001 to 49999.
During data transmission (length: bit or WORD) from or to the global DB or the memory
area (M) that you assigned with the MB_DATA_PTR parameter.
If you use a data block for the buffer in the MB_DATA_PTR parameter, you will need to assign
data types to the DB elements.
Use the 1-bit data type BOOL for a Modbus bit address
Use a 16-bit data type such as WORD, UINT, INT or REAL for a Modbus WORD address.
Use a 32-bit data type (double word) such as DWORD, DINT or REAL for two Modbus
WORD addresses.
With MB_DATA_PTR, you can also access complex DB elements such as:
Standard arrays
Structures with unique element names
Complex structures with unique naming of the elements and data type lengths of 16 or
32 bits.
The data areas for the MB_DATA_PTR parameter can also be in different global data blocks
(or in different memory areas). You can, for example, use a data block for the the read jobs
and another one for the write jobs or a separate data block for each "MB_CLIENT" station.
See also
Description of MB_CLIENT (Page 2527)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2532 System Manual, 01/2013,
Parameter STATUS
STATUS parameter (protocol error)
STATUS
(W#16#)
Code of the response to the
Modbus client (B#16#)
Description
8381 01 Function code is not supported.
8382 03 Error in data length.
8383 02 Error in the data address or access outside the address area of
MB_DATA_PTR (Page 2532).
8384 03 Error in data value.
8385 03 Error codes of diagnostics not supported (function code 08).
STATUS parameter (parameter error)
In addition to the errors listed in the following table, errors are also possible with the
"MB_CLIENT" instruction caused by the communications instructions ("TCON", "TDISCON",
"TSEND" and "TRCV").
STATUS
(W#16#)
Description
80C8 No response of the server in the defined period. Check the connection to the Modbus server. This error is
only reported on completion of the configured repeated attempts.
If the "MB_CLIENT" instruction does not receive an answer with the originally transferred transaction ID
(MB_Transaction_ID variable) within the defined period, this error code is output.
8188 The MB_MODE parameter has an invalid value.
818A Invalid data length at the MB_DATA_LEN parameter.
818B The MB_DATA_PTR parameter has an invalid pointer. You should also check the values of the
MB_DATA_ADDR (Page 2530) and MB_DATA_LEN parameters.
818C The MB_DATA_PTR (Page 2532) pointer references an an optimized data block. Either use a data block
with standard access or a memory area
8200 A further Modbus request is currently being processed via the port.
8380 Received block of transferred Modbus data is not well-formed or too few bytes were received
8387 The assigned connection ID is different from that used for previous requests. Only one connection ID
can be used for each instance DB of the "MB_CLIENT" instruction.
The error code is also output when the ID of the Modbus TCP protocol received by the server is not "0".
8388 The Modbus server sent a different data length than was requested. This error occurs only when using the
Modbus functions 15 or 16.
See also
Description of MB_CLIENT (Page 2527)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2533
MB_SERVER: Communicating via PROFINET as a Modbus TCP server
Description of MB_SERVER
Description
The "MB_SERVER" instruction communicates as a Modbus TCP server via the PROFINET
connection of the S7-1200 CPU. To use the instruction, you do not require any additional
hardware module. The "MB_SERVER" instruction processes connection requests of a Modbus
TCP client, receives requests from Modbus functions and sends responses.
Parameters
The following table shows the parameters of the "MB_SERVER" instruction:
Parameters Declaration Data type Description
DISCONNECT Input BOOL The "MB_SERVER" instruction is used to enter into a passive connection
with a partner module. The server reacts to a TCP connection request
from every requesting IP address.
0: Passive communication connection can be initialized
1: Initialization of the connection termination. You can use this
parameter to control when a connection request accepted. If the input
to this parameter is set, no other operations are executed.
CONNECT_ID Input UINT The parameter uniquely identifies a connection within the CPU. Each
individual instance of the instructions "MB_CLIENT (Page 2527)" and
"MB_SERVER" must have a unique CONNECT_ID parameter.
IP_PORT Input UINT Start value = 502. The number of IP Ports defines which IP port is
monitored for connection requests of the Modbus client.
These TCP port numbers must not be used for the passive connection
of the "MB_SERVER" instruction: 20, 21, 25, 80, 102, 123, 5001, 34962,
34963 and 34964.
MB_HOLD_REG
(Page 2537)
InOut VARIANT Pointer to the Modbus holding register of the "MB_SERVER" instruction:
As the holding register, use either a global data block with standard
access or a memory area (M). The holding register contains the values
that may be accessed by a Modbus client using the Modbus functions 3
(read), 6 (write) and 16 (read).
NDR Output BOOL "New Data Ready":
0: No new data
1: New data written by the Modbus client written
DR Output BOOL "Data Read":
0: No data read
1: Data read by the Modbus client
ERROR Output BOOL If an error occurs during the call of the "MB_SERVER" instruction, the
output of the ERROR parameter is set to TRUE. Detailed information
about the cause of the problem is indicated by the STATUS parameter.
STATUS
(Page 2538)
Output WORD Error code of the instruction.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2534 System Manual, 01/2013,
For additional information on valid data types, refer to "Overview of the valid data types
(Page 899)".
Mapping of Modbus addresses to the process image
The "MB_SERVER" instruction allows incoming Modbus functions (1, 2, 4, 5 and 15) direct
read and write access to the process image input and output of the S7-1200 CPU (use of the
data types BOOL and WORD).
For the data transfer of the function codes 3, 6 and 16, the holding register (MB_HOLD_REG
parameter) must be defined longer than one byte. The following table shows the mapping of
the Modbus addresses to the process image of the CPU.
Modbus function S7-1200
Code Function Data area Address space Data area CPU address
01 Read: Bits Output 1 to 8192 Process image output Q0.0 to Q1023.7
02 Read: Bits Input 10001 to 18192 Process image input I0.0 to I1023.7
04 Read: WORD Input 30001 to 30512 Process image input IW0 to IW1022
05 Write: Bits Output 1 to 8192 Process image output Q0.0 to Q1023.7
15 Write: Bits Output 1 to 8192 Process image output Q0.0 to Q1023.7
Incoming Modbus messages with the function codes 3, 6 and 16 write to or read from the
Modbus holding registers (you specify the holding registers with the MB_HOLD_REG
parameter).
Multiple server connections
You can create multiple Server connections. This allows a single CPU to establish connections
to more than one Modbus TCP client at the same time.
A Modbus TCP server can support several TCP connections and the maximum number of
connections depends on the CPU being used.
The total number of connections of one CPU, including those of the Modbus TCP clients and
server must not exceed the maximum number of supported connections.
Modbus TCP connections can also be shared by client and/or server connections.
In the case of Server connections, remember the following rules:
Each "MB_SERVER" connection must use a unique instance DB.
Each "MB_SERVER" connection must be created with a unique IP port number. Only one
connection is supported for each port.
Each "MB_SERVER" connection must use a unique connection ID.
The relevant individual connection ID must be used for each individual instance DB of the
instruction. The connection ID and instance DB belong together in pairs and must be unique
for each connection.
For each connection, the "MB_SERVER" instruction must be called individually.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2535
Modbus diagnostics functions
The table below contains a description of the Modbus diagnostics functions.
Code Subfunction Description
08 0x0000 Echo test: The "MB_SERVER" instruction receives a data word and returns this unchanged to
the Modbus master.
08 0x000A Reset event counter: The "MB_SERVER" instruction resets the event counter for communication
that is used for Modbus function 11.
11 - Fetch event counter of the communication: The "MB_SERVER" instruction uses an internal event
counter for communication to record the number of successfully executed read and write
requests sent to the Modbus server.
The event counter is not incremented by the functions 8, 11 or broadcast requests. The same
applies to requests that result in a communications error (for example parity errors or CRC
errors). The broadcast function is not available for Modbus TCP because only one client/server
connection can exist at any one time.
Static variables of the instruction
The following table describes the static variables of the instance data block of the
"MB_SERVER" instruction used in the program. You can write the HR_Start_Offset tag. You
can read the other variables to monitor the Modbus status.
Tag Data type Start value Description
HR_Start_Offset WORD 0 Assign the start address of the Modbus holding register.
Request_Count WORD 0 Total number of requests received by the server
Server_Message_
Count
WORD 0 Total number of received messages for the relevant Server.
Xmt_Rcv_Count WORD 0 Counter for detecting the number of transfers during which an error
occurred. The counter is also incremented if an invalid Modbus message
is received.
Exception_Count WORD 0 Counter for detecting the number of errors specifically for Modbus cause
an exception.
Success_Count WORD 0 Counter for detecting the number of requests that contain no error in the
transferred protocol.
Connected BOOL 0 Indicates whether the connection to the assigned client has been
established or not: 1 = connected, 0 = not connected.
Example: Addressing via static tag HR_Start_Offset
The addresses of the Modbus holding register start at 40001. These addresses correspond to
the address space of the CPU memory area for the holding register. You can also define the
HR_Start_Offset tag so that the Modbus holding register has a start address other than 40001.
Example: The holding register begins at MW100, and has a length of 100 WORD. An offset
value in the HR_Start_Offset parameter means that the start address of the holding register is
moved from 40001 to 40021. Whenever the holding register is addressed below the address
40021 and above the address 40119, this causes an error.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2536 System Manual, 01/2013,
HR_Start_Offset Address Minimum Maximum
0 Modbus address (WORD) 40001 40099
S7-1200 address MW100 MW298
20 Modbus address (WORD) 40021 40119
S7-1200 address MW100 MW298
See also
MB_SERVER example: Multiple TCP connections (Page 2541)
MB_HOLD_REG parameter
Description
The MB_HOLD_REG parameter is a pointer to a data buffer for storing the data read from or
written to the Modbus server. As the data buffer, you can use a global data block or a memory
area (M).
As pointer to a buffer in the memory area (M), use the ANY format as follows: "P#bit address"
"data type" "length" (example: P#M1000.0 WORD 500).
The following table shows examples of mapping Modbus addresses to the holding register for
the Modbus functions 3 (read WORD), 6 (write WORD) and 16 (write several WORD). The
upper limit for the number of addresses in the data block is decided by the maximum work
memory of the CPU. If you use a memory area, the upper limit for the addresses is decided
by the size of the memory area of the CPU.
Modbus
addresses
MB_HOLD_REG parameter - examples
P#M100.0
WORD 5
P#DB10.DBx0.0 WORD 5 "Recipe".ingredient
40001 MW100 DB10.DBW0 "Recipe".ingredient[1]
40002 MW102 DB10.DBW2 "Recipe".ingredient[2]
40003 MW104 DB10.DBW4 "Recipe".ingredient[3]
40004 MW106 DB10.DBW6 "Recipe".ingredient[4]
40005 MW108 DB10.DBW8 "Recipe".ingredient[5]
See also
Description of MB_SERVER (Page 2534)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2537
Parameter STATUS
Description
In addition to the errors listed in the following table, errors are also possible with the
"MB_CLIENT" instruction caused by the communications instructions ("TCON", "TDISCON",
"TSEND" and "TRCV").
STATUS*
(W#16#)
Code of the response to
the Modbus server
(B#16#)
Description
8187 No response The MB_HOLD_REG parameter has an invalid pointer. Data area is too small.
818C No response The MB_HOLD_REG parameter references an an optimized data block.
Either use a data block with standard access or a memory area
Error due to timeout of execution (more than 55 seconds).
8381 01 Function code is not supported.
8382 03 Error in data length
8383 02 Error in data address or access outside the address area of the holding register
(MB_HOLD_REG (Page 2537) parameter).
8384 03 Error in data value
8385 03 Value of the diagnostic code is not supported (only with function code 08).
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
See also
Description of MB_SERVER (Page 2534)
Examples
MB_CLIENT example 1: Send several requests via a TCP connection
Description
Several requests of the Modbus Client can be sent via a TCP connection. To do this, use the
same instance DB, the same connection ID and the same port number.
Only one client can be active at any one time. After processing of a client has been completed,
the next client is processed. The order of execution must be defined in the program.
In the following sample program, the value of the STATUS output parameter is also copied.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2538 System Manual, 01/2013,
Network 1: Modbus function 1 - 16 read output bits
Network 2: Modbus function 2 - 32 read input bits
MB_CLIENT example 2: Send multiple requests via several TCP connections
Description
Requests from the Modbus client can be sent via different TCP connections. If you require
this, use a different instance DB and a different connection ID.
Use a different port number, if the connections are to the same Modbus server. If the
connections are to different Modbus servers, you can freely assign the port number.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2539
Network 1: Modbus function 4 - read input (WORD)
Network 2: Modbus function 3 - read holding register (WORD)
MB_CLIENT example 3: Coordinate several requests
Description
Make sure that the individual Modbus requests are executed. You control coordination of
requests with the program. The following example demonstrates how the output parameters
of the first and second client request can be used to coordinate execution of the instructions.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2540 System Manual, 01/2013,
Network 1: Modbus function 3 - read holding register (WORD)
Network 2: Modbus function 3 - read holding register (WORD)
MB_SERVER example: Multiple TCP connections
Description
You can use several Modbus TCP server connections. To do this, the "MB_SERVER"
instruction must be called independently for each connection.
Every connection requires the following:
An independent instance data block of the instruction
A unique connection ID
A separate IP port (on the S7-1200, only one connection is permitted per IP port)
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2541
To optimize the performance "MB_SERVER" should be executed once per program cycle for
each connection.
Network 1: Connection #1 with associated IP port connection ID and instance DB
Network 2: Connection #1 with associated IP port connection ID and instance DB
9.8.5.5 TeleService
TM_MAIL: Transfer email
Description of TM_MAIL
Description
The "TM_MAIL" instruction works asynchronously, in other words, its execution extends over
multiple calls. You must specify an instance when you call the instruction "TM_MAIL". The
attribute "retentive" may not be set in the instance. This attribute ensures that the instance is
initialized when the CPU switches from STOP to RUN and that a new e-mail send job can be
triggered afterwards.
You start the sending of an e-mail with an edge change from "0" to "1" for the REQ parameter.
The job status is indicated by the output parameters BUSY , "DONE", "ERROR", "STATUS"
and "SFC_STATUS". "SFC_STATUS" corresponds in this case to the "STATUS" output
parameter of the called communication blocks.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2542 System Manual, 01/2013,
The output parameters DONE, ERROR, STATUS, and SFC_STATUS are each displayed for
only one cycle if the status of the BUSY output parameter changes from "1" to "0". The following
table shows the relationship between BUSY, DONE, and ERROR. Using this table, you can
determine the current status of the instruction "TM_MAILand when the sending of the e-mail
is complete.
DONE BUSY ERROR Description
0 1 0 The job is being processed.
1 0 0 Job successfully completed.
0 0 1 The job ended with an error. The cause of the error can be found in the STATUS and
SFC_STATUS parameters.
0 0 0 The "TM_MAIL" instruction was not assigned a (new) job.
If the CPU changes to STOP mode while "TM_MAIL" is active, the communication connection
to the mail server aborts. The communication connection to the mail server will also be lost if
communication problems occur on the Industrial Ethernet bus. In this case, the transfer of the
e-mail will be interrupted and it will not reach its recipient.
NOTICE
Changing user programs
You can change the parts of your user program that directly affect calls of "TM_MAIL" only:
when the CPU is in "STOP" mode or
when no mail is being sent (REQ = 0 and BUSY = 0).
This relates, in particular, to deleting and replacing program blocks that contain "TM_MAIL"
calls or calls for the instance of "TM_MAIL".
Ignoring this restriction can tie up connection resources. The automation system can change
to an undefined status for the TPC/IP communication functions via Industrial Ethernet.
A warm or cold restart of the CPU is required after the changes are transferred.
Data consistency
The ADDR_MAIL_SERVER input parameter of the instruction is taken from the "TM_MAIL"
instruction again each time the sending of an e-mail is triggered. If a change is made during
operation, the "new" value only becomes effective once an e-mail is triggered again.
In contrast, the WATCH_DOG_TIME, TO_S, CC, FROM, SUBJECT, TEXT, ATTACHMENT,
and, if applicable, USERNAME and PASSWORD parameters are taken from the "TM_MAIL"
instruction while it is running, which means that they may only be changed after the job is
complete (BUSY = 0)
Setting the parameters of the TS Adapter IE
On the TS Adapter IE, you need to specify parameters for outgoing calls in such a way as to
enable the TS Adapter IE to establish a connection to the dial-up server of your service
provider.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2543
If you set "When required" for connection establishment, the connection will only be established
when an e-mail needs to be sent.
Connection establishment can take longer (approx. one minute) for an analog modem
connection. When you specify the WATCH_DOG_TIME parameter, remember to allow for the
time required to establish the connection.
Parameters
The following table shows the parameters of the "TM_MAIL" instruction:
Parameter Declaration Data type Memory area Description
REQ Input BOOL I, Q, M, D, L or
constant
Control parameter REQUEST: Activates the sending
of an e-mail on a rising edge.
ID Input CONN_OU
C (Word)
D, L or constant Reference to the connection to be established. See
ID parameter of the TCON (Page 2427), TDISCON
(Page 2430), TSEND (Page 2432), and TRCV
(Page 2435) instructions. A number that is not used
for any additional instances of this instruction in the
user program must be entered here.
TO_S
(Page 2546)
Input STRING D Input parameter for receiver addresses:
STRING with a maximum length of 240 characters
(see example call).
CC (Page 2546) Input STRING D Input parameter for CC recipient addresses
(optional): STRING with a maximum length of 240
characters (see example call).
If an empty string is assigned here, the e-mail is not
sent to a CC recipient.
SUBJECT Input STRING D Input parameter for subject of the e-mail:
STRING with a maximum length of 240 characters.
TEXT Input STRING D Input parameter for text of the e-mail (optional):
Reference to a data string with a maximum length of
240 characters.
If an empty string is assigned at this parameter, the
e-mail is sent without text.
ATTACHMENT Input VARIANT I, Q, M, D, L Input parameter for e-mail attachment (optional):
Reference to a byte/word/double word field with a
maximum length of 65534 bytes.
If no value is assigned, the e-mail is sent without an
attachment.
DONE Output BOOL I, Q, M, D, L DONE = 0: Job not yet started or still executing.
DONE = 1: Job was executed without errors.
BUSY Output BOOL I, Q, M, D, L BUSY = 1: E-mail transmission is not yet complete.
BUSY=0: The processing of "TM_MAIL" was
stopped.
ERROR Output BOOL I, Q, M, D, L ERROR=1: An error occurred during processing.
STATUS and SFC_STATUS supply detailed
information about the type of error.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2544 System Manual, 01/2013,
Parameter Declaration Data type Memory area Description
STATUS
(Page 2547)
Output WORD I, Q, M, D, L Output/status parameter STATUS:
Return value or error information of the "TM_MAIL"
instruction.
ADDR_MAIL_S
ERVER
Static* DWORD I, Q, M, D, L IP address input parameter of the mail server: Specify
as a data word in HEX format, for example: IP address
= 192.168.0.200.
ADDR_MAIL_SERVER = DW#16#C0A800C8,
where:
192 = 16#C0,
168 =16#A8
0 = 16#00 and
200 = 16#C8.
WATCH_DOG_
TIME
Static* TIME I, Q, M, D, L Input parameter for max. period of time:
The "TM_MAIL" instruction should establish a
connection within the period specified by
WATCH_DOG_TIME. The block is exited with an
error if this period is exceeded. The time before the
block is exited and the error is output can exceed the
WATCH_DOG_TIME because connection
termination also takes a certain amount of time. To
begin with, you should set a period of 2 minutes. If
you have an ISDN telephone connection, a
significantly shorter period can be selected.
USERNAME Static* STRING D Input parameter for user name:
STRING with a maximum length of 180 characters. A
user name is an absolute requirement for
authentication.
PASSWORD Static* STRING D Input parameter for password:
STRING with a maximum length of 180 characters. A
password is an absolute requirement for
authentication.
FROM
(Page 2546)
Static* STRING D Input parameter for sender address:
STRING with a maximum length of 240 characters
(see example call).
SFC_STATUS
(Page 2547)
Static* WORD I, Q, M, D, L Output/status parameter "SFC_STATUS":
Error information of the called communication blocks.
*The values of the parameter are not modified at every call of the instruction "TM_MAIL". The values are in the static
parameters of the instance and are only written once at the first call of the instruction.
You will find more detailed information on valid data types in "Overview of the valid data
types (Page 899)".
Note
Optional parameters
The optional parameters CC, TEXT, and ATTACHMENT are only sent with the e-mail if the
corresponding parameters contain a string of length > 0.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2545
SMTP authentication
Authentication refers here to a procedure for ensuring an identity, for example, by a password
query.
The "TM_MAIL" instruction supports the SMTP authentication procedure AUTH-LOGIN that
is requested by most mail servers. For information about the authentication procedure of your
mail server, please refer to your mail server manual or the website of your Internet service
provider.
To use the AUTH-LOGIN authentication procedure, the "TM_MAIL" instruction requires the
user name with which it can log onto the mail server. This user name corresponds to the user
name with which you set up a mail account on your mail server. It is made available to the
"TM_MAIL" instruction in the USERNAME parameter.
To log on, the "TM_MAIL" instruction also requires the associated password. This password
corresponds to the password you specified when you set up your mail account. It is made
available to the "TM_MAIL" instruction in the PASSWORD parameter.
The user name and the password are each transferred to the mail server unencrypted
(BASE64-coded).
If no user name is specified in the DB, the AUTH-LOGIN authentication procedure is not used.
The e-mail is then sent without authentication.
Parameters TO_S, CC, and FROM
Description
The TO_S, CC, and FROM parameters are strings with, for example, the following content:
TO: <wenna@mydomain.com>, <ruby@mydomain.com>,
CC: <admin@mydomain.com>, <judy@mydomain.com>,
FROM: <admin@mydomain.com>
Note the following rules when entering the parameters:
The "TO:", "CC:", and "FROM:" characters must be entered.
A space and an opening pointed bracket "<" must be entered before each address.
A closing pointed bracket ">" must be entered after each address.
A comma must be entered after each address in TO and CC.
Only one e-mail may be entered in FROM, and there must not be a comma at the end of
this address
Because of runtime and memory space, the "TM_MAIL" instruction does not perform any
syntax check of the parameters TO_S, CC and FROM.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2546 System Manual, 01/2013,
STATUS and SFB_STATUS parameters
Description
The return values of the "TM_MAIL" instruction can be classified as follows:
W#16#0000: "TM_MAIL" was completed successfully
W#16#7xxx: Status of "TM_MAIL"
W#16#8xxx: An error was reported during the internal call of a communication block or from
the mail server.
The following table shows the return values of "TM_MAIL" except for error codes of the
internally called communication blocks.
Return value
STATUS*
(W#16#...):
Return value
SFB_STATUS
(W#16#...):
Explanation Notes
0000 - The processing of "TM_MAIL" was
completed without errors.
A error-free completion of "TM_MAIL"
does not mean that the sent e-mail will
necessarily arrive (see below - note on
point 1)
7001 "TM_MAIL" is active (BUSY = 1). Initial call; job has started
7002 7002 "TM_MAIL" is active (BUSY = 1). Intermediate call; job already active
8xxx xxxx The processing of "TM_MAIL" was
completed with an error code of the internally
called communication instructions.
For detailed information on the
evaluation of the SFB_STATUS
parameter, please refer to the
descriptions of the STATUS parameter
of the communication instructions.
8010 xxxx Error during connection establishment. For further information on the
evaluation of the SFB_STATUS
parameter, please refer to the
descriptions of the STATUS parameter
of the "TCON (Page 2427)" instruction.
8011 xxxx Error sending the data. For further information on the
evaluation of SFB_STATUS, please
refer to the descriptions of the STATUS
parameter of the "TSEND (Page 2432)"
instruction.
8012 xxxx Error receiving the data. For further information on the
evaluation of SFB_STATUS, please
refer to the descriptions of the STATUS
parameter of the "TRCV (Page 2435)"
instruction.
8013 xxxx Error during connection establishment. For further information on the
evaluation of SFB_STATUS, please
refer to the descriptions of the STATUS
parameter of the "TCON (Page 2427)"
and "TDISCON (Page 2430)"
instructions.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2547
Return value
STATUS*
(W#16#...):
Return value
SFB_STATUS
(W#16#...):
Explanation Notes
8014 - Establishment of a connection is not possible. You have possibly entered an incorrect
mail server IP address
(ADDR_MAIL_SERVER) or a time
span that is too short
(WATCH_DOG_TIME) to establish the
connection. It is also possible that the
CPU has no connection to the network
or that the CPU configuration is
incorrect.
82xx, 84xx, or
85xx
- The error message originates from the mail
server and corresponds, except for the "8", to
the error number of the SMTP protocol.
The following columns list several error
codes that can occur:
See point 2 in the note.
8450 - Action not executed: Mailbox not available/
not reachable.
Try again later.
8451 - Action aborted: Local processing error Try again later.
8500 - Syntax error: Error not recognized. This also
includes the error when a command string is
too long. This can also be occur when the e-
mail server does not support the LOGIN
authentication procedure.
Check the parameters of "TM_MAIL".
Try to send an e-mail without
authentication. To do this, replace the
USERNAME parameter with an empty
string.
8501 - Syntax error: Parameter or argument
incorrect
You have possibly entered an incorrect
address in TO_S or CC.
8502 - Command unknown or not implemented. Check your entries, in particular the
FROM parameter. This is possibly
incomplete and you have forgotten "@"
or ".".
8535 - SMTP authentication incomplete. You have possibly entered an incorrect
user name or incorrect password.
8550 - Mail server cannot be reached, you have no
access rights.
You have possibly entered an incorrect
user name or password, or the mail
server does not support your LOGIN.
Another cause of error could be an
incorrect entry of the domain name
after the "@" in TO_S or CC.
8552 - Action aborted: Assigned memory size has
been exceeded
Try again later.
8554 - Transmission failed. Try again later.
* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
Programming the PLC
9.8 References
STEP 7 Basic V12.0
2548 System Manual, 01/2013,
Note
Status error
1. An incorrect entry of the recipient addresses does not generate a status error of the
"TM_MAIL" instruction. In this case, there is no guarantee that the e-mail will be sent to
other recipients, even if these were entered correctly.
2. You will find more detailed information on the SMTP error code and other error codes in
SMTP protocol on the Internet or in the error documentation of the mail server. You can
also view the most recent message from the mail server in your instance DB in the
BUFFER1 parameter. If you look under "Data", you will find the data most recently sent
by the "TM_MAIL" instruction.
Programming the PLC
9.8 References
STEP 7 Basic V12.0
System Manual, 01/2013, 2549
Visualizing processes (Basic)
10
10.1 Creating screens
10.1.1 Basics
10.1.1.1 Screen basics
Introduction
In WinCC you create screens that an operator can use to control and monitor machines and
plants. When you create your screens, the object templates included support you in visualizing
processes, creating images of your plant, and defining process values.
Application example
The figure shows a screen that was created in WinCC. With the help of this screen, the operator
can operate and monitor the mixing station of a fruit juice manufacturing system. Fruit juice
base is supplied from various tanks to a mixing unit. The screen indicates the fill level of the
tanks.
Tanks
Mixer
Screen design
Insert an object you need to represent a process into your screen. Configure the object to
correspond to the requirements of your process.
A screen may consist of static and dynamic elements.
STEP 7 Basic V12.0
System Manual, 01/2013, 2551
Static elements such as text or graphic objects do not change their status in runtime. The
tank labels (W, K, Z, A) shown in this example of a mixing unit are static elements.
Dynamic elements change their status based on the process. Visual current process values
as follows:
From the memory of the PLC
From the memory of the HMI device in the form of alphanumeric displays, trends and
bars.
Input fields on the HMI device are also considered dynamic objects. The fill level values of
the tanks in our example of a mixing plant are dynamic objects.
Process values and operator inputs are exchanged between the controller and the HMI device
via tags.
Screen properties
The screen layout is determined by the features of the HMI device you are configuring. It
corresponds with the layout of the user interface of this device. The screen properties such as
the screen resolution, fonts and colors are also determined by the characteristics of the
selected HMI device. If the set HMI device has function keys, the screen shows these function
keys.
A function key is a key on the HMI device. You can assign one or several functions in WinCC.
These functions are triggered when the operator presses the relevant key on the HMI device.
A function key can be assigned global or local functions.
Global function keys always trigger the same action, regardless of the currently displayed
screen.
Function keys with local assignment trigger different actions, based on the currently
displayed screen on the operator station. This assignment applies only to the screen in
which you have defined the function key.
Opening screens
In order for the operator to be able to call a screen in runtime, you must integrate each
configured screen in the operating process. You have various options of configuring these
functions:
You use the "Screen" editor to configure buttons and function keys for opening other
screens.
You use the "Global Screen" editor to configure globally assigned function keys.
10.1.1.2 Device-specific functional scope of screens
Introduction
The functions of an HMI device determine the display of the device in WinCC and the scope
of functions of the editors.
The following screen properties are determined by the functions of the selected HMI device:
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2552 System Manual, 01/2013,
Device layout
Screen resolution
Number of colors
Fonts
Objects available
Device layout
The device layout of a screen forms the image of the HMI device in your configuration. The
device layout of the screen shows all the function keys available on the HMI device, for
example.
Screen resolution
The screen resolution is determined by the different display dimensions of the various operator
panels. You can only change the screen resolution if you configure the
"WinCC Runtime Advanced" or "WinCC Runtime Professional" HMI device.
Number of colors
You can assign colors to the screen objects. The number of possible colors is determined by
the color depth and specific colors supported on the selected HMI device.
Fonts
You can customize the appearance of the texts in all the screen objects that contain static or
dynamic text. How to highlight individual texts in a screen. Select the font, font style and size,
and set additional effects such as underscoring, for example.
The settings for the text markups such as font style and effects always refer to the entire text
of a screen object. That is, you can display the complete title in bold format, but not its individual
characters or words, for example.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2553
Objects available
Some of the screen objects can not be configured globally for all HMI devices. These screen
objects are not displayed in the "Tools" task card. For a KTP 1000 touch panel unit you can
not configure a slider, for example.
10.1.1.3 Basics
Task cards
Introduction
The following task cards are available in the "Screens" editor:
Tools: Display and operating objects
Animations: Templates for dynamic configuration
Layout: Aid for customizing the display
Libraries: Administration of the project library and of the global libraries
Note
WinCC Basic
The "Animations" task card is not available in WinCC Basic.
Tools
The "Tools" task card contains objects in different panes:
Basic objects
Elements
Controls
User controls (optional)
Graphics
You paste objects from the palettes into your screens by drag&drop or a double click. The
objects available for selection are determined by the features of the HMI device you are
configuring. The following icons are used to change the display mode:
Icon Meaning
Displays the objects as a list.
Displays the objects as a graphic.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2554 System Manual, 01/2013,
Animations
The "Animations" task card contains the possible dynamizations of a screen object in the
palettes. You paste the animations to a screen object by drag&drop or a double click from the
"Movements", "Display" and "Tag Binding" palettes.
Layout
The "Layout" task card contains the following panes for displaying objects and elements:
Layers: Serves to manage screen object layers The layers are displayed in a tree view and
contain information about the active layer and the visibility of all layers.
Grid: You specify whether you want to align the objects to a grid or to other objects and set
the grid size for a grid.
Objects out of range: Objects that lie outside the visible area are displayed with name,
position and type.
Libraries
The "Libraries" task card show the following libraries in separate panes:
Project library: The project library is stored together with the project.
Global library: The global library is stored in a separate file in the specified path on your
configuration PC.
Move view
Introduction
To display only a section of the entire screen in the work area, use the icon of the "Screens"
editor:
Requirement
A screen is open.
The view shows only a screen section.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2555
Procedure
To move the view:
1. Click the icon at the bottom right corner of the work area and press the left mouse button.
A miniature view of the full screen is shown. An orange frame shows the currently selected
area.
2. Hold down the mouse button and drag the frame to the desired area.
Note
The screen is scrolled when you drag a screen object from the visible to a currently hidden
section.
Zooming the view
Introduction
To view a small screen section in closer detail, use the zoom tool to magnify the screen in the
working area. The maximum zoom amounts to 800%.
You can zoom with the toolbar in the work area or with the "Layout > Zoom" task card.
There are different ways to increase the screen, for example, with the zoom factor or by
adapting the work area to the height of the screen.
Requirement
The screen is opened.
Procedure
Proceed as follows to zoom a view with the selection frame:
1. Click the toolbar button.
2. Use the mouse to draw a selection frame in the screen.
After you have released the mouse button, the section enclosed by the selection frame is
zoomed to fit the complete work area.
Alternatively, use the slider in the lower right-hand corner of the screen.
Result
The selected screen section is magnified.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2556 System Manual, 01/2013,
10.1.1.4 Working with screens
Steps
Steps
To create screens, you need to take the following initial steps:
Plan the structure of the process visualization: Number of screens and their layout
Example: Subprocesses are visualized in separate screens, and merged in a master screen.
Define your screen navigation control strategies.
Adapt the templates and the global screen.
You define objects centrally and assign function keys for example.
Create the screens. Use the following options of efficient screen creation:
Working with libraries
Working with layers
Working with faceplates
Creating a new screen
Introduction
Create screens to display processes in your system.
Requirement
The project has been created.
The Inspector window is open.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2557
Procedure
1. Double-click "Screens > Add New Screen" in the project navigation.
The screen is generated in the project and appears in your view. The screen properties are
shown in the Inspector window.
2. Enter a meaningful name for the screen.
3. Configure the screen properties in the Inspector window:
Specify whether and on which template the screen is based.
Set the "Background Color" and the "Screen Number."
Specify a documenting text under "Tooltip".
Specify the layers to be displayed under "Layers" in the engineering system.
Select dynamic screen update under "Animations."
Select "Events" to define which functions you want to execute in Runtime when you call
and exit the screen or at other events.
Note
Not all HMI devices support the "Visibility" animation.
Result
You created the screen in your project. You can now paste objects and control elements from
the "Tools" task card and assign function keys in further work steps.
Managing Screens
Introduction
You can move screens within a project to other groups, or copy, rename, and delete them.
Moving screens in a group
1. Select the "Screens" folder in the project tree.
2. Select the "Add group" command from the shortcut menu.
A folder called "Group_x" is inserted.
3. Select the screen in the project tree.
4. Drag-and-drop the screen to the required group.
The screen is moved into this group.
Copy screen
1. Select the screen in the project tree.
2. Select the "Copy" command in the shortcut menu to copy the screen to the clipboard.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2558 System Manual, 01/2013,
3. In the project tree, select the screen insert position.
4. Select "Paste" from the shortcut menu to insert the screen.
A copy of the screen is inserted. A consecutive number is appended to the name of the
original in the copy.
Alternatively, press <Ctrl> while you drag the screen to the required position.
Note
If you copy a screen with interconnected template for several devices and projects, the
template will also be copied. Any existing matching template is not used. This holds
particularly true when you copy the screens with drag-and-drop.
Rename screen
1. Select the screen in the project tree.
2. Select "Rename" from the shortcut menu.
3. Type in a new name.
4. Press <Enter>.
As an option, use the <F2> function key to rename the screen.
Delete screen
1. Select the screen in the project tree.
2. Select "Delete" from the shortcut menu.
The screen and all its objects are deleted from the current project.
Defining the start screen of the project
Introduction
The start screen is the initial screen opened at the start of project in Runtime. You can define
a different start screen for each one of the HMI devices. Beginning at this start screen, the
operator calls the other screens.
Requirement
The project contains the screen you want to use as the start screen.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2559
Procedure
1. Double-click "Runtime settings > General" in the project tree.
2. Select the desired screen as "Start screen."
Alternatively select a screen in the project tree and select "Use as start screen" in the shortcut
menu.
Result
The start screen opens on the HMI at the start of Runtime.
10.1.1.5 Working with Templates
Basics on working with templates
Introduction
Configure the objects in a template which are to be displayed in all screens based on this
template.
Note the following rules:
A screen must not be based on a template.
A screen is only based on one template.
You can create several templates for one device.
A template cannot be based on another template.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2560 System Manual, 01/2013,
Objects for a template
You determine functions and objects in the template which are to apply for all screens based
on this template:
Assignment of function keys: You also assign the function keys in the template for HMI
devices with function keys. This assignment overwrites a possible global assignment.
Permanent window: Some devices support a permanent window for all screens in the top
area of the screen. In contrast to the template, the permanent window occupies an area of
the screen for itself alone.
Operator controls: You can paste all screen objects which you also use for a screen into a
template.
Application examples
You want to assign the ActivateScreen" function to a function key in the template. The
operator uses this key to switch to another screen in runtime. This configuration applies to
all screens that are based on this template.
A graphic with your company logo can be added to the template. The logo appears on all
screens that are based on this template.
Note
If an object from the template has the same position as an object in the screen, the
template object is covered.
See also
Creating a new template (Page 2563)
Managing templates (Page 2564)
Global screen (Page 2561)
Using a template in the screen (Page 2565)
Global screen
Introduction
You define global elements for all screens of an HMI device independently of the used
template.
Function keys
For HMI devices with function keys you assign the function keys globally in the "Global Screen"
editor. This global assignment applies for all screens of the HMI device.
Proceed as follows to assign function keys locally in screens or templates:
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2561
1. Click the function key in your screens or templates.
2. Deactivate "Properties > Properties > General > Use Global Assignment" in the inspection
window.
Indicator and control objects for alarms
The "Alarm window" and "Alarm indicator" objects that are available as global objects are
configured within the "Global screen" editor.
The "Alarm window" and "Alarm indicator" are always shown in the foreground.
For Comfort Panels you also have the possibility of configuring a "System diagnostic view" in
the global screen.
Note
If you have configured a permanent window in a template, do not position the alarm window
and alarm indicator in the area of the permanent window. Otherwise, the alarm window and
the alarm indicator will not be displayed in Runtime.
The permanent window is not visible in the "Global screen" editor.
Order of configuration of screens
The following order applies for the configuration:
The global screen comes before screens and templates
Screens come before templates
Screen
System
Global screen
Screen
Template
Layer
Layer
Layer
31 0
31 0
31 0
The system layer is not configurable. This contains
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2562 System Manual, 01/2013,
input dialog boxes
alarms from the operating system
the direct keys for touch panels
See also
Basics on working with templates (Page 2560)
Creating a new template
Introduction
In a template, you can centrally modify objects and function keys. Changes to an object or of
a function key assignment in the template are applied to the object in all the screens which
are based on this template.
Note
HMI device dependency
Function keys are not available on all HMI devices.
Requirement
The project has been created.
The Inspector window is open.
Procedure
1. Select "Screen management > Templates" in the project tree and then double-click "Add
new template".
The template is created in the project, and appears in your view.
The properties of the template are displayed in the Inspector window.
2. Define the name of the template under "Properties > Properties > General" in the Inspector
window.
3. Specify the layers in the engineering system that are displayed under "Properties
>Properties >Layers" in the Inspector window.
4. Add the necessary objects from the "Tools" task card.
5. Configure the function keys.
Result
The template is created in your project.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2563
See also
Basics on working with templates (Page 2560)
Managing templates
Introduction
You can move, copy, rename, and delete templates within a project in the Project window.
Moving a template into a group
1. Select the templates in the project navigation "Screen management > Templates".
2. Select "Add group" in the shortcut menu.
A folder called "Group_x" is inserted.
3. Select the template in the project navigation.
4. Drag-and-drop the template to the required group.
The template is moved to this group.
Copying templates
1. Select the template in the project navigation.
2. Select "Copy" in the shortcut menu.
3. Select the position in the project navigation where you want to paste the template.
4. Select "Paste" from the shortcut menu to insert the template.
A unique name is assigned automatically to the copy.
Alternatively, you can hold down the <Ctrl> key, and drag the template into position.
Deleting a template
1. In the project navigation, select the template to be deleted.
2. Select "Delete" in the shortcut menu.
The template, and all its objects are deleted from the current project.
Assigning a template to a screen
1. In the project navigation, select the screen to which you want to assign the template.
2. In the Inspector window, select "Properties > Properties > General".
3. Select the desired template under "Template."
The selected template and all the objects contained in it are assigned to the screen.
See also
Basics on working with templates (Page 2560)
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2564 System Manual, 01/2013,
Using a template in the screen
Introduction
You use a template in the screen. All the objects configured in the template are also available
in the screen.
Requirement
A template has been created.
A screen has been created.
Procedure
Proceed as follows to use a template in a screen:
1. Double click a screen in the project tree. The screen opens in the work area.
2. Open "Properties > Properties > General" in the inspector window.
3. Select a template that is to be applied to the screen under "Template".
Show template in screen
When you edit a screen, you can show an existing template in the screen.
Proceed as follows to show a template in the screen:
1. Activate "Extras > Settings > Visualization > Show template in screens" in the menu.
Result
The screen is based on the selected template. All objects which you have configured in the
template are available in the screen. The template is displayed in the screen.
See also
Basics on working with templates (Page 2560)
10.1.2 Working with objects
10.1.2.1 Overview of objects
Introduction
Objects are graphics elements which you use to design the screens of your project.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2565
The "Tools" task card contains all objects that can be used for the HMI device. Display the
Task Card with menu command "View" by activating the "Task Card" option.
The toolbox contains various palettes, depending on the currently active editor. If the "Screens"
editor is open, the toolbox contains the following palettes:
"Basic objects"
The basic objects include basic graphic objects such as "Line", "Circle", "Text field" or
"Graphic view".
"Elements"
The elements include basic control elements, e.g. "I/O field", "Button" or "Gauge".
"Controls"
The controls provide advanced functions. They also represent process operations
dynamically, for example Trend view and Recipe view.
"Graphics"
Graphics are broken down into subjects in the form of a directory tree structure. The various
folders contain the following graphic illustrations:
Machine and plant areas
Measuring equipment
Control elements
Flags
Buildings
You can create links to your own graphic folders. The external graphics are located in these
folders and subfolders. They are displayed in the toolbox and incorporated into the project
using links.
"Libraries" task card
In addition to the display and operating elements, the library objects are available. They
are located within the palettes of the "Libraries" task card. A library contains preconfigured
objects such as graphics of pipes, pumps, or preconfigured buttons. You can also integrate
multiple instances of library objects into your project without having to reconfigure them.
The WinCC software package includes libraries, e.g. "HMI Buttons & Switches".
You can also store customized objects, and faceplates in user libraries.
Faceplates are objects that you create from existing screen objects, and for which you
define the configurable properties.
Note
HMI device dependency
Some of the toolbox objects are either available with restricted functionality, or not at all.
This depends on the HMI device you are configuring. Unavailable properties of an object
are displayed as deactivated, and cannot be selected.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2566 System Manual, 01/2013,
Basic objects
Icon Object Instructions
"Line" -
"Ellipsis" -
"Circle" -
"Rectangle" -
"Text field" One or more lines of text. The font and layout are adjustable.
"Graphic view" Displays graphics from external graphic programs, and inserts OLE
objects. The following graphic formats can be used: "*.emf", "*.wmf",
"*.dib", "*.bmp", "*.jpg", "*.jpeg", "*.gif" and "*.tif".
Elements
Icon Object Instructions
"I/O field" Outputs the values of a tag, and/or writes values to a tag.
You can define limits for the tag values shown in the I/O field. To
hide the operator input in Runtime, activate "Hidden input."
"Button" Executes a list of functions, or a script as configured.
"Symbolic I/O field" Outputs the values of a tag, and/or writes values to a tag. A text from
a text list is displayed in relation to the tag value.
"Graphic I/O field" Outputs the values of a tag, and/or writes values to a tag. A graphic
from a graphics list is displayed in relation to the tag value.
"Date/time field" Outputs the system date and time, or the time and date from a tag.
This allows the operator to enter new values. The display format is
adjustable.
"Bar" The bar represents a value from the PLC in the form of a scaled bar
graph.
"Switch" Toggles between two defined states. You can label a switch with
text, or a graphic.
Controls
Icon Object Description
"Alarm view" Shows currently pending alarms or alarm events from
the alarm buffer or alarm log.
"Trend view" Represents multiple curves with values from the PLC,
or from a log.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2567
Icon Object Description
"User view" Allows an administrator to administer users on the HMI
device.
It also allows an operator without administrator rights
to change his password.
"Recipe view" Displays data records, and allows them to be edited.
See also
Options for Editing Objects (Page 2568)
Inserting an object (Page 2569)
Deleting an Object (Page 2571)
Positioning an object (Page 2572)
Resizing an object (Page 2573)
Selecting multiple objects (Page 2574)
Aligning objects (Page 2576)
Moving an object forward or backward (Page 2578)
Show objects outside the screen area (Page 2579)
Rotating objects (Page 2580)
Flipping objects (Page 2581)
Inserting multiple objects of the same type (stamping tool) (Page 2582)
Repositioning and resizing multiple objects (Page 2584)
External graphics (Page 2584)
Managing external graphics (Page 2585)
Storing an external image in the graphics library. (Page 2587)
Basics on groups (Page 2589)
Overview of keyboard access (Page 2595)
Example: Inserting and configuring a rectangle (Page 2598)
10.1.2.2 Options for Editing Objects
Introduction
Objects are graphics elements which you use to design the screens of your project.
You have the following options for editing objects:
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2568 System Manual, 01/2013,
Copying, pasting or deleting objects using the shortcut menu If you copy an object in a
screen and the screen already includes an object of the same name, the name of the object
is changed.
Maintaining the standard size of the objects you are inserting or customizing their size on
insertion.
Changing the properties of an object, e.g. the size
Positioning an object
Moving an object in front of or behind other objects
Rotating objects
Mirroring objects
Changing default properties of the objects
Defining the tab sequence for objects
Stamping: Inserting several objects of the same type
Selecting several objects simultaneously
Repositioning and resizing multiple objects
You can assign external graphics to objects, e.g. in the Graphic View.
You can view only the images you have previously stored in the graphic browser of your
WinCC project.
You can save graphics in the graphic browser:
Via drag & drop from the "Graphics" object group to the working area
As graphic files in the following formats: *.bmp, *.dib, *.ico, *.emf, *.wmf, *.gif, *.tif, *.jpeg
or *.jpg
As an OLE object
You either create a new OLE object or save an existing graphic file as an OLE object.
To save an OLE object, an OLE-compatible graphics program must be installed on the
configuration computer.
See also
Overview of objects (Page 2565)
10.1.2.3 Inserting an object
Introduction
In the "Screens" or "Reports" editor, insert the objects to the "Toolbox" task card. Use the
mouse to drag the objects into the work area. You either keep the objects in their original size,
or scale them up or down when you paste them.
In addition, you can copy or move objects via the clipboard from one editor to another, for
example to transfer a screen object to a report. Alternatively, you can also use the mouse
instead of the clipboard for copying and moving:
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2569
Copying: <Ctrl + Drag&Drop>
Moving: Drag&drop
Note
Basic Panels
The "Reports" editor is not available for Basic Panels.
Requirement
The "Tools" task card is open.
Inserting objects in their standard size
1. In the "Toolbox" task card, select the desired graphic object or the desired graphic in the
WinCC graphics folder.
When you move the cursor across the work area, it turns into a crosshair with an appended
object icon.
2. Click the location in the work area where you want to insert the object or graphic.
The object is inserted with its standard size at the desired position in the work area.
Alternatively, double-click the object in the "Toolbox" task card.
Copying an object
1. Select the desired object.
2. Select "Copy" in the shortcut menu.
3. Click the desired location and select "Paste" in the shortcut menu.
WinCC inserts a copy of the object at the desired location. You can only change the properties
that are appropriate for the relevant context.
Example: In the "Screens" editor, you can set for I/O fields and the mode for input and output.
In the "Reports" editor, the mode is set to "Output".
Original and copy are not interconnected and are configured independently from one another.
Inserting lines
1. Select the desired graphic object in the "Tools" task card.
2. Click on a location in the work area. A line in the standard size is inserted.
Inserting a polygon or polyline
1. Select the desired object "Polyline" or "Polygon" in the "Tools" task card.
2. Click on a location in the work area. This fixes the starting point of the object.
3. Click another location in the work area. A corner point is set.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2570 System Manual, 01/2013,
4. For every additional corner point, click on the corresponding location in the work area.
5. Double-click on a location in the work area. The last corner point is set.
This fixes all the points of the polygon or polyline.
Note
Basic Panels
The "Polyline" and "Polygon" objects are not available for Basic Panels.
Note
If you want to insert several objects of the same type, use the "Stamp" function. This avoids
having to reselect the object in the "Tools" task card every time before inserting it. To do so,
select the icon in the toolbar of the "Tools" task card.
See also
Overview of objects (Page 2565)
10.1.2.4 Deleting an Object
Introduction
You can delete objects individually or with a multiple selection.
Requirement
You have opened the work area containing at least one object.
Procedure
1. Select the object that you want to delete.
To delete multiple objects, keep the <Shift> key pressed and select the objects to be deleted
one after the other. Alternatively, drag and maximize an area around the desired objects
with the mouse.
2. Select "Delete" from the shortcut menu.
Result
The selected objects are deleted.
See also
Overview of objects (Page 2565)
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2571
10.1.2.5 Positioning an object
Introduction
When you select an object, it is enclosed by a rectangle with resizing handles. This rectangle
is the rectangle which surrounds the object. The position of an object is defined by the
coordinates of the top left corner of the rectangle surrounding the object.
Note
If the position is outside the work area the object is not displayed in Runtime.
Position and align
You have the possibility of having a grid displayed in the work area. You have three options
for easier positioning of objects:
"Snap to grid" When you resposition objects, they are automatically snapped and pasted
to the grid. If you hold down the <Alt> key, the object is no longer snapped to the grid.
"Snap to objects" When you reposition objects, they are displayed with help lines. You can
use other objects for orientation during positioning.
"None": You position the objects in any position.
You activate and deactivate the grid and options as follows:
In the "Options > Settings > Visualization > Screens" menu
In the "Layout > Grid" task card
Requirement
You have opened the work area containing at least one object.
Procedure
1. Select the object you want to move.
The selected object is framed by a rectangle with resizing handles.
2. Left-click the object and keep the mouse button pressed.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2572 System Manual, 01/2013,
3. Move the mouse pointer onto the new position.
The contour of the object moves with the mouse and displays the new position for the object.
The object initially remains at its original position.
4. Now release the mouse button.
The object is moved into the position indicated by the contour of the selection rectangle.
Alternative procedure
1. In the Inspector window, select "Properties > Properties > Layout".
2. Enter the X and Y values for the position under "Position & Size".
Result
The object appears at its new position.
See also
Overview of objects (Page 2565)
10.1.2.6 Resizing an object
Introduction
When you select an object, it is enclosed by a rectangle with handles. You have the following
options of resizing an object:
Drag the handles using the mouse.
Modify the "Size" property in the Inspector window.
Requirement
You have opened the work area containing at least one object.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2573
Procedure
1. Select the object you want to resize.
The selection rectangle appears. The following figure shows a selected object:
2. Drag a resizing contact of the rectangle to a new position.
The size of the object changes.
The size of the object is aligned to the grid pattern, provided the "Snap to grid" function
is set.
Press <ALT> to disable this function while you drag the object.
Note
In order to scale the object proportionally, keep the <Shift> key pressed while changing
the size with the mouse.
Alternative procedure
1. In the Inspector window, select "Properties > Properties > Layout".
2. Enter the size of the object under "Position & Size".
Result
The object now appears with its new size.
See also
Overview of objects (Page 2565)
10.1.2.7 Selecting multiple objects
Introduction
Select all objects you want to align with each other or to change global properties. This
procedure is called "multiple selection."
The Inspector window shows all the properties of the selected objects.
You now have several options of selecting multiple objects:
Draw a selection frame around the objects.
Hold down the <Shift> key, and click the required objects.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2574 System Manual, 01/2013,
Selection frame of a multiple selection
The selection frame surrounds all objects of a multiple selection. The selection frame is
comparable with the rectangle that surrounds an individual object.
The selection frame is not visible. When you have made your multiple selection, the following
frame is displayed:
The reference object is indicated by the rectangle around it.
The other selected objects are indicated by a dashed-line frame.
Specifying a reference object
The reference object is the object upon which the other objects are oriented. The reference
object is framed by a rectangle with handles. The following figure shows a reference object
with two other selected objects:
You have the following options to specify the reference object:
Select the objects via multiple selection. The object selected first is then the reference
object.
Draw a selection frame around the objects. The reference object compiled automatically.
If you wish to specify a different object within the selection as the reference object, click on
the desired object. This action does not cancel your multiple selection.
Requirement
You have opened the work area containing at least two objects.
Selecting multiple objects with a selection frame
1. Position the mouse pointer in the work area close to one of the objects to be selected.
2. Hold down the mouse button, and draw a selection frame around the objects to be selected.
Or:
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2575
1. Hold down the <Shift> key.
2. Click the relevant objects, working in succession.
All the selected objects are identified by frames.
The object selected first is identified as reference object.
Note
To remove an object from the multiple selection, press <SHIFT>, hold it down and then
click the relevant object once again.
Result
Multiple objects are selected. One of those is identified as the reference object. You can now
perform the following steps:
Changing the object properties of all the objects
Resizing all the objects by the same ratio, by dragging the selection frame to increase or
reduce the size
Moving all the objects in one group
Aligning the objects to the reference object
See also
Overview of objects (Page 2565)
10.1.2.8 Aligning objects
Procedure
1. Select the objects via multiple selection.
2. Specify an object as the reference object.
3. Select the desired command in the toolbar or the shortcut menu - see table below.
The selected objects will be aligned.
Aligning objects flush
The selected objects will be aligned flush to the reference object.
Icon Description
Aligns the selected objects to the left edge of the reference object.
Aligns the selected objects to the vertical center axis of the reference object.
Aligns the selected objects to the right edge of the reference object.
Aligns the selected objects to the upper edge of the reference object.
Aligns the selected objects to the horizontal center axis of the reference object.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2576 System Manual, 01/2013,
Icon Description
Aligns the selected objects to the lower edge of the reference object.
Centers the selected objects to the center points of the reference object.
Centers the selected objects vertically in the screen.
Distributing objects evenly
You need at least three selected objects. A reference object is not required.
1. Select the objects.
2. Click one of the buttons "Distribute horizontally equal" or "Distribute vertically equal."
The selected objects are distributed at equal distances.
The following screen shows how you align the vertical spacing of the selected objects:
Icon Description
Aligns the horizontal distance between the objects.
The position of the objects on the extreme left and right side remains unchanged. All
other objects are distributed evenly between them.
Aligns the vertical distance between the objects.
The position of the objects at the extreme top and bottom (right and left) remains
unchanged. All other objects are distributed evenly between them.
Harmonizing the object size
1. Select the objects.
2. Now, click one of the following buttons: or or
The size of the selected objects is matched to each other.
The following screen shows how the selected objects are adapted to the height of the reference
object:
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2577
Icon Description
Aligns the selected objects to the width of the reference object.
Aligns the selected objects to the height of the reference object.
Aligns the selected objects to the width and height of the reference object.
See also
Overview of objects (Page 2565)
10.1.2.9 Moving an object forward or backward
Introduction
You can use the "Order" functions in the shortcut menu of a selected object or in the toolbar
to move a selected object in front of or behind other objects within an object layer.
Note
ActiveX controls are always positioned in front of an object layer (.NET property).
Requirement
You have opened a screen which contains a layer with multiple objects.
Procedure
1. Select the object you want to move forward or backward.
2. Select the "Sort" command and one of the following commands from the shortcut menu:
Icon Description
Moves the selected object before all the other objects of the same layer
Moves the selected object to the lowest position in the same layer
Moves the selected object up by one position
Moves the selected object down by one position
Alternative procedure
1. Open the "Layers" palette of the "Layout" task card.
2. Navigate to the required object.
3. Hold down the mouse button, and drag the object in the tree topology to the required position
in the layer.
4. Now release the mouse button.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2578 System Manual, 01/2013,
Result
The object is moved up or down.
See also
Overview of objects (Page 2565)
10.1.2.10 Show objects outside the screen area
Introduction
If you assign objects to positions that are outside the configurable area, these objects will be
hidden. The functions of the "Objects outside the visible area" palette in the "Layout" task card
are used to move these objects back into the screen.
Requirement
You have opened a screen which contains objects that are outside the configurable area.
The "Layout" task card is open.
Procedure
1. Open the "Layout > Objects outside the area" task card.
This displays a list of objects that are outside the configurable area.
2. Select the the object which you want to move back into the screen from the list.
3. Select "Move to screen" in the object shortcut menu.
Alternatively open the "Layout > Layer" task card. Objects outside the area are indicated by
the icon. If you click this icon, the object is moved back into the screen.
Result
The objects are moved to the configurable area.
See also
Overview of objects (Page 2565)
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2579
10.1.2.11 Rotating objects
Introduction
You can rotate a suitable object clockwise or counterclockwise around its center axis in steps
of 90.
Note
Not all the objects can be rotated. Some objects that can be rotated in screens cannot be
rotated in reports.
You can also rotate multiple objects using the multiple selection function. Certain WinCC
objects such as buttons cannot be rotated.
The alignment of elements in an object will change in a rotated object. The following figure
shows how a rectangle and an ellipse behave under the different commands for rotating an
object:
90 to the right
180 to the right
3x 90 to the right
90 to the left
Requirement
You have opened the work area containing at least one object.
Procedure
1. Select the object that you want to rotate.
2. Click one of the following toolbar icons:
, to rotate the object clockwise around its center point. The angle of rotation is 90.
, to rotate the object counterclockwise around its center point. The angle of rotation is
90.
, to rotate the object clockwise by 180.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2580 System Manual, 01/2013,
Result
The object is shown at its new angle.
See also
Overview of objects (Page 2565)
Ellipse (Page 2665)
10.1.2.12 Flipping objects
Introduction
You can flip an object along its vertical or horizontal center axis. The alignment of elements in
an object will change when you flip an object. The following figure shows how a rectangle and
an ellipse behave under the different commands for flipping an object.
horizontal
horizontal + vertical
vertical
Requirement
You have opened a screen which contains at least one object.
Procedure
1. Select the object that you want to flip.
2. Click the "Flip" command in the shortcut menu and select one of the options displayed:
, to flip the selected object along its vertical center axis.
, to flip the selected object along its horizontal center axis.
Result
The object is shown at its flipped position.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2581
See also
Overview of objects (Page 2565)
Ellipse (Page 2665)
10.1.2.13 Designing an object
Introduction
You design the border and background of an object.
Requirement
A line has been created in a screen.
Procedure
1. Select the line on your screen.
2. In the Inspector window, select "Properties > Properties > Appearance":
3. Select "Dash" as the style.
4. To display the dashed line in two colors, select the line width "1".
5. Select the setting "Arrow" in the "Line ends" area.
Result
The line is displayed in two colors as a dashed line. The end of the line is an arrow.
10.1.2.14 Inserting multiple objects of the same type (stamping tool)
Introduction
WinCC offers the possibility to "stamp" several objects of the same type directly one after the
other, i.e. paste without having to reselect the object every time. In addition you have the
possibility of multiplying an object that has already been inserted.
Requirement
The "Tools" task card is open.
Inserting several objects of one type
1. Select the object that you want to insert in the "Tools" task card.
2. Click the icon in the toolbar of the "Tools" task card.
The "Stamp" function is activated.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2582 System Manual, 01/2013,
3. To insert the object with its standard size, click the relevant insertion position in the work
area.
To insert the object with another size, position the mouse pointer at the desired location in
the work area. Press the left mouse button and drag the object to the required size.
The object is inserted in the work area as soon as you release the mouse button.
4. Repeat step 3 to insert further objects of the same type.
5. Click the icon again.
The "Stamp" function is deactivated.
Note
You can copy existing objects using the drag-and-drop +<CTRL> function. The existing
object is not moved in this case. You paste a copy of this object into the new position
instead.
Inserting and multiplying an object
1. Insert the desired object from the "Tools" task card.
2. Press the <Ctrl> key and position the cursor on one of the handles displayed in the figure
shown below.
Multiplication
in horizontal
direction
Multiplication
in vertical
direction
Multiplication
in vertical and
horizontal
direction
3. Drag the handles to the right and/or down while keeping the left mouse button pressed.
4. The object is multiplied depending on available space if you keep moving the cursor.
Result
You have pasted and stamped an object in a screen.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2583
See also
Overview of objects (Page 2565)
10.1.2.15 Repositioning and resizing multiple objects
Possible modifications
After you have selected multiple objects, you edit them:
Shift using the mouse
To change the absolute position of the marked objects, position the mouse pointer over
an object, and shift the multiple selection with the mouse button pressed.
To resize all the objects by the same ratio, grab the resizing handles of the reference
object.
Move over the work area with the icons of the toolbar
Change the position of the marked objects with respect to each other
Align the height and width of the marked objects
Moving with the shortcut menu commands of the work area
Change the position of the marked objects with respect to each other
Align the height and width of the marked objects
See also
Overview of objects (Page 2565)
10.1.2.16 External graphics
Introduction
You can use graphics created with an external graphic program in WinCC. To use these
graphics you store them in the graphic browser of the WinCC project.
You can save graphics in the graphic browser:
When you drag-and-drop graphics objects from the "Graphics" pane into the work area,
these are stored automatically in the graphic browser. The graphic names are numbered
in the order of their creation, for example, "Graphic_1." Use the <F2> function key to rename
the graphic.
As a graphic file with the following formats:
*.bmp, *.ico, *.emf, *.wmf, *.gif, *.tif, *.png, *.jpeg or *.jpg
As an OLE object that is embedded in WinCC and is linked to an external graphic editor.
In the case of an OLE link, you open the external graphic editor from WinCC. The linked
object is edited using the graphic editor. An OLE link only works if the external graphic
editor is installed on your PC, and supports OLE.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2584 System Manual, 01/2013,
Use of graphics from the graphic browser
Graphics from the graphic browser are used in your screens:
In a Graphic view
In a graphics list
As labeling for a button/function key
Transparent graphics
In WinCC you also use graphics with a transparent background. When a graphic with a
transparent background is inserted into a graphic object of WinCC, the transparency is
replaced by the background color specified for the graphic object. The selected background
color is linked firmly with the graphic. If you use the graphic in another graphic object of WinCC,
this object is displayed with the same background color as the graphic object that was
configured first. If you want to use the graphic with different background colors, include this
graphic in the graphic browser again under a different name. The additional background color
is configured when the graphic is used at the corresponding graphic object of WinCC.
Managing graphics
An extensive collection of graphics, icons and symbols is installed with WinCC, for example:
In the Toolbox window of the "Graphic" pane the graphic objects are structured by topic in the
"WinCC graphics folder." The link to the WinCC graphics folder cannot be removed, edited or
renamed.
The "Graphics" pane is also used to manage the external graphics. The following possibilities
are available:
Creating links to graphics folders
The external graphic objects in this folder, and in the subfolders, are displayed in the toolbox
and are thus integrated in the project.
Editing folder links
You open the program required for editing of the external graphic in WinCC.
See also
Overview of objects (Page 2565)
10.1.2.17 Managing external graphics
Introduction
External graphics that you want to use in WinCC are managed in the "Screens" editor by using
the "Tools" task card in the "Graphics" pane.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2585
Requirement
The "Screens" editor is open.
The "Tools" task card is open.
The graphics are available.
The graphics have the following formats:
*.bmp, *.ico, *.emf, *.wmf, *.gif, *.tif, *.jpeg or *.jpg
Creating a folder link
1. Click "My graphics folder."
2. Select "Link" in the shortcut menu.
The "Create link to folder" dialog is opened. The dialog suggests a name for the folder link.
3. Edit the name as required. Select the path containing the graphic objects.
4. Click "OK" to confirm your input.
The new folder link is added to the "Graphics" object group. The external graphics that are
located in the target folder and in sub-folders are displayed in the toolbox.
Editing folder links
1. Select the folder link to edit.
2. Select the "Edit link..." command from the shortcut menu.
The "Create link to folder" dialog is opened.
3. Edit the name and path of the folder link as required.
4. Click "OK" to confirm your input.
Renaming the folder link
1. Select the folder link to rename.
2. Select "Rename" from the shortcut menu.
3. Assign a name to the new folder link.
Removing a folder link
1. Select the folder link you want to delete.
2. Select "Remove" in the shortcut menu.
Edit external graphics
1. Select the graphic you want to edit.
2. Select the "Edit graphic" command from the shortcut menu.
This opens the screen editor associated with the graphic object file.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2586 System Manual, 01/2013,
Editing graphics folders from WinCC
1. Select the graphic you want to edit.
2. Select the "Open parent folder" command from the shortcut menu.
The Windows Explorer opens.
See also
Overview of objects (Page 2565)
10.1.2.18 Storing an external image in the graphics library.
Introduction
To display graphics that have been created in an external graphics program in your screens,
you will first have to store these graphics in the graphics browser of the WinCC project.
Requirement
A screen has been created.
A Graphic View is inserted in the screen.
The Inspector window of the Graphic view is open.
To store an external graphic in the image browser:
A graphic is available.
To store an OLE object in the browser:
An OLE-compatible graphics program is installed on your configuration computer.
Save graphics file
1. Open the Windows Explorer.
2. Select the graphic that you want to store.
3. Drag-and-drop the graphic into the graphic browser.
Creating and saving a new graphic as an OLE object
1. Select the Graphic view on your screen.
2. In the Inspector window, select "Properties > Properties > General":
3. Open the graphic selection list.
4. Click .
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2587
5. The "Insert object" dialog box opens.
Note
In addition, the dialog "External application running..." will open. The dialog will not close
until you exit the external application.
6. From the "Insert object" dialog box, select "New" and an object type. The settings in
"Settings > "OLE settings" determine which object types are shown.
7. Click "OK." The associated graphic program is opened.
When you are finished creating graphics, end the graphic programming software with "File
> Close" or "File > Close & return to WinCC."
The graphic will be stored in the graphic programming software standard format and added
to the graphic browser.
Inserting created graphics in WinCC
Note
A new graphic object created as OLE object may not be directly accepted in WinCC when
you save it to an external graphics program.
1. Reopen the dialog for inserting a graphic.
2. From the "Insert object" dialog box, select "Create from file."
3. Click the "Browse" button.
4. Navigate to the created graphic and select it.
Saving an existing graphic object as an OLE object
1. In the Inspector window, select "Properties > Properties > General":
2. Open the graphic selection list.
3. Click .
4. The "Insert object" dialog box opens.
Note
In addition, the dialog "External application running..." will open. The dialog will not close
until you exit the external application.
5. From the "Insert object" dialog box, select "Create from file."
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2588 System Manual, 01/2013,
6. Click the "Browse" button.
7. Use the dialog to help you navigate to the folder in which the graphic file is saved.
Note
To import graphics files, note the following size restrictions:
*.bmp, *.tif, *.emf, *.wmf 4 MB
*.jpg, *.jpeg, *.ico, *.gif "*1 MB
Result
The image file is now stored in your image browser. It is shown in a screen with a Graphic
view , or is added as a list element in an image list.
You can double-click OLE objects in your library to open them for editing in the corresponding
graphic editor. When you have finished editing graphics, end the graphic programming
software with "File > Close" or "File > Close & return to WinCC." The changes are applied to
WinCC.
See also
Overview of objects (Page 2565)
10.1.2.19 Working with object groups
Basics on groups
Introduction
Groups are several objects that are grouped together with the "Group" function. You edit a
group in the same way as any other object.
Overview
WinCC offers the following methods for editing multiple objects:
Multiple selection
Creating object groups
Editing mode
To edit an individual object in a group, select the object in the "Layout > Layers" task card.
Alternatively select "Group > Edit group" in the object group's shortcut menu.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2589
Hierarchical groups
You add further objects or groups to extend a group. The group is enlarged by the new objects
and is structured hierarchically in main and sub-groups. Such hierarchical groups must be
broken up in stages. You also break up the group in the same order in which you grouped the
objects or groups. It takes exactly the same number of steps to break up these hierarchical
groups as it did to create them.
Rectangle surrounding the object
Only one surrounding rectangle is now displayed for the whole group. The surrounding
rectangles of all objects are displayed for a multiple selection on the other hand.
Layers
All objects of a group are located in the same layer.
See also
Overview of objects (Page 2565)
Creating object groups
Introduction
The "Group" command combines multiple objects to form a group.
You can change the size and position of the group. The following rules apply:
The system automatically adapts the position coordinates of the grouped objects when you
reposition the group. The relative position of the grouped objects to the group is not affected.
The system automatically adapts the height and width of the grouped objects in proportion
to a change of the group size.
To change the size of the group proportionately, hold down the <Shift> key and drag the
rectangle around the object until has the required size.
Note
To create a hierarchical group, organize the individual groups like objects.
Requirement
You have opened a screen which contains at least two objects.
Creating object groups
1. Select all the objects you want to organize in a group.
2. Select the command "Group > Group" from the shortcut menu.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2590 System Manual, 01/2013,
The objects of the group are displayed with a rectangle around the objects.
Grouping objects within a group
1. Select the group you want to edit.
2. Select the command "Group > Edit group" from the shortcut menu.
The group that you are editing is highlighted by a red frame.
3. Select the objects of a group that you want to combine into a subgroup.
4. Select the command "Group > Group" from the shortcut menu.
A subgroup with the objects is created.
Adding objects into an existing group
1. Select the group to which you want to add objects.
2. Press the <Shift> key and select the object you want to add to the group.
3. Select the "Group > Add to group" command from the shortcut menu.
The object is added to this group.
Alternative procedure
You can also edit groups in the "Layout" task card. Using drag-and-drop you can also easily
edit nested groups in the "Layers" pane.
Result
The selected objects are combined in a group. The multiple selection rectangle becomes the
rectangle surroundings the objects in the group. The handles are shown only for the group.
The group in in the active layer.
Ungroup
Introduction
Select the "Ungroup" command to split a group into the original object fractions.
Requirement
You have opened a screen that contains a group.
Ungroup
1. Select the group.
2. Select the "Group > Ungroup" command from the shortcut menu.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2591
Ungrouping a group within a group
1. Select the higher-level group.
2. Select the command "Group > Edit group" from the shortcut menu.
The group that you are editing is highlighted by a red frame.
3. Select the lower-level group.
4. Select the "Group > Ungroup" command from the shortcut menu.
Result
The lower-level group is ungrouped. The objects are assigned to the next higher group.
Alternative procedure
You can also edit groups in the "Layout" task card. Using drag-and-drop you can also easily
edit nested groups in the "Layers" pane.
Adding objects to a group
Introduction
The "Add objects to group" command is used to add objects to a group, without ungrouping it
first.
Requirements
A screen with one group and at least one other object is opened.
Procedure
1. Select the group.
2. Press the <Shift> key and select the object you want to add to the group.
3. Select the "Group > Add to group" command from the shortcut menu.
Result
The group consists of the original objects, and the newly-added objects. The added objects
are arranged at the front of the group.
Alternative procedure
You can also edit groups in the "Layout" task card. Using drag&drop you can also easily edit
hierarchical groups in the "Layers" palette.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2592 System Manual, 01/2013,
Removing Objects from the Group
Introduction
You use the "Remove objects from group" command to remove individual objects from a group,
without ungrouping it first.
You do not have to remove the object from the group to edit an object in a group. You can edit
the objects of a group individually.
Requirement
You have opened a screen that contains a group.
Removing objects from a group
To remove an object from a group:
1. Select the group.
2. Select the command "Group > Edit group" from the shortcut menu.
The group you want to edit is highlighted by a red frame.
3. Select all objects in the group that you want to remove from the group.
4. Select the "Group > Remove from group" command from the shortcut menu.
The objects are removed from the group.
Note
If there are only two objects in the group, the menu command "Remove from group" is not
available.
Deleting objects from a group
To remove an object from the group, and from the screen:
1. Select the group.
2. Select the command "Group > Edit group" from the shortcut menu.
The group you want to edit is highlighted by a red frame.
3. Select the objects in the group that you want to delete.
4. Select "Delete" from the shortcut menu.
Note
If there are only two objects in the group, the menu command "Delete" is not available.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2593
Alternative procedure
You can also edit groups in the "Layout" task card. Using drag-and-drop you can also easily
edit nested groups in the "Layers" pane.
Editing an Object in a Group
Introduction
You can edit the objects of a group individually.
Requirement
You have opened a screen that contains a group.
Editing grouped objects
1. Select the group.
The properties of the group are displayed in the Inspector window.
2. Change the position and size of the grouped objects in "Properties > Properties >Layout."
3. Change the name of the group in "Properties > Properties > Miscellaneous."
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2594 System Manual, 01/2013,
Modifying the properties of an object within a group
1. Select the group.
2. Select the object whose properties you want to change in the Inspector window.
The properties of the object are displayed.
3. Change the object properties.
Result
Although you have edited the object, it is still an element of the group. These changes do not
affect the other objects of the group.
10.1.2.20 Configuring the keyboard access
Overview of keyboard access
Introduction
For keyboard units without a mouse, the operator activates control objects using the <Tab>
key. You can set up keyboard input to make the process easier to run, and to make sure that
the operator enters all the necessary values. If you are using the keyboard, use the <Tab> key
to activate the objects in a certain order, and to enter the necessary values.
For HMI devices without key, you can simulate the <Tab> key by configuring the
"SimulateSystemKey" system function to a function key.
Operator authorizations and operator control enables
If you configure an object for operator input with the <Tab> key, the object must have both an
operator authorization, and an operator control enable.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2595
Editing the tab sequence
The tab sequence is determined automatically when the control objects are created. The
numbers of the tab sequence are assigned in the sequence in which the libraries are created.
It makes sense to change the tab sequence in the following cases:
The operator changes directly to a specific control object.
The screen requires a specific sequence
Change to the tab sequence mode to change the tab sequence. In this mode, the tab sequence
number is displayed at the top left of the control objects. The tab sequence numbers of hidden
objects are also shown. The distribution of these numbers is edited using the mouse.
Note
Other functions are not available in the tab sequence mode.
See also
Example: Inserting and configuring a rectangle (Page 2598)
Overview of objects (Page 2565)
Defining the Operator Authorization and Operator Control Enable for an Object
Introduction
If you configure an object for operator input with the <Tab> key, the object must have both an
operator authorization, and an operator control enable.
Requirement
You have opened a screen which contains at least one object.
Procedure
1. Select the object.
2. Select "Properties > Properties > Security" in the Inspector window.
3. Select the operator authorization under "Authorization."
4. Activate the authorization to operate.
Result
The operator can use the <Tab> key in Runtime to select the object.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2596 System Manual, 01/2013,
See also
Example: Inserting and configuring a rectangle (Page 2598)
Setting the tab sequence order
Introduction
All operable objects can be reached in runtime with the <Tab> key. You use the "Tab sequence"
command to define the order in which the operator can activate objects in runtime.
Note
You cannot reach objects with the "Output" or "Two states" mode in runtime with the <Tab>
key.
You can operate the screen in runtime:
Using the <Tab> key
Using the mouse
Using a configured hotkey
Requirement
The active screen contains operable objects.
No object is selected.
The objects have been enabled for use in runtime, and have operator authorization.
Procedure
1. Select "Edit tab sequence" in the "Edit" menu.
Tab sequence mode is activated. The tab sequence number is displayed for all objects that
can be used. The tab sequence number is also displayed for hidden objects.
2. Use edit the tab sequence mode, click the accessible objects in the order in which you want
them to be activated using <Tab> in runtime.
The following figure shows how the tab sequence is defined in the screen. In runtime, the
<Tab> key first activates the alarm view (number 1), then the I/O field (number 2), and then
the button (number 3):
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2597
3. To exclude a screen object from the tab sequence, press the key combination <Shift+Ctrl>
and click on the desired object.
The tab sequence number is no longer displayed in the screen object. The screen object
is now excluded from the tab sequence. The remaining tab sequence numbers are
automatically decreased by 1.
4. To reenter an excluded screen object in the tab sequence, repeat step 3.
The screen object entered as the first object in the tab sequence.
Result
The operator selects the objects in the specified order in Runtime with the <Tab> key.
See also
Example: Inserting and configuring a rectangle (Page 2598)
10.1.2.21 Examples
Example: Inserting and configuring a rectangle
Task
In this example, you insert a rectangle in a screen. You can configure the following properties:
Name = "MyRectangle"
Position = (20, 20)
Size = (100,100)
Color = red
Black frame 2 pixels wide
Principle
The rectangle is a closed object which can be filled with a color or pattern. The height and
width of a rectangle can be adjusted to allow its horizontal and vertical alignment.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2598 System Manual, 01/2013,
Overview
Carry out the following steps in order to create a rectangle:
Inserting a rectangle
Configuring a rectangle
See also
Basics on groups (Page 2589)
Overview of objects (Page 2565)
Example: Inserting a rectangle
Task
In this example, you insert and rename a rectangle. Do not use the special characters ?, ", /,
\, *, <, > for the name.
Requirement
A screen is open.
The Inspector window is open.
The "Tools" task card is open.
Procedure
1. Click the "Basic objects" palette in the "Tools" task card.
2. Drag the "Rectangle" object into the screen.
3. In the Inspector window, select "Properties > Properties > Miscellaneous".
4. Type in the new name "MyRectangle".
Result
The rectangle is now inserted and named "MyRectangle". The rectangle has the default
properties of the "rectangle" object.
Example: Configuring a rectangle
Task
In this example you configure a rectangle:
Color = red
Black frame 2 pixels wide
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2599
Position = (20, 20)
Size = (100,100)
Changing the color of the rectangle
To change the color of the rectangle:
1. Select the rectangle.
2. Define the background color in "Properties > Properties > Appearance > Background >
Color" in the Inspector window.
3. Select "Solid" as the fill pattern.
4. Define the color for the border in "Properties > Properties > Appearance > Border > Color"
in the Inspector window.
5. Enter the value "2" for "width".
6. Select "Solid" as the "Style".
Interim result
The rectangle is red and has a black frame with a width of two pixels.
Repositioning and resizing the rectangle
To change the position and size of the rectangle:
1. Select the rectangle.
2. In the Inspector window, select "Properties > Properties > Layout".
3. Set "20" for the both the X and Y coordinates under "Position & Size".
4. Set "100" for the height and for the width.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2600 System Manual, 01/2013,
Result
The rectangle is positioned at the coordinates (20, 20), and has a width and height of 100 pixels.
10.1.3 Working with text lists and graphics lists
10.1.3.1 Working with text lists
Basics on text lists
Introduction
Texts are assigned to the values of a tag in a text list. Assign the text list to a symbolic I/O field
for example in the configuration. This supplies the text to be displayed to the object. The text
lists are created in the ""Text List" editor. You configure the interface between the text list and
a tag at the object that uses the text list.
The selection of objects that can have a text list assigned depends on the Runtime.
Application
The text list is used, for example, to display a drop-down list in a symbolic I/O field.
If the symbolic I/O field is a display field, the associated texts will differ according to the value
of the configured tags. If the symbolic I/O field is an input field, the configured tag assumes
the associated value when the operator selects the corresponding text in Runtime.
Note
Display of tag values without text
The display of tag values to which no text has been assigned depends on the Runtime:
The display and operating object remains empty.
Three asterisks *** are displayed.
Multilingual texts
You can configure multiple languages for the texts in a text list. The texts will then be displayed
in the set language in Runtime. To this purpose you set the languages in the Project window
under "Language support > Project languages."
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2601
Configuration steps
The following steps are necessary to display texts in a symbolic I/O field for example:
1. Creating the text list
2. Assignment of the texts to values or value ranges of a text list
3. Assignment of a text list in the display object, e.g. the symbolic I/O field
Creating a text list
Introduction
The text list allows you to assign specific texts to values and to output these in Runtime, for
example in a symbolic I/O field. The type of symbolic I/O field can be specified, for example
as a pure input field.
The following types of list are available:
Value/Range
Bit
Bit Number
Procedure
1. Double-click "Text and graphics lists" in the project window.
2. Open the "Text lists" tab.
3. Click "Add" in the "Text lists" table.
The Inspector window of the text list is open.
4. Assign a name to the text list that indicates its function.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2602 System Manual, 01/2013,
5. Select the text list type under "Selection":
Value/Range: Text from the text list is displayed when the tag has a value that lies within
the specified range.
Bit (0,1): A text from the text list is displayed when the tag has the value 0. A different
text from the text list is displayed when the tag has the value 1.
Bit number (0-31): Text from the text list is displayed when the tag has the value of the
assigned bit number.
6. Enter a comment for the text list.
Note
You must not use semicolons in the texts in a text list. The semicolon is a control character
and is automatically deleted from a text.
Result
A text list is created.
Assigning texts and values to a range text list
Introduction
For each area text list you specify which texts are displayed at which value range.
Requirement
The "Text and graphics list" editor is open.
The "Text lists" tab is open.
An area text list has been created and selected.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2603
Procedure
1. Click "Add" in the "Text list entries" table.
The Inspector window for this list entry opens.
2. Select the setting "Range" in "Properties > Properties > General > Value" in the Inspector
window.
Enter the value "1" for "Min" for example.
Enter the value "20" for "Max" for example.
For "Text", enter the text that is displayed in Runtime if the tag is within the specified
value range.
Note
Use a maximum of 255 characters and no semicolons for the text.
3. Click "Add" in the "Text list entries" table. A second list entry is created.
4. Select the setting "Range" in "Properties > Properties > General > Value" in the Inspector
window.
Enter the value "21" for "Min" for example.
Enter the value "40" for "Max" for example.
For "Text", enter the text that is displayed in Runtime when the tag is within the specified
value range.
5. If required, activate the "default entry".
The entered text is always displayed when the tag has an undefined value. Only one default
entry is possible per list.
Result
An area text list is created. Texts have been assigned to the possible value ranges.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2604 System Manual, 01/2013,
Assigning texts and values to a bit text list
Introduction
For each text list, you specify which text is displayed at which bit value.
Requirement
The "Text and graphics list" editor is open.
The "Text lists" tab is open.
A bit text list has been created and selected.
Procedure
1. Click "Add" in the "Text list entries" table.
The Inspector window for this list entry opens.
2. Select the setting "Single value" in "Properties > Properties > General > Value" in the
Inspector window.
Enter "0" for "Value."
Enter the text which is displayed in Runtime under "Text" if the bit tag is set to "0".
Note
Use a maximum of 255 characters and no semicolons for the text.
3. Click "Add" in the "Text list entries" table. A second list entry is created.
4. Select the setting "Single value" in "Properties > Properties > General > Value" in the
Inspector window.
Enter "1" under "Value."
Enter the text which is to be displayed in Runtime under "Text" if the bit tag is set to "1".
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2605
Result
A bit text list is created. Texts that appear in Runtime are assigned to the possible values "0"
and "1".
Assigning texts and values to a bit number text list
Introduction
For each bit number text list you specify which texts are displayed at which bit number.
Requirement
The "Text and graphics list" editor is open.
The "Text lists" tab is open.
A bit number text list has been created and selected.
Procedure
1. Click "Add" in the "Text list entries" table.
The Inspector window for this list entry opens.
2. Select the setting "Single value" in "Properties > Properties > General > Value" in the
Inspector window.
Enter "10", for example, for "Value".
Under "Text", enter the text that is displayed in Runtime when the tag
has the value "10".
Note
Use a maximum of 255 characters and no semicolons for the text.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2606 System Manual, 01/2013,
3. If required, activate the "default entry".
The entered text is always displayed when the tag has an undefined value. Only one default
entry is possible per list.
4. Create further list entries for additional bit numbers of the same text list.
Result
A bit number text list is created. Texts that appear in Runtime are assigned to the specified bit
numbers.
Configuring objects with a text list
Introduction
The output value and value application for text lists are specified in the display and operating
object that displays the texts of the text list in Runtime. The properties of these objects are
configured as required.
Requirement
A text list is created.
You have created a tag.
The "Screens" editor is open.
A screen with a symbolic I/O field is open. The object is edited.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2607
Procedure
1. Select the text list which you want to have displayed in Runtime in "Properties > Properties
> General > Text list" in the Inspection window.
2. Select the setting "Output" as the "Mode".
Note
Runtime dependency
Different field types are available for a symbolic I/O field depending on the Runtime.
3. Select the tag the value of which determines the display in the symbolic I/O field as "Tag".
Result
The defined texts of the text list are displayed in the symbolic I/O field in Runtime when the
tag has the specified value.
10.1.3.2 Working with graphics lists
Basic principles of graphics lists
Introduction
The possible values of a tag are assigned to specific graphics in a graphics list. During
configuration, you can create a graphics list for a button or a graphic I/O field. This supplies
the graphics to be displayed to the object.
The graphics lists are created with the "Text and graphics list" editor. You configure the
interface between the graphics list and a tag at the object that uses the graphics list. The
availability of the graphics list is determined by the HMI device used.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2608 System Manual, 01/2013,
Application
You can configure the graphics list for the following situations:
Drop-down list with a graphic I/O field
State-specific graphic for a button
The graphics in a graphics list can be configured as multilingual. The graphics will then be
displayed in the set language in runtime.
Graphic sources
Graphics can be added to the graphics list from the following sources:
By selecting from a graphic browser
By selecting an existing file
You can use the following file types:
*.bmp, *.ico, *.emf, *.wmf, *.gif, *.tiff, *.png, *.jpeg and *.jpg.
By creating a new file
Function
If the graphic I/O field is a display field, the associated graphics will differ according to the value
of the configured tags. If the graphic I/O field is an input field, the configured tag assumes the
associated value when the operator selects a graphic in runtime.
Configuration steps
The following tasks are required to display graphics, for example, in a graphic I/O field:
1. Creating the graphics list
2. Assignment of the graphics to values or value ranges of a graphics list
3. Assigning a graphics list in the display object, for example the graphic I/O field
Creating a graphics list
Introduction
The graphics list allows you to assign specific graphics to variable values and to output these
in a graphic IO field in Runtime. You can specify the type of graphic I/O field, for example as
a pure output field.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2609
Procedure
1. Double-click "Text and graphics lists" in the project window.
2. Open the "Graphics lists" tab.
3. Click "Add" in the "Graphics lists" table. The Inspector window of the graphics list will open
up.
4. Assign a name to the graphics list that indicates its function.
5. Select the graphics list type "Bit number (0 - 31)" for example under "Select".
6. Enter a comment for the graphics list.
Result
A graphics list of the type "Range (0 - 31)" is created.
Assigning a graphic and values to a range graphics list
Introduction
For each area graphics list you specify which graphics are displayed at which value range.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2610 System Manual, 01/2013,
Requirement
The "Text and graphics list" editor is open.
The "Graphics list" tab is open.
An area graphics list has been created and selected.
Procedure
1. Click "Add" in the "Graphics list entries" table.
The Inspector window for this list entry opens.
2. Select the settings "Range" in "Properties > Properties > General > Value" in the Inspector
window:
Enter the value "1" for "Min" for example.
Enter the value "20" for "Max" for example.
Select a graphic that is displayed in Runtime when the tag is within the specified value
range.
Note
As an alternative to the drop-down menu, you can insert graphics from libraries or from
your file system:
1. Select a graphic in the library or in your file system.
2. Drag-and-drop the graphic into the "Graphics list entries > Graphic" table.
3. Click "Add" in the "Graphics list entries" table. A further list entry is created.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2611
4. Select the settings "Single value" in "Properties > Properties > General > Value" in the
Inspector window:
Enter the value "21" for example.
Select a graphic which is displayed in Runtime if the bit "21" is set in the tag.
5. If required, activate the "default entry".
The graphic is always displayed when the tag has an undefined value. Only one default
entry is possible per list.
Result
An area graphics list is created. Graphics that appear in Runtime are assigned to the possible
values.
Assigning graphics and values to a bit graphics list
Introduction
For each graphics list you specify which graphic is displayed at which bit value.
Requirement
The "Text and graphics list" editor is open.
The "Graphics list" tab is opened.
A bit graphics list has been created and selected.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2612 System Manual, 01/2013,
Procedure
1. Click "Add" in the "Graphics list entries" table.
The Inspector window for this list entry opens.
2. Select the settings "Single value" in the inspector window "Properties > Properties >
General > Value":
Enter "0" as the value.
Select a graphic which is displayed in Runtime if the bit "0" is set in the tag.
Note
As an alternative to the drop-down menu, you can insert graphics from libraries or from
your file system:
1. Select a graphic in the library or in your file system.
2. Drag-and-drop the graphic into the "Graphics list entries > Graphic" table.
3. Click "Add" in the "Graphics list entries" table. A new list entry is created.
4. Select "Properties > Properties > General > Value > Single value": in the Inspector window.
Enter "1" as the value.
Select a graphic which is displayed in Runtime if the bit "1" is set in the tag.
Result
A bit graphics list is created. Graphics that appear in Runtime are assigned to the values "0"
and "1".
Assigning graphics and values to a bit number graphics list
Introduction
For each bit number graphics list you specify which graphics are displayed at which bit number.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2613
Requirement
The "Text and graphics list" editor is open.
The "Graphics list" tab is open.
A bit number graphics list has been created and selected.
Procedure
1. Click "Add" in the "Graphics list entries" table.
The Inspector window for this list entry opens.
2. Select the settings "Single value" in "Properties > Properties > General > Value" in the
Inspector window:
Enter the value "0" for example.
Select a graphic which is displayed in Runtime if the bit "0" is set in the tag.
Note
As an alternative to the drop-down menu, you can insert graphics from libraries or from
your file system:
1. Select a graphic in the library or in your file system.
2. Drag-and-drop the graphic into the "Graphics list entries > Graphic" table.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2614 System Manual, 01/2013,
3. If required, activate the "default entry".
The graphic is always displayed when the tag has an undefined value. Only one default
entry is possible per list.
4. Create further list entries for additional bit numbers of the same graphics list.
Result
A bit number graphics list is created. Graphics that appear in Runtime are assigned to the
specified bit numbers.
Configuring objects with a graphics list
Introduction
The output value and value application for graphics list are specified in the display and
operating object that displays the graphics of the graphics list in Runtime. The properties of
these objects are configured as required.
Requirement
A graphics list is created. The values have been defined. Graphics have been assigned to
the values.
You have created a tag.
The "Screens" editor is open.
A screen with a graphics I/O field is open. The object is edited.
Procedure
1. Select the graphics list the graphics of which you want to have displayed in Runtime in
"Properties > Properties > General > Graphics list" in the inspector window.
2. Select the setting "Input/Output"
as the "Mode".
Note
Runtime dependency
Different field types are available for a graphic I/O field depending on the Runtime.
3. As "Tag", select the tag whose values are defined by the display in the graphic I/O field.
Result
The defined graphics of the graphics list are displayed in the graphic I/O field in Runtime when
the tag has the specified value.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2615
10.1.4 Dynamizing screens
10.1.4.1 Basics on dynamization
Dynamizing objects
In WinCC you dynamize objects to map your system and show processes on HMI devices.
You implement dynamizations by
Animations
Tags
System functions
One example is the mapping of a tank, the liquid level of which rises or falls in relation to a
process value.
The options for dynamization depend on the object involved. When you copy an object, its
dynamization functions are included.
See also
Dynamization in the inspector window (Page 2616)
Configuring a new animation (Page 2618)
Basic on events (Page 2626)
10.1.4.2 Dynamization in the inspector window
Introduction
Basically, you can dynamize all the screen objects which you have configured in a screen.
Which dynamization possibilities and which events are available depends on the device and
the selected object.
Animations
WinCC helps you to implement dynamization using predefined animations. If you want to
animate an object, first configure the desired animation in the object's inspector window. Then
adapt the animation to the requirements of your project.
The selection of the supported animations depends on the HMI device and the selected object.
You choose between the following types of animation:
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2616 System Manual, 01/2013,
Layout: Appearance, visibility
Movements: direct, diagonal, horizontal and vertical movement
Variable binding
You can configure the "Variable binding" type of animation several times for one object.
You configure animations in the "Properties > Animations" inspector window.
Events
Operable objects also react to events, such as a mouse click.
You configure a function list with system functions on an event. The system functions are
processed as a reaction to the triggered event.
You configure events in the "Properties > Events" inspector window.
You will find further information in "Working with function lists".
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2617
See also
Basics on dynamization (Page 2616)
10.1.4.3 Dynamization with animations
Configuring a new animation
Introduction
Use predefined animations to dynamize screen objects.
Requirement
You have opened a screen which contains at least one dynamic object.
The Inspector window is open.
The toolbox window is displayed.
Procedure in the inspector window
1. In the Inspector window, select "Properties > Animations".
2. Select the animation you want to use.
3. Click the button.
Procedure in the "Animations" task card.
1. Open the object group containing the required animation in the "Animations" task card.
2. Drag the animation onto the object that you want to make dynamic.
Alternatively you select the object in the screen and double click the desired animation in the
"Animation" task card.
Result
The animation appears in the Inspector window of the object. You configure the animation in
the following steps.
In the animations overview the green arrow indicates which animation is already configured.
The configured animation opens in the inspector window when you click the green arrow.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2618 System Manual, 01/2013,
See also
Dynamizing the visibility of an object (Page 2623)
Basics on dynamization (Page 2616)
Dynamize appearance of an object
Introduction
The appearance of a screen object is controlled by changing the value of a tag in runtime.
When the tag adopts a certain value, the screen object changes its color or flashing
characteristics according to the configuration.
Type
Areas or single values of the tag are observed in Runtime depending on the selection. The
appearance of the object changes according to the configuration.
Requirement
A screen is open.
A dynamic object is contained and selected in the screen.
The Inspector window is open.
The toolbox window is displayed.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2619
Procedure
1. In the Inspector window, select "Properties > Animations".
The animations available for the selected object are displayed.
2. Select the animation "Appearance" and click the button.
The parameters of the animation are displayed.
3. Select a tag in "Tag > Name".
4. Select "Type > Range" for example.
5. Click "Add" in the table.
6. Enter the tag interval "0 - 20" in the "Range" column for example.
7. For "Foreground color" and "Background color", select the color the object is to acquire in
Runtime when the tag reaches the interval.
8. Select a flashing mode for the object from the "Flashing" list.
9. Repeat steps 5 to 8 to create another tag interval, e.g. "21 - 60".
Result
In Runtime, the flashing response, and color of the object change dynamically according to
the process value returned in the tag.
Configuring movement
Introduction
You can configure dynamic objects in such a way that they move on a certain track. The
movement is controlled via tags. The object moves every time the tag is updated.
You can only program one type of movement for each object.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2620 System Manual, 01/2013,
Requirement
You have created a tag.
You have opened a screen which contains at least one dynamic object.
The Inspector window is open.
The toolbox window is displayed.
Procedure
1. Select the screen object you want to control dynamically.
The object properties are displayed in the Inspector window.
2. In the Inspector window, select "Properties > Animations".
The animations available for the selected object are displayed.
3. Select "Horizontal movement" and click the button.
The parameters of the animation are displayed.
A transparent copy of the object is shown in the work area, which is connected to the source
object by means of an arrow.
4. Select a tag for control of movement.
5. Move the object copy to the relevant destination. The system automatically enters the pixel
values of the final position in the Inspector window.
6. Customize the range of values for the tag as required.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2621
Result
In Runtime, the object moves in response to every change in value of the tag that is used to
control the movement. The direction of movement corresponds to the configured type of
movement "horizontal".
Note
You configure vertical and diagonal movements similar to horizontal movements
Configuring direct movement
Introduction
The object is moved respectively in x direction and y direction with "Direct movement". Two
tags define the number of pixels by which the object moves from its original static start
position.
Requirement
Two tags are set up.
You have opened a screen which contains at least one dynamic object.
The Inspector window is open.
The toolbox window is displayed.
Configuring "Direct movement"
1. Select the screen object you want to control dynamically.
The object properties are displayed in the Inspector window.
2. In the Inspector window, select "Properties > Animations".
3. Select "Direct movement" and click the button.
The parameters of the animation are displayed.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2622 System Manual, 01/2013,
4. Select a tag for the X position with which the movement in x direction is controlled.
5. Select a tag for the Y position with which the movement in y direction is controlled.
Result
In Runtime, the object moves in response to every change in value of the tag that is used to
control the movement.
Dynamizing the visibility of an object
Introduction
Dynamization of the "Visibility" property allows you to output an alarm to your screen, which
is triggered when the tag value exceeds a critical range, for example. The alarm is cleared
when the tag value returns to the non-critical range.
The "Simple recipe view" and "Simple alarm view" objects are always visible.
Requirement
You have created a tag.
You have opened a screen containing an object that you want to show or hide in Runtime.
The Inspector window is open.
Procedure
1. Select the screen object you want to control dynamically.
The object properties are displayed in the Inspector window.
2. In the Inspector window, select "Properties > Animations".
The animations available for the selected object are displayed.
3. Select "Visibility" and click the button.
The parameters of the animation are displayed.
4. Select a tag.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2623
5. Activate "Single bit".
6. Select bit number "6" for example.
7. Activate "Visible".
Result
The screen object is shown or hidden in Runtime depending on the tag value.
If the tag value matches the configured bit number exactly, the screen object is shown.
If the tag value matches the configured bit number exactly, the screen object is hidden.
See also
Configuring a new animation (Page 2618)
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2624 System Manual, 01/2013,
Animations of object groups
Applying animations to object groups
The inspector window shows all objects of a group and their possible animations. The
animation types which are supported by all objects in the group are also listed separately.
If you configure an animation for an object group, this animation will apply to all individual
objects that support this animation.
Application example
The "horizontal movement" animation is configured for the object of an object group. The "direct
movement" animation is configured for the whole object group. Only the animation of the object
group i.e. "direct movement" is executed in Runtime. This also applies for object groups within
object groups. Only the animation of the group on the top layer is listed.
Animations for object groups and for multiple selection
Changing animations for multiple objects
For a multiple selection, the animations that are configured for the reference object appear in
the Inspector window. You can change the animations as usual. The changes will apply to all
the objects in the multiple selection that support the configured animation. This means that
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2625
even objects for which you have not yet configured an animation will have the reference object's
animation.
Application example
Select a button, and a circle at the same time. The button is the reference object. The
"Appearance" animation is already configured for the button, so it appears in the Inspector
window of the multiple selection. When you activate "Properties > Animations >Appearance >
Flashing" in the inspector window, the settings of the "Appearance" animation apply for the
button and for the circle.
Configuring new animations for multiple objects
If you configure a new animation for the objects of a multiple selection, this animation will apply
to all selected objects that support the configured animation. If the new animation replaces an
existing animation, a security prompt appears.
Application example
You select a circle, and a rectangle. The "Diagonal movement" animation is already configured
for the circle. You configure the "Horizontal movement" animation for the multiple selection.
This animation applies to the rectangle since no animation of the Movement type is yet
configured for it. For the circle, you are asked to confirm that you want to replace the existing
"Diagonal movement" animation with the new "Horizontal movement" animation.
10.1.4.4 Dynamize with system functions
Basic on events
Introduction
Screen objects react to events. You configure a function list with system functions on the events
of an object.
Events
Which events and system functions are available depends on the object used.
If the operator activates a screen object for example, the configured system function is
executed.
Further information can be found in Auto-Hotspot
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2626 System Manual, 01/2013,
See also
Basics on dynamization (Page 2616)
Example: Configuring a button for language switching (Page 2627)
Configure system function on the "Click" event (Page 2627)
Configure system function on the "Click" event
Introduction
You configure a function list on an object event. The linked system function is executed when
the event occurs in runtime.
Requirements
A screen is open.
A button has been created in the screen.
The inspector window is open.
Procedure
1. Select the button.
2. Click "Properties> Events" in the Inspector window.
3. Select the "Click" event.
4. Click "Add function" in the table.
5. Select the "ShowAlarmWindow" system function.
Result
The alarm window opens in the screen if the operator clicks the button in runtime.
See also
Basic on events (Page 2626)
Example: Configuring a button for language switching
Introduction
In this example, you configure a button that can be used to toggle between multiple runtime
languages during runtime.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2627
Requirements
You have completed the "Configuring a button in multiple languages" example.
The "Screen_1" screen is open.
The button on the screen has been selected.
Procedure
1. In the Inspector window, select "Properties > Events > Press".
2. Click on "Add function" in the table.
3. Select the "SetLanguage" system function.
Result
You have assigned the button the function "SetLanguage". Pressing the button during runtime
will switch the runtime language. The runtime languages are switched in the order specified
by the number sequence in the "Languages and fonts" editor.
See also
Basic on events (Page 2626)
Button (Page 2683)
10.1.5 Working with function keys
10.1.5.1 Working with function keys
Introduction
The function key is a physical key on your HMI device and its functions can be configured. A
function list can be configured for the events "Key pressed" and "Release key".
A function key can be assigned global or local functions.
Note
Availability for specific HMI devices
Function keys are not available on all HMI devices.
Global function keys
Global function keys always trigger the same action, regardless of the displayed screen.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2628 System Manual, 01/2013,
Global function keys are configured in the "Global Screen" editor. The global assignment
applies for all the screens of the set HMI device.
Global function keys reduce programming considerably, because there is no need to assign
these global keys to each individual screen.
Local function keys in screens
Local function keys in screens can trigger a different action in each screen. This assignment
applies only to the screen in which you have defined the function key.
Using a local function key you can overwrite global function keys and the local function keys
of a template.
Note
If a screen with local function keys is overlapped by an alarm view or an alarm window, then
the function keys are still active in runtime. This may happen in particular on HMI devices
with a small display.
Local function keys in templates
Local functions keys that are assigned in templates are valid for all the screens based on this
template. They can trigger a different action in every screen. Function keys for templates are
assigned in the template of the "Screens" editor. You overwrite the global assignment of a
function key by a local assignment in the template.
Hotkey assignment
You can assign hotkeys, such as buttons, to control objects. The available hotkeys depend on
the HMI device.
Note
The function key has a local or global action assigned to it. If the function key also has a
hotkey assigned to it, then the hotkey function will be executed in Runtime.
Graphics
When a function key is placed directly next to the display, you can assign a graphic to it to
make the function of the function key more clear.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2629
Display of assignment
Table 10-1 The following table shows which symbols display the assignment of the function keys:
Function key Description
Not assigned
Global assignment
Assigned locally in the template
Local assignment
Local assignment (local assignment of the template overwrites global
assignment)
Local assignment (local assignment overwrites global assignment)
Local assignment (local assignment overwrites local assignment of the template)
Local assignment (local assignment overwrites local assignment of the
template, which already overwrites global assignment)
Assigning buttons with screen navigation
Note
Basic Panels
The "Screen Navigation" editor is not available for Basic Panels.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2630 System Manual, 01/2013,
10.1.5.2 Assigning function keys globally
Introduction
You define the global assignment of a function key in the "Global Screen" editor. The global
assignment applies to all screens of the set HMI device.
Note
Availability for specific HMI devices
Function keys are not available on all HMI devices.
Requirement
You have opened the project.
The Inspector window is open.
Procedure
Proceed as follows to assign a screen-based function to a function key:
1. To open the "Global Screen" editor, double-click "Global Screen" in the "Screen
management" group of the Project window.
2. Select the desired function key.
The properties of the function key are shown in the Inspector window.
3. Under "General", configure a graphic and an operator authorization for the function key.
4. Configure a function list for the required event under "Events".
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2631
Result
If a local assignment does not overwrite the global assignment, the assignment of the function
key changes in all the screens of the set HMI device in accordance with your entry.
10.1.5.3 Local assignment of function keys
Introduction
Function keys are assigned globally and locally. A local assignment of the function keys is only
valid for the screen or the template in which it was defined. The following local function keys
are available:
Local function keys of a screen
Different functions are assigned to the function key for each screen. This assignment
applies only to the screen in which you have defined the function key.
Local function keys of a template
You assign the function keys in a template. The assignment applies to all the screens that
are based on this template and are not overwritten by a local assignment in a screen.
A local assignment overwrites the global assignment of a function key.
Note
Availability for specific HMI devices
Function keys are not available on all HMI devices.
Using existing assignments
The option for using existing assignments is referred to as follows in the Inspector window:
In a template: "Use global assignment"
In a screen:
Screen based on a template: "Use local template"
Screen not based on a template: "Use global assignment"
The "Use local template" option includes the use of the local assignment in the template and
the global assignment.
Requirement
You have opened the screen or the template in which you want to assign a function key
locally.
The Inspector window is open.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2632 System Manual, 01/2013,
Procedure
Proceed as follows:
1. Select the desired function key in the screen or in the template.
The properties of the function key are shown in the Inspector window.
2. Click "General" in the Inspector window.
3. Disable the "Use local template" or "Use global assignment" option.
4. Under "General", configure a graphic and an operator authorization for the function key.
5. Configure a function list for the required event under "Events".
Result
The function key is assigned the configured function in the screen or in the template.
10.1.5.4 Assigning a function key to a function
Introduction
A function key can have two states:
Pressed: Defined by the "Key pressed" event.
Released: Defined by the "Release key" event.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2633
Both of these events are configured in the Inspector window of the function key. You can assign
any event a function list which contains system functions or scripts. Execution of this function
list is event-driven in runtime.
Note
Availability for specific HMI devices
Function keys are not available on all HMI devices.
Note
Basic Panels
Scripts are not available for Basic Panels.
Requirement
To assign the function key a global function:
The "Global Screen" editor is open.
To assign the function key a local function:
The screen in which you want to assign a function key is open.
If you want to assign a function key locally in a template:
The template in which you want to assign a function key is open.
The Inspector window is open.
Procedure
Proceed as follows:
1. Select the function key you want to define.
The properties of the function key are shown in the Inspector window.
2. Configure the function list for the desired result in the Inspector window under "Properties"
in the "General" group.
Result
The function list is executed in runtime when the operator presses or releases the function
key.
10.1.5.5 Assigning operator authorization for a function key
Introduction
In WinCC you can assign an operator authorization for a function key in runtime. This allows
you to restrict access to the function keys to specific persons or operator groups when you
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2634 System Manual, 01/2013,
configure your project. Only authorized personnel can then change important parameters and
settings in runtime.
You configure access protection in order to avoid operator errors and increase plant or machine
security.
Note
Availability for specific HMI devices
Function keys are not available on all HMI devices.
Requirement
The user groups have been defined.
To protect a global function key:
The "Global Screen" editor is open.
If you want to protect a local function key of a screen or of a template:
The screen or the template which contains the function key is open.
The Inspector window is open.
Procedure
Proceed as follows:
1. Select the relevant function key.
The properties of the function key are shown in the Inspector window.
2. Click "General" in the Inspector window.
3. In the "Authorization" list, select the user group you want to allow runtime access to the
function key.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2635
Result
The operator authorization is configured.
10.1.5.6 Assigning a function key to a graphic
Introduction
In order to make the function of a key more clear, you can insert a graphic in the screen
alongside the function key. Graphics can only be assigned to function keys that border the
screen margin of the HMI device.
Note
Availability for specific HMI devices
Function keys are not available on all HMI devices.
Requirement
To assign a graphic to a global function key:
The "Global Screen" editor is open.
If you want to assign a graphic to a local function key in a screen or template:
The screen or the template that contains the corresponding function key is open.
The Inspector window is open.
You have created the graphic for the function key.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2636 System Manual, 01/2013,
Procedure
Proceed as follows:
1. Select the relevant function key.
The properties of the function key are shown in the Inspector window.
2. Click "General" in the Inspector window.
3. Click in the "Graphic" area of the list.
The graphic browser of your WinCC project appears. The pane on the left side shows the
external graphics which are stored in the browser. The pane on the right side shows you a
preview of the graphic you have selected in the browser.
Using the and icons, you can display the collection either in form of thumbnails
or as a list.
In order to open and edit OLE objects with the associated graphics program, double-click
on the object.
4. In the browser click the desired graphic or store the relevant graphic in the graphic browser.
The graphic preview is shown in the right pane.
5. Click "Select" to add the graphic to the screen.
Click "Clear" to remove the graphic from the screen.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2637
Result
The graphic is displayed next to the function key.
10.1.5.7 Configuring LED tags
Requirements
An HMI device with key operation has been created.
You have created an LED tag.
Procedure
1. Create a new screen.
2. Click an F-key of the HMI device.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2638 System Manual, 01/2013,
3. In the Inspector window, click "Properties > Properties > General".
4. Select a tag under "LED tag" in the "General > Settings" area.
5. Under "Bit" enter the correct bit number.
The correct bit number depends on the HMI device and the input and output assignments
on the HMI device.
Assignment of inputs and outputs
The exact assignment of inputs and outputs can be found under:
PROFINET IO direct keys: Auto-Hotspot
PROFIBUS DP direct keys: Auto-Hotspot
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2639
10.1.5.8 Example: Using function keys for screen navigation
Task
In this example you create a local function key in a screen. When the operator presses this
function key, a screen change to a predefined screen is triggered, for example "Boiler 2".
Note
Availability for specific HMI devices
Function keys are not available on all HMI devices.
Requirement
The screen in which you want to assign the function key is open.
You have created the "Boiler 2" screen.
The Inspector window is open.
Procedure
Proceed as follows to use the "ActivateScreen" function:
1. Select the desired function key.
The properties of the function key are shown in the Inspector window.
2. Click "General."
3. To overwrite a global assignment, disable the "Use local template" option.
4. Click "Key pressed" under "Events".
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2640 System Manual, 01/2013,
5. Select the "ActivateScreen" system function from the list.
The "ActivateScreen" function appears in the "Function list" dialog box, including the
"Screen name" and "Object number" parameters.
6. Select the "Boiler 2" screen from the "Screen name" list.
Result
The operator changes to the "Boiler 2" screen in runtime by pressing the selected function key.
10.1.6 Working with layers
10.1.6.1 Basics on working with layers
Layers
Use layers in order to achieve differentiated editing of the objects in a screen. A screen consists
of 32 layers that you can give any names. If you assign objects to the layers, you thereby define
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2641
the screen depth. Objects of layer 0 are located at the screen background, while objects of
layer 31 are located in the foreground.
The objects of a single layer are also arranged hierarchically. When you create a screen, the
object inserted first is located at the rear within the layer. Each further object is placed one
position towards the front. You can shift objects forwards and backwards within a layer.
Principle of the layer technique
Always one layer of the 32 layers is active. New objects you add to the screen are always
assigned to the active layer. The number of the active level is displayed in the inspector window
of the screen and in the "Layout > Layers" task card.
When you open a screen, all 32 layers of the screen are displayed. You can hide all the layers
except for the active layer in the inspector window of the screen and in the "Layout > Layers"
task card. You then explicitly edit objects of the active layer.
In the tree view of the "Layers" palette in the "Layout" task card, you administer layers and
objects with drag-and-drop and the context menu.
Application examples
Use layers, for example, in the following cases:
To hide the labeling of objects when editing,
To hide objects, e.g. alarm windows, while configuring other objects
10.1.6.2 Moving objects between layers
Introduction
By default, a new object is inserted on the active layer. You can, however, assign an object to
another layer at a later time.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2642 System Manual, 01/2013,
Requirement
A screen with an object is open.
The Inspector window is open.
Procedure
1. Select the object in the screen.
The object properties are displayed in the Inspector window.
2. Enter the layer to which you want to move the object in "Properties > Properties >
Miscellaneous > Layer" in the Inspector window.
Alternatively, select the object from the "Layout" task card and drag it to the required layer.
Changing the order of objects
1. Select the object in the screen.
The object properties are displayed in the Inspector window.
2. To move the object to the front or back, select the "Order" > "Move backward" or "Move
forward" command from the shortcut menu.
Alternatively, use the or button in the toolbar.
Result
The object is assigned to the selected layer, and positioned at the top of the layer.
10.1.6.3 Setting the active layer
Introduction
The screen objects are always assigned to one of the 32 layers. There is always an active
layer in the screen. New objects you add to the screen are always assigned to the active layer.
The number of the active layer is indicated in the "Layer" toolbar. The active layer is indicated
by the icon in the "Layout > Layers" task card.
Layer 0 is the active layer when you start programming. You can activate a different layer
during configuration, if necessary.
Requirement
You have opened a screen which contains at least one object.
The Inspector window of the active screen is open.
Procedure
1. Click "Properties > Properties > Layers" in the Inspector window of the current screen.
2. Enter the layer number in "Settings > Active layer".
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2643
Alternative procedure
1. Select "Layout > Layers" in the "Layout" task card.
2. Select the "Set to active" command from the shortcut menu of a layer.
Result
The layer with the specified number is now active.
10.1.6.4 Show and hide layers
Introduction
You can show or hide the layers of a screen as required. You specify the layers that are shown
in the Engineering System. When you open a screen, all the layers are always shown.
Requirement
The screen is opened.
The "Layout" task card is open.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2644 System Manual, 01/2013,
Procedure
1. Select the layer that you want to hide or show in the "Layout > Layers" task card.
2. Click one of the icons next to the corresponding layer:
A shown layer is hidden
A hidden layer is shown
Note
The active layer cannot be hidden.
Alternative procedure
1. Click in an area of the screen that does not contain an object.
The screen properties are shown in the Inspector window.
2. In the Inspector window, select "Properties > Properties > Layers":
3. In the list, disable the levels you wish to hide.
If you activate "All ES layers" for a layer, the objects in this layer will be shown in the
Engineering System.
Result
The layers are shown according to your settings.
10.1.6.5 Renaming layers
Introduction
When you create a screen, the 32 layers are numbered consecutively by default. To improve
clarity, you can rename the layers to suit your requirements.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2645
Requirement
The screen is opened.
Procedure
1. Click in an area of the screen that does not contain an object.
The screen properties are shown in the Inspector window.
2. In the Inspector window, select "Properties > Properties > Layers".
3. Enter the new layer name.
Result
The layer is displayed with the new name.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2646 System Manual, 01/2013,
10.1.7 Working with libraries
10.1.7.1 Basics on libraries
Introduction
Store all objects you need frequently in the libraries. An object that is stored in the library only
has to be configured once. It can then be used repeatedly as often as required. Library objects
extend the number of available screen objects and increase the effectiveness during
configuration through the multiple usage of ready-to-use objects.
Libraries are managed in the "Libraries" task card. The following libraries are available:
Project library
Global libraries
Note
There is a symbol library in the "Tools" task card in the "Graphics" palette.
Project library
There is one library for each project. Objects of the project library are stored alongside with
the project data and are available only for the project in which the library was created. If the
project is moved to another PC, any project library created in it is also moved.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2647
To use the library object of the project library in other objects, move or copy the object into a
global library.
Global libraries
In addition to the objects from the project library, you can also incorporate objects from global
libraries in your projects. A global library is saved independently of the project data in its own
file with the extension *.aI11.
A project can access several global libraries. A global library may be used concurrently in
several projects.
When a library object is changed by a project, this library will be changed in all projects in
which these libraries are open.
Library objects
A library can contain all WinCC objects. Examples:
Complete HMI device
Screens
Display and control objects including tags and functions
Graphics
Tags
Alarms
Text and graphics lists
Faceplates
Structures
See also
Copy templates and types (Page 2648)
10.1.7.2 Copy templates and types
Introduction
Both the "Project library" and the "Global library" contain the two folders "Copy templates" and
"Types". You can create or use the library objects either as a copy template or a type.
Copy templates
Use copy templates to create independent copies of the library object.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2648 System Manual, 01/2013,
Types
Create instances of objects of the "Types" folder and use these in your project. The instances
are bound to their respective type. Changes to an instance also change all other instances.
Types are marked by a green triangle in the "Libraries" task card.
Administration of the library objects
You can only copy and move library objects within the same library. You can only copy copy
templates to the "Copy templates" folder or any sub-folder of "Copy templates". You can also
only insert types in the "Types" folder or any sub-folder of "Types".
See also
Basics on libraries (Page 2647)
10.1.7.3 Libraries in WinCC
Introduction
The WinCC software package includes extensive libraries. Sorted by topic into folders, they
contain preassembled graphic objects which you can use in screens for operation and
monitoring of your plant.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2649
Global library "Buttons and Switches"
The libraries "Buttons and Switches" offer a wide selection of buttons and switches.
The folders divide switches and buttons into categories. The "DiagnosticsButtons" folder
contains the object "System diagnostics indicator", for example. You use the "System
diagnostics indicator" object for system diagnostics in your plant.
Note
You can only use the objects in the "DiagnosticsButtons" folder on Comfort Panels.
You cannot use objects which have "Switch" in the object name or in the associated folder
name in Runtime Professional.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2650 System Manual, 01/2013,
Global library "Monitoring and Control objects"
The "Monitoring and Control objects" library offers more complex display and operating objects
in several designs and corresponding control lights, buttons and switches.
In addition, graphics views for the designs are stored in the "Design_Backgrounds" folder; they
can be used as object backgrounds for the custom extension of the scope of the library.
Note
You cannot use objects which have "Switch" in the object name in Runtime Professional. The
same applies for the object "D5_Display_3" with the date/time field it contains.
10.1.7.4 Displaying library objects
Introduction
The libraries are displayed as file folders in the corresponding palette. The elements contained
in the library are displayed in the file folder and in the "Elements" palette.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2651
Requirement
At least one library object has been created in a library.
The "Libraries" task card is opened.
Procedure
1. Select the library in the corresponding palette whose library objects you want to display.
2. Click .
The contained library objects are displayed in the "Elements" palette.
3. Click one of the following icons:
Icon Description
Element view in detailed mode
Element view in list mode
Element view in overview mode with icons
When several objects are assigned to the library with a multiple selection, only one of the
objects is shown in the "Elements" palette. The individual components of this element are
displayed in the "Parts" palette.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2652 System Manual, 01/2013,
Show parts of the library objects
1. Select the library in the corresponding palette from which you want to view the components
of an element.
2. Click .
3. The contained library objects are displayed in the "Elements" palette.
4. Select the element.
The "Parts" palette shows the objects of which the element consists.
Result
The library objects are displayed in accordance with the configuration. The components of the
faceplates are displayed.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2653
10.1.7.5 Managing library objects
Introduction
You can always copy or move library objects within the categories of a library. Delete the library
objects you do not require.
Note
Copy templates and types
You can only copy and move library objects within the same library. You can only copy copy
templates to the "Copy templates" folder or any sub-folder of "Copy templates". You can also
only insert types in the "Types" folder or any sub-folder of "Types".
Requirement
You have opened a library which contains several categories and at least one object.
The library object is shown.
Moving a library object
1. Select the library object.
2. Drag the object to the desired folder with drag&drop.
Copying a library object
1. Select the library object.
2. Select "Copy" from the shortcut menu.
3. Select the folder in which you want to insert the library object.
4. Select "Paste" from the shortcut menu.
Deleting a library object
1. Select the library object.
2. Select "Delete" from the shortcut menu.
Renaming a library object
Proceed as follows to rename a library object
1. Click the object that you wish to rename with the right mouse button.
2. Select the "Rename" command from the shortcut menu.
3. Enter the new name.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2654 System Manual, 01/2013,
10.1.7.6 Storing an object in a library
Introduction
You can store all of WinCC objects, such as screens, tags, graphic objects or alarms in your
libraries. You can use drag-and-drop to move the corresponding object from the work area,
project window or detail view to the library. In a library you have divided into categories, you
can directly add objects to a specific category.
Requirement
The "Screens" editor is open.
A screen object has been created in the work area of the screen.
The created libraries are displayed.
Procedure
1. Select the object in the work area of the "Screens" editor.
2. Drag-and-drop the object from the work area to the desired library.
The mouse pointer is transformed into a crosshair with an appended object icon.
Result
The object is saved to the library for further use in multiple instances of your configuration.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2655
10.1.7.7 Inserting a library object
Introduction
The system always assigns the inserted library object a name which consists of the name of
the object type and of a consecutive number. If the inserted object already exists, you can use
a dialog window to specify whether or not the existing object should be replaced or inserted
under a new name. Enter a new name if you do not want to replace the existing object.
You cannot insert library objects that are not supported by the HMI device.
Note
If you insert a screen with interconnected template from the library, the template will also be
inserted. Any existing matching template is not used.
Requirement
The "Libraries" task card is opened.
The editor in which you want to insert the library object is open.
Procedure
1. Select the library object that you want to insert in the library.
2. Drag-and-drop the library object to the position in the work area where you want to insert
the object.
The library object is inserted.
3. Select the library object in the screen and adapt it.
Result
If the object was contained in the "Copy templates" folder, you have inserted an independent
copy of the library object in the editor.
If the object was contained in the "Types" folder, you have inserted an instance of the library
object in the editor.
10.1.7.8 Creating a global library
Introduction
In the libraries you store the configured objects that you want to use several times in your
configuration. To use objects in several projects, create a global library.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2656 System Manual, 01/2013,
Requirement
You have opened the project.
The "Libraries" task card is opened.
Procedure
1. Click the icon in the "Libraries > Global libraries" task card.
The "Create new global library" dialog opens.
2. Enter a name.
3. Select the path where the new library is to be stored.
4. Click "Create".
Result
The new library is shown in the "Global libraries" palette. The global library contains the "Types"
and "Copy templates" folders. You can save objects to the library.
10.1.7.9 Saving a global library
Introduction
A global library is stored in a separate file on your hard disk drive. The file contains the objects
of the global library including the referenced objects. E.g. the reference of a tag which was
configured on an I/O field is also saved in the library.
WinCC prompts you to save the global libraries when you close WinCC or your project without
saving. You also can store the global library during configuration, without storing the entire
project.
Requirement
You have opened a project which contains at least one library.
The "Libraries" task card is opened.
A library has been changed.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2657
Procedure
1. Select the global library that you want to save.
2. Click the icon in the "Libraries" task card in the "Global libraries" palette.
You can alternatively select the "Save Library" command in the shortcut menu.
If you want to store the global library in a different folder, select "Save as" in the shortcut menu.
Select the path in which you want to store the new library and enter a file name.
Result
The global libraries are saved under their current file name or a file name you have specified.
10.1.7.10 Opening a global library
Introduction
In WinCC, the global libraries are stored in separate files. You can use a global library in every
project.
Requirement
You have saved a global library.
A project is open.
The "Libraries" task card is opened.
Procedure
1. Click the icon in the "Global libraries" palette.
The "Open global library" dialog box is displayed.
2. Select the path in which the library is stored.
3. Click "Open."
Note
If you want to access a global library from several projects, the global library will have to
be read-only when you open it. As soon as a global library is read-only, access from other
projects is blocked.
Result
WinCC displays the opened global library in the "Global libraries" palette.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2658 System Manual, 01/2013,
10.1.8 Display and operating objects
10.1.8.1 Device-Specific Nature of the Objects
Objects for Basic Panels
Availability of display and operating elements for Basic Panels
Only the objects which can be used for the device you are configuring will be shown in the
object window. The following table shows the availability of indicator and control objects for
the Basic Panels.
Overview
KP300 Basic
KP400 Basic
KTP400 Basic
KTP600 Basic
KTP1000 Basic
TP1500 Basic
Bar Yes Yes
User view Yes Yes
Date/time field Yes Yes
I/O field Yes Yes
Ellipse Yes Yes
Graphic view Yes Yes
Graphic I/O field Yes Yes
Help indicator Yes No
Circle Yes Yes
Trend view Yes Yes
Line Yes Yes
Alarm view
Alarm window
Yes Yes
Alarm indicator Yes Yes
Rectangle Yes Yes
Recipe view Yes Yes
Button Yes Yes
Switch Yes Yes
Symbolic I/O field Yes Yes
System diagnostics view Yes Yes
Text field Yes Yes
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2659
See also
Overview of objects (Page 2565)
10.1.8.2 Objects
Bar
Application
The tags are displayed graphically using the "Bar" object. The bar graph can be labeled with
a scale of values.
Layout
In the Inspector window, you customize the settings for the position, shape, style, color, and
font types of the object. You can adapt the following properties in particular:
Color transition: Specifies the change in color display when limit values are exceeded.
Displaying the limit lines / limit markers: Shows the configured limit as a line or marker.
Define bar segments: Defines the gradations on the bar scale.
Define scale gradation: Defines the subdivisions, scale markings and intervals of a bar
scale.
Color transition
You define how the color change is represented in "Properties > Properties > Appearance" in
the Inspector window.
Color transition Description
"Segmented" If a particular limit was reached, the bar changes color segment by segment.
With segment by segment representation, you visualize, for example, which
limits are exceeded by the displayed value.
"Entire bar" If a particular limit was reached, the entire bar changes color.
Displaying limit lines and limit markers
You display the configured limit in the bar as a line or marking in Runtime using the "Lines"
and "Markings" property:
1. In the Inspector window, select "Properties > Properties > Appearance":
2. Activate "Lines" and "Markings".
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2660 System Manual, 01/2013,
Define bar segments
Use the "Subdivisions" property to define the number of segments into which the bar is divided
by the main gradations on the scale.
Use the "Interval" property to divide the distance between the main gradations. The value
appears as the difference in value between two adjacent main gradations:
1. In the Inspector window, select "Properties > Properties > Scales":
2. Activate "Show scale."
3. Select the corresponding value for "Settings > Subdivisions".
4. Select the corresponding value for "Settings > Marks label".
5. Select the corresponding value for "Large interval > Interval".
See also
Device-Specific Nature of the Objects (Page 2659)
User view
Application
The "User view" object is used to set up and administer users and authorizations.
Note
Do not use the simple user view in a group.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2661
Layout
In the Inspector window, you customize the position, shape, style, color and font types of the
object. You can adapt the following properties in particular:
Number of lines: Specifies the maximum number of visible entries.
Number of lines
The number of lines in the user view displayed in Runtime is specified in the Inspector window.
The setting for the number of lines is only effective if the property "Fit object to contents" is
active.
1. In the Inspector window, select "Properties > Properties > View".
2. Enter an integer value under "Number of lines".
3. In the Inspector window, activate "Properties > Properties > Layout".
4. Activate "Fit object to contents."
See also
Device-Specific Nature of the Objects (Page 2659)
Simple user view (Page 3482)
Configuring a user view (Page 2838)
Date/time field
Application
The "Date/time field" object shows the system time and the system date. The appearance of
the "Date/time field" depends on the language set on the HMI device.
Layout
In the Inspector window, you customize the position, style, colors and font types of the object.
You can adapt the following properties in particular:
Display system time: Specifies that the system time is displayed.
Include tag: Specifies that the time of the connected tag is displayed.
Long date/time format: This setting defines the format displayed for the data and time.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2662 System Manual, 01/2013,
Display system time
The time displayed in the "Date/time field" on the HMI device is specified in the inspector
window.
1. In the Inspector window, select "Properties > Properties > General".
2. Activate "Format > System time".
Using tags
The time of the interconnected tag is displayed in the date/time field.
1. In the Inspector window, select "Properties > Properties > General".
2. In the "Format" area, select a tag with the "DateTime" data type, e.g. an internal tag.
Long date/time format
Visualization of the date and time is specified in the "Format" area under "General" in the
inspector window.
Option Description
"Enabled" Date and time are displayed in full, e.g. "Sunday, December 31, 2000 10:59:59
AM"
"Disabled" Date and time are displayed in short form, e.g. "12/31/2000 10:59:59 AM"
See also
Device-Specific Nature of the Objects (Page 2659)
I/O field
Application
The "I/O field" object is used to enter and display process values.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2663
Layout
In the Inspector window, you customize the position, shape, style, color and font types of the
object. You can adapt the following properties in particular:
Mode: Specifies the response of the object in Runtime.
Display format: Specifies the display format in the I/O field for input and output of values.
Hidden input: Specifies whether the input value is displayed normally or encrypted during
input.
Note
Reports
In reports, I/O fields only output data. "Output" mode is preset. Properties for configuring
input are not available, e.g. "hidden input".
Mode
The response of the I/O field is specified in the Inspector window in "Properties > Properties
> General > Type".
Mode Description
"Input" Values can only be input into the I/O field in runtime.
"Input/output" Values can be input and output in the I/O field in runtime.
"Output" The I/O field is used for the output of values only.
Layout
The "display format" for the input and output of values is specified in "Properties > Properties
> General > Format" in the Inspector window.
Layout
"Binary" Input and output of values in binary form
"Date" Input and output of date information. The format depends on the language setting
on the HMI device.
"Date/time" Input and output of date and time information. The format depends on the
language setting on the HMI device.
"Decimal" Input and output of values in decimal form
"Hexadecimal" Input and output of values in hexadecimal form
"Time" Input and output of times. The format depends on the language setting on the HMI
device.
"Character string" Input and output of character strings.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2664 System Manual, 01/2013,
Note
Data formats
Not all data formats are available for selection for Runtime Professional.
Hidden input
In Runtime the input can be displayed normally or encrypted, for example for hidden input of
a password. A "*" is displayed for every character during hidden input. The data format of the
value entered cannot be recognized.
1. In the Inspector window, select "Properties > Properties > Response":
2. Activate "Hidden input".
Avoid overlaps in output fields
If several I/O fields are configured as output fields with a transparent background in a screen,
these I/O fields may overlap. The transparent part of the one field covers the digits of the other
field. This may cause display problems in Runtime. In order to avoid such overlaps, set the
margins of the I/O fields to zero in the object properties under "Properties > Properties >
Appearance". Activate "Properties > Properties > Layout > Fit object to contents."
See also
Device-Specific Nature of the Objects (Page 2659)
Ellipse
Application
The "Ellipse" is an enclosed object that can be filled with a color or pattern.
Layout
In the Inspector window you can customize the settings for the object position, geometry, style,
frame and color. You can adapt the following properties in particular:
Horizontal radius: Specifies the horizontal radius of the elliptical object.
Vertical radius: Specifies the vertical radius of the elliptical object.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2665
Horizontal radius
The horizontal radius of the "Ellipse" object is specified in the Inspector window. The value is
entered in pixels.
1. In the Inspector window, select "Properties > Properties > Layout".
2. Enter a value between 0 and 2500 under "Horizontal."
Vertical radius
The vertical radius of the "Ellipse" object is specified in the Inspector window. The value is
entered in pixels.
1. In the Inspector window, select "Properties > Properties > Layout".
2. Enter a value between 0 and 2500 at "Vertical."
See also
Device-Specific Nature of the Objects (Page 2659)
Rotating objects (Page 2580)
Flipping objects (Page 2581)
Graphic view
Application
The "Graphic view" object is used to display graphics.
Layout
In the Inspector window, you customize the position, shape, style, color and font types of the
object. You can adapt the following properties in particular:
Graphic: Specifies the graphic file that is displayed in the object.
Stretch graphic: Specifies the automatic size stretching for objects with graphics.
Transparent color: Specify whether or not the transparent color is used for the graphic.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2666 System Manual, 01/2013,
Inserting graphics
The following graphic format is used in the "Graphic view" object: *.bmp, *.tif, *.png, *.ico, *.emf,
*.wmf, *.gif, *.jpg or *.jpeg. You may also use graphics as OLE objects in the Graphic view .
1. In the Inspector window, select "Properties > Properties > General":
2. Select the graphic that you wish to insert.
The graphic preview is shown in the right pane.
3. Click "Apply" to insert the graphic in the Graphic view .
Stretch graphic
Whether a graphic displayed in a Graphic view is stretched to the size of the Graphic view in
runtime is specified in the Inspector window.
1. Click "Properties > Properties > Layout" in the inspector window.
2. Select the required size adjustment for the graphic.
Transparent color
This property defines whether the transparent color is used for the graphic to be displayed.
1. Click "Properties > Properties > Appearance" in the inspector window:
2. Activate "Background > Transparent".
3. Select a transparent color.
Note
When using bitmaps in WinCC screens the "Transparent color" setting demands a high
character performance in the layout on the panel. Visualization performance is enhanced
by disabling the "Transparent" setting in the properties of the relevant display object. This
restriction applies in particular when bitmaps are used as background image.
Note
Basic Panels
The "Transparent" property is not available for Basic Panels.
See also
Device-Specific Nature of the Objects (Page 2659)
Storing an external image in the graphics library. (Page 2587)
Options for Editing Objects (Page 2568)
Objects for Basic Panels (Page 2659)
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2667
Graphic I/O field
Application
The "Graphic I/O field" object can be used to configure a list for display and selection of graphic
files.
Layout
In the Inspector window, you customize the position, shape, style, color and font types of the
object. You can adapt the following properties in particular:
Mode: Specifies the response of the object in Runtime.
Scroll bar type: Specifies the graphic layout of the scroll bar.
Note
Basic Panels
The scroll bar is not available for Basic Panels.
Note
Reports
Graphic I/O fields output exclusively graphics in reports. "Output" mode is preset. Properties
for configuring the selection of graphics are not available, e.g. "scroll bar".
Mode
The response of the "Graphic I/O field" object is specified under "Properties > Properties >
General > Type > Mode" in the Inspector window.
Mode Description
"Input" The "Graphic I/O field" object is only used to select graphics.
"Input/output" The "Graphic I/O field" object is used to select and display graphics.
"Output" The "Graphic I/O field" object is used to display graphics only.
"Two states" The "Graphic I/O field" object is only used to display graphics and can have a
maximum of two states.
You use no graphics list but insert one graphic each for the "ON" and "OFF"
state.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2668 System Manual, 01/2013,
Stretch graphic
Whether a graphic displayed in a graphic I/O field is stretched to the size of the view in runtime
is specified in the Inspector window.
1. In the Inspector window, select "Properties > Properties > Layout".
2. Select the required size adjustment for the graphic.
Scroll bar type
The response for the graphic representation of the scroll bar is specified under "Properties >
Properties > Appearance > Scroll Bar > Type" in the Inspector window.
Type Description
"Permanent" The scroll bar is always visible.
"No scrollbar" The scroll bar is not visible.
"Visible after clicking" The scroll bar is made visible by a mouse click.
See also
Device-Specific Nature of the Objects (Page 2659)
Symbolic I/O field (Page 2684)
Help indicator
Application
The object "help indicator" is available for the HMI devices OP 73 and KP300 Basic. If a a
tooltip exists for the selected object, the help indicator is displayed during runtime. If a tooltip
was configured for the opened screen, the help indicator always remains visible.
You configure the object "help indicator" exclusively in the global screen.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2669
Layout
You can adapt the following properties in the Inspector window:
Position: Determines the position of the object "Help indicator."
Position
You can use this property to set the position of the object "Help indicator."
1. Select the object "Help indicator" in the template.
2. In the Inspector window, select "Properties > Properties > Layout".
3. Enter a value for X and Y. You can also use the cursor keys to position the selected object.
If you have configured a screen object at this position, the visible help indicator covers the
screen object. The help indicator is covered only by incoming system alarms and dialogs.
See also
Device-Specific Nature of the Objects (Page 2659)
Circle
Application
The "Circle" object is a closed object which can be filled with a color or pattern.
Layout
In the Inspector window you can customize the settings for the object position, geometry, style,
frame and color. You can adapt the following properties in particular:
Radius: Specifies the size of the circle.
Radius
The radius of the "Circle" object is specified in the Inspector window. The value is entered in
pixels.
1. In the Inspector window, select "Properties > Properties > Layout".
2. Enter a value between 0 and 2500 in the "Radius" area.
See also
Device-Specific Nature of the Objects (Page 2659)
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2670 System Manual, 01/2013,
Trend view
Application
The trend view is meant for the graphical representation of tag values from the current process
or from a log in form of trends.
Layout
In the Inspector window, you customize the position, shape, style, color, and font types of the
object. You can adapt the following properties in particular:
Display value table, ruler and grid: Specifies whether a value table, a ruler or a grid is
displayed in addition to the coordinate system to improve legibility.
Toolbars: Defines the display of the control elements.
Display value table, ruler and grid
For improved legibility a value table, a ruler and a grid can be displayed in Runtime.
1. Activate "Properties > Properties > Appearance > Show ruler".
2. Activate "Properties > Properties > Table > Show table".
3. Activate "Properties > Properties > Table > Show grid".
Toolbars
The layout of the control elements is defined in the "Properties > Properties > Toolbar"
inspector window.
Note
Basic Panels
As archiving is not possible for Basic Panels, the control elements are not available.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2671
Toolbar button Brief description Description
"Go to start" Scrolls back to the beginning of the trend recording.
The start values with which the trend recording started
are displayed.
"Zoom in" Zooms into the displayed time section.
"Zoom out" Zooms out of the displayed time section.
"Ruler backward" Moves the ruler back.
"Ruler forward" Moves the ruler forward.
"Backward" Scrolls back one display width.
"Forward" Scrolls forward one display width.
"Ruler" Shows or hides the ruler. The ruler displays the X-
value associated with a Y-value.
"Start/stop" Stops trend recording or continues trend recording.
Configuration behavior
Displaying column headers
The layout of the table in the trend view depends on the view settings in the Control Panel.
Depending on the setting, the column headers may be truncated. This setting is found under
"Display > Appearance" in the control panel. To display column headers correctly, set the
display in "Windows and buttons" to "Windows Classic" style.
This behavior only occurs during configuration. The column headers are displayed correctly
in Runtime.
Consistency test
If warnings or errors are displayed in the output window during a consistency check in
connection with trend views, clicking "Go to Error/Tag" on the shortcut menu will not always
take you to the exact error position. In some cases only the trend view is shown as cause of
error.
Adding, configuring, and removing trends
The trends of the trend view are managed in the Inspector window under "Properties >
Properties > Trend." You can copy trends between different trend views.
See also
Device-Specific Nature of the Objects (Page 2659)
Configuring trend displays for values from the PLC (Page 2731)
Touch and key operation (Page 3476)
Overview (Page 3475)
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2672 System Manual, 01/2013,
Line
Application
The "Line" object is an open object. The line length and gradient slope are defined by the height
and width of the rectangle enclosing the object.
Layout
In the Inspector window, you customize the settings for the object position, shape, style, and
color. You can adapt the following properties in particular:
Line style
Line start and end
Line style
The representation of the line is specified under "Properties > Properties > Appearance" in the
Inspector window. The line is shown without interruption if you select "Solid", for example.
Note
The line styles available depend on the selected HMI device.
Line start and end
The start and end points of the line are specified under "Properties > Properties > Appearance
> Line ends" in the Inspector window.
Use arrow point, for example, as start and end point. The available start and end points depend
on the device.
See also
Device-Specific Nature of the Objects (Page 2659)
Alarm view
Application
Alarms are indicated in the Alarm view or in the Alarm window of the HMI device.
The following screen contains a simple alarm view:
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2673
Layout
In the Inspector window, you customize the position, shape, style, color and font types of the
object.
Note
The fonts available for selection depend on the "Language and fonts" you have configured
in the Runtime settings.
You can adapt the following properties in particular:
Control elements: Defines the operator controls of the alarm display.
Alarm classes: This setting defines which alarm classes are displayed in the alarm view.
Columns: Specifies the displayed columns in runtime.
Note
If you have different alarm classes output, these will be initially sorted into alarm classes
in runtime, and then by when the alarm occurred.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2674 System Manual, 01/2013,
Control elements
The control elements that can be used to control the alarm display in runtime are specified in
the Inspector window under "Display > Settings". The following table shows the control
elements in the alarm view, and what they do:
Button Function
"Info text" Displays info text for an alarm.
"Acknowledge" Acknowledges an alarm.
"Loop-In-Alarm" Switches to the screen containing information about the error that
has occurred.
Select alarm classes
1. Click "Properties" in the Inspector window.
2. Under "Alarm classes" activate the alarm classes to be displayed in the alarm view in
runtime .
Define columns
Define the columns to be displayed in the alarm view in runtime in the Inspector window.
1. In the Inspector window, click "Properties > Columns".
2. Activate the columns that are to be displayed in runtime under "Columns".
Displaying column headers
The layout of the alarm view is dependent on the view settings in the control panel. Depending
on the setting, the column headers may be truncated. This setting is found under "Display >
Layout tab" in the control panel. To display column headers correctly, set the display in
"Windows and buttons" to "Windows Classic" style.
This behavior only occurs during configuration. The column headers are displayed correctly
in runtime.
Note
In the engineering system you can dynamically control the visibility of an object, for example,
in the "Animations" group of the Inspector window. In runtime, the "Simple alarm view" does
not support animations. If you have configured an animation and, for example, wish to perform
a consistency check of the project, then an error alarm is issued in the Output window.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2675
See also
Device-Specific Nature of the Objects (Page 2659)
Alarm window (Page 2676)
Alarm indicator (Page 2678)
Configuring an alarm view (Page 2757)
Alarm window
Application
Alarms are indicated in the Alarm view or in the Alarm window of the HMI device. The layout
and operation of the Alarm window are similar to that of the Alarm view. The Alarm window
has the following characteristics that are the same as in the Alarm view:
Simple alarm window
Advanced alarm window
Alarm line
Note
Basic Panels
Only the simple alarm window is available for Basic Panels.
The Alarm window is configured in the "Global screen" editor.
The Alarm window is independent of the process screen. Depending on the configuration, the
Alarm window opens automatically as soon as a new, unacknowledged alarm has been
received. If applicable, the Alarm window is configured so that it only closes after all alarms
have been acknowledged. The following figure shows an advanced Alarm window:
Note
In the engineering system you dynamize, for example, the visibility of an object in "Properties
> Animations" in the Inspector window. In runtime, the "Simple alarm window" object does
not support animations. If you have configured an animation and, for example, wish to perform
a consistency check of the project, then an error alarm is issued in the Output window.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2676 System Manual, 01/2013,
Layout
In the Inspector window, you customize the position, shape, style, color and font types of the
object. You configure the Alarm window in the same way as the Alarm view. In addition you
adapt the following properties:
Fixed alarm windows: Specifies that the Alarm window retains the focus after a screen
change.
Window: You define the operator input and response of the Alarm window in runtime.
Note
If you have different alarm classes output, these will be initially sorted into alarm classes
in runtime, and then by when the alarm occurred.
Control elements
The control elements that can be used to control the alarm view in runtime are specified in the
Inspector window under "Properties >Display > Settings". The following table shows the control
elements in the Alarm window, and what they do:
Button Function
"Tooltip" Displays a tooltip for an alarm.
"Acknowledge" Acknowledges an alarm.
"Loop-In-Alarm" Switches to the screen containing information about the error that
has occurred.
Access protection in runtime
Configure access protection under "Properties > Properties > Security" in the Inspector window
of the alarm view. If a logged-on user has the required authorization, he can acknowledge and
edit alarms using the operator controls in the alarm view. If the logged-in user does not have
the required authorization, or if no user is logged in, clicking the "Acknowledge" or "Edit" buttons
or double-clicking an alarm line opens the login dialog box.
Note
Basic Panels
Access protection is not available for Basic Panels.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2677
Activating the focus of the Alarm window
Select the following option so that the Alarm window does not lose the focus after a screen
change:
1. In the Inspector window, select "Properties > Properties > Mode":
2. Enable "Label".
Window
Define the response of the Alarm window under "Properties > Properties > Mode > Window"
in the Inspector window. The following table shows the possible properties:
Option Function
Automatic display The Alarm window is automatically displayed when a system alarm
occurs, for example.
Closable The window closes again after a set time has elapsed. You define the
display duration in the alarm settings.
Modal The Alarm window is linked to a confirmation, such as: Alarm must be
acknowledged. If the modal alarm window has the focus, the buttons in
the screen behind it cannot be used. The functions configured for a
function key are carried out.
Sizeable You can change the size of the Alarm window in runtime.
See also
Device-Specific Nature of the Objects (Page 2659)
Alarm view (Page 2673)
Configuring an alarm window (Page 2759)
Alarm indicator
Application
The alarm indicator is a graphic symbol that shows current errors or errors that need to be
acknowledged, depending on the configuration. The alarm indicator is configured in the "Global
screen" editor. The following figure shows an alarm indicator:
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2678 System Manual, 01/2013,
Alarm indicator OP 73
A "simple" alarm indicator is available for the HMI OP 73. The following diagram shows the
alarm indicator for the OP 73 HMI devices:
The "simple" alarm indicator shows alarms to be acknowledged or alarms which have already
been acknowledged and have not yet gone. Only the position can be defined for the "simple"
alarm indicator. The alarm indicator is displayed on the device at the selected position. If you
have configured a screen object at this position, the visible alarm indicator covers the screen
object. The alarm indicator is covered by system dialogs, such as the login dialog, Help dialog,
and alarm windows.
Layout
In the Inspector window, you customize the position, shape, style, color and font types of the
object. You can adapt the following properties in particular:
Alarm classes: Establishes the alarm classes where the alarm indicator is displayed.
Operator control in Runtime: Defines the operator actions in Runtime that cause the Alarm
window to open.
Alarm classes
You define which alarm classes are shown with an alarm indicator in "General > Alarm classes"
in the Inspector window. Alarm classes, such as "Warnings" or "Errors".
Define operator control in Runtime
1. Select the alarm indicator in the screen.
2. Click "Events > Click" or "Click when flashing" in the Inspector window.
3. The "function list" opens. Click the first line of the function list. The list of system functions,
and scripts available in the project opens.
4. Select the "ShowAlarmWindow". system function under "Alarms."
5. Under "object name" select the name of the Alarm window from the selection list. Under
"Layout", define whether the Alarm window should be visible, hidden, or should toggle
between the two states.
See also
Device-Specific Nature of the Objects (Page 2659)
Alarm view (Page 2673)
Configuring an alarm indicator (Page 2760)
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2679
Rectangle
Application
The "Rectangle" is a closed object which you can fill with a color.
Layout
In the Inspector window, you customize the position, shape, style, color and font types of the
object. You can adapt the following properties in particular:
Corner radius: Specifies the horizontal and vertical distance between the corner of the
rectangle and the start point of a rounded corner.
Corner radius
The corners of the "Rectangle" object can be rounded to suit your requirements. When the
properties "X" and "Y" are set to the 100 % value, the rectangle is displayed as an ellipse. As
soon as one of the properties has the value 0%, a normal rectangle without a rounded corner
is shown.
1. Click "Properties > Properties > Layout" in the inspector window.
2. Enter a value for "X" in the "Corner radius" area.
The input value is the percentage proportion of half the width of the rectangle.
3. Enter a value for "Y" in the "Corner radius" area.
The input value is the percentage proportion of half the height of the rectangle.
See also
Device-Specific Nature of the Objects (Page 2659)
Rotating objects (Page 2580)
Flipping objects (Page 2581)
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2680 System Manual, 01/2013,
Recipe view
Application
The "Recipe view" object is used to display and modify recipes.
Layout
In the Inspector window, you customize the position, geometry, style, color and font types of
the object. You can adapt the following properties in particular:
Control elements: Specifies the menu commands of the recipe view.
Control elements
The menu commands with which the recipe view is operated in Runtime are configured under
"Properties > Buttons" in the inspector window.
Menu command Description
"Tooltip" Calls up the configured tooltip for the selected recipe.
"New record" Creates a new recipe record in the recipe.
"Delete record" Deletes the selected record.
"Saving" Saves the modified record with its current name.
"Save as" Saves the modified record with a new name.
"Write to PLC" Sends the current value to the PLC.
"Read from PLC" Reads the current value from the PLC.
See also
Device-Specific Nature of the Objects (Page 2659)
Simple recipe view (Page 2801)
Displaying recipes (Page 2796)
Configuring the simple recipe view (Page 2812)
Description of the simple recipe view (Page 2815)
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2681
Switch
Application
The "Switch" object is used to configure a switch that is used to switch between two predefined
states in runtime. The current state of the "Switch" object can be visualized with either a label
or a graphic.
The following figure shows a "Switch" type switch.
Layout
In the Inspector window, you customize the position, shape, style, color and font types of the
object. In particular, you can customize the following property:
Type: Defines the graphic representation of the object.
Type
Button visualization is specified at "Properties > Properties > General >Type" in the Inspector
window.
Type Description
"Switch" The two states of the "Switch" are displayed in the form of a switch. The
position of the switch indicates the current state. The state is changed in
runtime by sliding the switch.
You specify the direction of movement of the switch in "Switch orientation"
with this type.
"Switch with text" The switch is shown as a button. The current state is visualized with a label.
In runtime click on the button to actuate the switch.
"Switch with graphic" The switch is shown as a button. The current state is visualized with a graphic.
In runtime click on the button to actuate the switch.
Note
Basic Panels
The "Switch" type is not available for Basic Panels.
See also
Device-Specific Nature of the Objects (Page 2659)
Overview of objects (Page 2565)
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2682 System Manual, 01/2013,
Button
Application
The "Button" object allows you to configure an object that the operator can use in runtime to
execute any configurable function.
Layout
In the Inspector window, you customize the position, shape, style, color and font types of the
object. You can adapt the following properties in particular:
Mode: Defines the graphic representation of the object.
Text / Graphic: Defines whether the Graphic view is static or dynamic.
Define hotkey: Defines a key, or shortcut that the operator can use to actuate the button.
Note
You can only define a hotkey for HMI devices with keys.
Mode
The button display is defined in "Properties > Properties > General >Mode" in the Inspector
window.
Mode Description
"Invisible" The button is not visible in runtime.
"Text" The current state of the button is visualized with a label.
"Graphic" The current state of the button is visualized with a graphic.
Depending on the device, further options are available:
Text / Graphic
The "Mode" property settings are used to define whether the display is static or dynamic. The
display is defined in "Properties > Properties > General >Text" or "Graphic" in the Inspector
window.
Your options for the type "Graphic" include the following.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2683
Type Option Description
"Graphic" "Graphic" "Graphic OFF" is used to specify a graphic that is displayed in the button
when the state is "OFF".
If you enable "Graphic ON", you can enter a graphic for the "ON" state.
"Graphics
list"
The graphic in the button depends on the state. The entry from the graphics
list corresponding to the state is displayed.
Define hotkey
In the Inspector window, a key or key combination is defined that the operator can use to
control the button in runtime.
1. In the Inspector window, select "Properties > Properties > General":
2. Select a key or key combination from the selection list in the "Hotkey" area.
See also
Device-Specific Nature of the Objects (Page 2659)
Example: Configuring a button for language switching (Page 2627)
Example: Configuring a button with logon dialog box (Page 2846)
Example: Configuring a button with access protection (Page 2850)
Symbolic I/O field
Application
The "Symbolic I/O field" object can be used to configure a selection list for input and output of
texts in runtime.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2684 System Manual, 01/2013,
Layout
In the Inspector window, you customize the position, shape, style, color and font types of the
object. You can adapt the following properties in particular:
Mode: Specifies the response of the object in runtime.
Text list: Specifies the text list that is linked to the object.
Button for selection list: Specifies that the object has a button to open the selection list.
Note
Reports
In reports, symbolic I/O fields only output data. "Output" mode is preset. Properties for
configuring the selection of graphics are not available, e.g. "button for selection list".
Mode
The response of the symbolic I/O field is specified in the Inspector window in "Properties >
Properties > General > Type".
Mode Description
"Output" The symbolic I/O field is used to output values.
"Input" The symbolic I/O field is used to input values.
"Input/output" The symbolic I/O field is used for the input and output of values.
"Two states" The symbolic I/O field is used only to output values and has a maximum of two
states. The field switches between two predefined texts. This is used, for
example, to visualize the two states of a valve: closed or open.
Note
The behavior possible for the symbolic I/O field depends on the Runtime.
Text list
In the Inspector window, you specify which text list is linked to the symbolic I/O field.
1. In the Inspector window, select "Properties > Properties > General".
2. Under "Contents" open the selection list for "Text list".
3. Select a text list.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2685
Button for selection list
The "Button for selection list" property is used to display a button for opening the selection list.
1. Select "Properties > Properties > Layout" in the Inspector window.
2. Activate "Response > Button for selection list".
Note
Basic Panels
The "Button for selection list" option is not available for Basic Panels.
See also
Device-Specific Nature of the Objects (Page 2659)
Graphic I/O field (Page 2668)
System diagnostics view
Introduction
The system diagnostics view offers you an overview of all the available devices in your plant.
You navigate directly to the cause of the error and to the relevant device. You have access to
all diagnostics-capable devices which you have configured in the "Devices & networks" editor.
Application
The system diagnostics view enables you to achieve the maximum level of detail of the
diagnostics data. A precise diagnosis is possible, as all the available data is displayed. You
have the system status of the entire plant at one glance.
Basic Panels support only the "Basic system diagnostics view".
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2686 System Manual, 01/2013,
Three different views are available in the system diagnostics view.
Device view
Diagnostic buffer view
Detail view
Device view
The device view of the system diagnostics view shows all the available links in tabular form.
Double-clicking a link opens the detail view. The device view is only displayed if more than
one link has been created in the "Devices & Networks" editor.
Diagnostic buffer view
In the diagnostic buffer view, the current data from the diagnostic buffer is displayed.
Detail view
The detail view shows detailed information on the selected link. You cannot sort error texts in
the detail view. The detail view is only available if there is an integrated link to an S7 1200 or
S7 1500
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2687
Layout
In the Inspector window, you customize the position, shape, style, color and font type of the
object. You can adapt the following properties in particular:
Lines per entry: Specifies the number of lines that are shown for an entry.
Configuring the system diagnostics view
1. Drag-and-drop the system diagnostics view from the toolbox.
2. In the Inspector window, select "Properties > Layout".
3. Enter a number under "Lines per entry", i.e. 5.
4. Select an authorization for operation in "Properties > Properties > Security".
See also
System diagnostics views (Page 3413)
Text field
Application
The "Text field" is a closed object which you can fill with a color.
Layout
In the Inspector window, you customize the position, shape, style, color and font types of the
object. You can adapt the following properties in particular:
Text: Specifies the text for the text field.
Size of text field: Defines whether the size of the object is adapted to the space required
by the largest list entry.
Text
Specify the text for the text field in the Inspector window.
1. In the Inspector window, select "Properties > Properties > General".
2. Enter a text.
For texts over several lines you can set a line break by pressing the key combination <Shift
+ Enter>.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2688 System Manual, 01/2013,
Size of text field
In the Inspector window, you can define whether the size of the object is adapted to the space
required by the largest list entry.
1. In the Inspector window, select "Properties > Properties > Layout".
2. Activate "Resize > Fit to contents".
See also
Device-Specific Nature of the Objects (Page 2659)
10.1.9 Configuring screen navigation
10.1.9.1 Basics for screen navigation
Types of navigation for the screen change
For a production process consisting of multiple subprocesses, you will configure multiple
screens. You have the following options to enable the operator to switch from one screen to
the next in Runtime:
Assign buttons to screen changes
Configuring screen changes at local function keys
Procedure
Before you create a screen change, define the plant structure and derive from it the screen
changes that you want to configure.
Create the start screen under "Runtime Settings > General > Start screen".
See also
Assign button with screen change (Page 2690)
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2689
10.1.9.2 Assign button with screen change
Introduction
Configure a button in the screen to switch between the screens on the HMI device during
operation.
Note
If you have set the "Visibility" of animations to "Hidden" in the Inspector window of a screen,
this screen cannot be called up in Runtime.
Requirements
You have created the project.
You have created the "Screen_2" screen.
"Screen_1" is created.
Procedure
1. Double-click "Screen_1" in the project navigation. The screen is displayed in the work area.
2. Move "Screen_2" from the project tree to the open screen by drag&drop.
A button with the name "Screen_1" is inserted.
3. In the Inspector window, select "Properties > Events > Click".
The "ActivateScreen" system function is displayed in the "Function list".
4. At the "Object number" attribute, define, if required, the tab sequence number of the object
on which the focus is to be set after a screen change. You can also specify a tag that
contains the object number.
Alternative procedure
1. Move a button from the "Tools" task card to "Screen2" by drag&drop.
2. In the Inspector window, select "Properties > Events > Click".
3. Select the "ActivateScreen" system function.
4. Select "Screen_2" for the "Screen number".
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
2690 System Manual, 01/2013,
Result
The operator goes to "Screen_1 with the button in Runtime. If you have specified an object
number, the object with this object number has the focus following a screen change.
See also
Basics for screen navigation (Page 2689)
10.1.9.3 Assign screen change to function key
Introduction
Configure a screen change function key in the screen to switch between the screens on the
HMI device during operation.
Note
If you have set the "Visibility" of animations to "Hidden" in the inspector window of a screen,
this screen cannot be called up in Runtime.
Requirements
You have created a project.
You have created the "Screen_2" screen.
You have created the "Screen_1" screen.
Procedure
1. Double click "Screen_1" in the project tree. The screen is displayed in the work area.
2. Move "Screen_2" from the project tree to a function key, e.g. "F2".
The configured function key displays a yellow triangle.
3. Click "Properties > Events > Press key" in the inspector window.
The "ActivateScreen" system function is displayed.
Result
The operator goes to the specified "Screen_2" with function key "F2" in Runtime.
Visualizing processes (Basic)
10.1 Creating screens
STEP 7 Basic V12.0
System Manual, 01/2013, 2691
10.2 Working with Tags
10.2.1 Basics
10.2.1.1 Basics of tags
Introduction
Process values are forwarded in runtime using tags. Process values are data which is stored
in the memory of one of the connected automation systems. They represent the status of a
plant in the form of temperatures, fill levels or switching states, for example. Define external
tags for processing the process values in WinCC.
WinCC works with two types of tag:
External tags
Internal tags
The external tags form the link between WinCC and the automation systems. The values of
external tags correspond to the process values from the memory of an automation system.
The value of an external tag is determined by reading the process value from the memory of
the automation system. It is also possible to rewrite a process value in the memory of the
automation system.
External tag
WinCC Automation system
Process value
Internal tags do not have a process link and only convey values within the WinCC.
Tags in WinCC
For external tags, the properties of the tag are used to define the connection that the WinCC
uses to communicate with the automation system and form of data exchange.
Tags that are not supplied with values by the process - the internal tags - are not connected
to the automation system. In the tag's "Connection" property, this is identified by the "Internal
tag" entry.
You can create tags in different tag tables for greater clarity. You then directly access the
individual tag tables in the "HMI tags" node in the project tree. The tags from all tag tables can
be displayed with the help of the table "Show all tags".
Visualizing processes (Basic)
10.2 Working with Tags
STEP 7 Basic V12.0
2692 System Manual, 01/2013,
See also
Overview of HMI tag tables (Page 2693)
Internal tags (Page 2698)
External tags (Page 2694)
Addressing external tags (Page 2695)
Creating external tags (Page 2699)
Basics on arrays (Page 2726)
Cycle basics (Page 2729)
10.2.1.2 Overview of HMI tag tables
Introduction
HMI tag tables contain the definitions of the HMI tags that apply across all devices. A tag table
is created automatically for each HMI device created in the project.
In the project tree there is an "HMI tags" folder for each HMI device. The following tables can
be contained in this folder:
Standard tag table
User-defined tag tables
All tags
The following tables are also available in an HMI tag table:
Discrete alarms
Analog alarms
With the help of these tables you configure alarms for the currently selected HMI tag.
In the project tree you can create additional tag tables in the HMI tags folder and use these to
sort and group tags and constants. You can move tags to a different tag table using a drag-
and-drop operation or with the help of the "Tag table" field. You activate the "Tag table" field
using the shortcut menu of the column headings.
Standard tag table
There is one standard tag table for each HMI device of the project. It cannot be deleted,
renamed or moved. The standard tag table contains HMI tags and, depending on the HMI
device, also system tags. You can declare all HMI tags in the standard tag table, or create
additional user-defined tag tables as you want.
User-defined tag tables
You can create multiple user-defined tag tables for each HMI device in order to group tags
according to your requirements. You can rename, gather into groups, or delete user-defined
tag tables. To group tag tables, create additional subfolders in the HMI tags folder.
Visualizing processes (Basic)
10.2 Working with Tags
STEP 7 Basic V12.0
System Manual, 01/2013, 2693
All tags
The "All tags" table shows an overview of all HMI tags and system tags of the HMI device in
question. This table cannot be deleted, renamed or moved.
Discrete alarms table
In the "Discrete alarms" table, you configure discrete alarms to the HMI tag selected in the
HMI tag table. When you configure a discrete alarm, multiple selection in the HMI tag table is
not possible. You configure the discrete alarms for each HMI tag separately.
Analog alarms table
In the "Analog alarms" table, you configure analog alarms to the HMI tag selected in the HMI
tag table. When you configure an analog alarm, multiple selection in the HMI tag table is not
possible. You configure the analog alarms for each HMI tag separately.
See also
Basics of tags (Page 2692)
10.2.1.3 External tags
Introduction
External tags allow communication (exchange of data) between the components of an
automation system, such as between the HMI device and the PLC.
Principle
An external tag is the image of a defined memory location in the PLC. You have read and write
access to this storage location from both the HMI device and from the PLC.
Since external tags are the image of a storage location in the PLC, the applicable data types
depend on the PLC which is connected to the HMI device.
In STEP 7, if you write a PLC control program, the PLC tags created in the control program
will be added to the PLC tag table. If you want to connect an external tag to a PLC tag, access
the PLC tags directly via the PLC tag table and connect them to the external tag.
Data types
All the data types which are available at the connected PLC are available at an external tag
in WinCC. Information about data types which are available for connection to other PLCs can
be found in the documentation about the respective communication drivers.
Visualizing processes (Basic)
10.2 Working with Tags
STEP 7 Basic V12.0
2694 System Manual, 01/2013,
See "Basics of communication (Page 2953)" for additional information.
Note
As well as external tags, area pointers are also available for communication between the HMI
device and PLC. You can set up and enable the area indicators in the "Connections" editor.
Update of tag values
For external tags, the current tag values are transmitted in runtime via the communication
connection between WinCC and the connected automation systems and then saved in the
runtime memory. Next, the tag value will be updated to the set cycle time. For use in the runtime
project, WinCC accesses tag values in the runtime memory that were read from the PLC at
the previous cycle time. As a result, the value in the PLC can already change whilst the value
from the runtime memory is being processed.
See also
Addressing external tags (Page 2695)
Basics of communication (Page 2953)
Basics of tags (Page 2692)
10.2.1.4 Addressing external tags
Introduction
The options for addressing external tags depend on the type of connection between WinCC
and the PLC in question. A distinction must be made between the following connection
types:
Integrated connection
Connections of devices which are within a project and were created with the "Devices &
Networks" editor are referred to as integrated connections.
Non-integrated connection
Connections of devices which were created with the "Connections" editor are referred to
as non-integrated connections. It is not necessary that all of the devices be within a single
project.
The connection type can also be recognized by its icon.
Integrated connection
Non-integrated connection
You can find additional information in the section "Basics of communication (Page 2953)".
Visualizing processes (Basic)
10.2 Working with Tags
STEP 7 Basic V12.0
System Manual, 01/2013, 2695
Addressing with integrated connections
An integrated connection offers the advantage that you can address a tag both symbolically
and absolutely.
For symbolic addressing, you select the PLC tag via its name and connect it to the HMI tag.
The valid data type for the HMI tag is automatically selected by the system. You have to
distinguish between the following cases when you address elements in data blocks:
Symbolic addressing of data blocks with optimized access and standard access:
During the symbolic addressing of a data block with optimized access and standard access,
the address of an element in the data block is dynamically assigned and is automatically
adopted in the HMI tag in the event of a change. You do not need to compile the connected
data block or the WinCC project for this step.
For data blocks with optimized access, only symbolic addressing is available.
For symbolic addressing of elements in a data block, you only need to recompile and reload
the WinCC project in case of the following changes:
If the name or the data type of the linked data block element or global PLC tag has changed.
If the name or the data type of the higher level structure node of a linked element in the
data block element or global PLC tag has changed.
If the name of the connected data block has changed.
Symbolic addressing is currently available with the following PLCs:
SIMATIC S7 1200
SIMATIC S7 1500
Symbolic addressing is also available if you have an integrated link.
Note
Symbolic addressing is not possible if you are using the "Date/Time" area pointer.
You can also use absolute addressing with an integrated connection. You have to use absolute
addressing for PLC tags from a SIMATIC S7 300/400 PLC. If you have connected an HMI tag
with a PLC tag and the address of the PLC tag changes, you only have to recompile the control
program to update the new address in WinCC. Then you recompile the WinCC project and
load it onto the HMI device.
In WinCC, symbolic addressing is the default method. To change the default setting, select
the menu command "Options > Settings". Select "Visualization > Tags" in the "Settings" dialog.
If required, disable the "Symbolic access" option.
The availability of an integrated connection depends on the PLC used. The following table
shows the availability:
Visualizing processes (Basic)
10.2 Working with Tags
STEP 7 Basic V12.0
2696 System Manual, 01/2013,
PLC Integrated connection Comments
S7 300/400 Yes The linking of tags is not checked in Runtime. If
the tag address changes in the PLC and the HMI
device is not compiled again and loaded, the
change is not registered in runtime.
S7 1200 Yes A validity check of the tag connection is
performed in runtime during symbolic
addressing. If an address is changed in the PLC,
the change is registered and an error message
is issued. In the case of absolute addressing, the
following behavior applies to the S7 300/400.
S7 1500 Yes A validity check of the tag connection is
performed in runtime during symbolic
addressing. If an address is changed in the PLC,
the change is registered and an error message
is issued. In the case of absolute addressing, the
following behavior applies to the S7 300/400.
Create an integrated connection in the "Devices & Networks" editor. If the PLC is contained in
the project and integrated connections are supported, you can then also have the connection
created automatically. To do this, when configuring the HMI tag, simply select an existing PLC
tag to which you want to connect the HMI tag. The integrated connection is then automatically
created by the system.
Addressing with non-integrated connections
In the case of a project with a non-integrated connection, you always configure a tag connection
with absolute addressing. Select the valid data type yourself. If the address of a PLC tag
changes in a project with a non-integrated connection during the course of the project, you
also have to make the change in WinCC. The tag connection cannot be checked for validity
in Runtime, an error message is not issued.
A non-integrated connection is available for all supported PLCs.
Symbolic addressing is not available in a non-integrated connection.
With a non-integrated connection, the control program does not need to be part of the WinCC
project. You can perform the configuration of the PLC and the WinCC project independently
of each other. For configuration in WinCC, only the addresses used in the PLC and their
function have to be known.
See also
External tags (Page 2694)
Basics of tags (Page 2692)
Basics of communication (Page 2953)
Visualizing processes (Basic)
10.2 Working with Tags
STEP 7 Basic V12.0
System Manual, 01/2013, 2697
10.2.1.5 Internal tags
Introduction
Internal tags do not have any connection to the PLC.
Principle
Internal tags are stored in the memory of the HMI device. Therefore, only this HMI device has
read and write access to the internal tags. You can create internal tags to perform local
calculations, for example.
You can use the HMI data types for internal tags.
The following HMI data types are available:
HMI data type Data format
Array One-dimensional array
Bool Binary tag
DateTime Date/time format
DInt Signed 32-bit value
Int Signed 16-bit value
LReal Floating-point number 64-bit IEEE 754
Real Floating-point number 32-bit IEEE 754
SInt Signed 8-bit value
UDInt Unsigned 32-bit value
UInt Unsigned 16-bit value
USInt Unsigned 8-bit value
WString Text tag, 16-bit character set
See also
Basics of tags (Page 2692)
Visualizing processes (Basic)
10.2 Working with Tags
STEP 7 Basic V12.0
2698 System Manual, 01/2013,
10.2.2 Working with tags
10.2.2.1 Creating tags
Creating external tags
Introduction
You can access an address in the PLC via a PLC tag using an external tag. The following
options are available for addressing:
Symbolic addressing
Absolute Addressing
You can find further details on symbolic addressing in section "Addressing external tags
(Page 2695)". If possible, use symbolic addressing when configuring a tag. You create tags
either in the standard tag table or in a tag table you defined yourself.
Requirement
You have opened the project.
A connection to the PLC is configured.
The Inspector window is open.
Procedure
To create an external tag, proceed as follows:
1. Open the "HMI tags" folder in the project tree and double-click the standard tag table. The
tag table open.
Alternatively, create a new tag table and then open it.
2. In the "Name" column, double-click "Add" in the tag table. A new tag is created.
3. Select the "Properties > Properties >General" category in the Inspector window and, if
required, enter a unique tag name in the "Name" field. The tag name must be unique
throughout the device.
4. If required, select the "Display name" field to enter a name to be displayed in Runtime. The
name to be displayed is language-specific and can be translated for the required Runtime
languages. The display name is available for Basic Panels, Panels and Runtime Advanced.
5. Select the connection to the required PLC in the "Connection" box. If the connection you
require is not displayed, you must first create the connection to the PLC. You create the
connection to a SIMATIC S7 PLC in the "Devices & Networks" editor. You create the
connection to external PLCs in the "Connections" editor.
If the project contains the PLC and supports integrated connections, you can also have the
connection created automatically. To do this, when configuring the HMI tag, simply select
an existing PLC tag to which you want to connect the HMI tag. The integrated connection
is then automatically created by the system.
Visualizing processes (Basic)
10.2 Working with Tags
STEP 7 Basic V12.0
System Manual, 01/2013, 2699
6. If you are working with an integrated connection, click the button in the "PLC tag" field
and select an already created PLC tag in the object list. Click the button to confirm the
selection.
7. If you are working with a non-integrated connection, enter the address from the PLC in the
"Address" field. The "PLC tag" field remains empty.
8. Configure the other properties of the tag in the inspector window.
You can also configure all tag properties directly in the tag table. To view hidden columns,
activate the column titles using the shortcut menu.
You can also create new tags alternatively directly at the application point, e.g. on an I/O field.
To do this, click the button in the object list. You then configure the new tag in
the Inspector window.
Result
An external tag has been created and linked to a PLC tag or an address in the PLC.
Alternative procedure
You can also create external HMI tags by dragging and dropping data block elements or global
PLC tags in an HMI tag table.
Visualizing processes (Basic)
10.2 Working with Tags
STEP 7 Basic V12.0
2700 System Manual, 01/2013,
See also
Creating internal tags (Page 2701)
Creating multiple tags (Page 2702)
Editing a Tag (Page 2703)
Tag limits (Page 2709)
Basics of tags (Page 2692)
Addressing external tags (Page 2695)
Creating internal tags
Introduction
You must at least set the name and data type for internal tags. Select the "Internal tag" item,
rather than a connection to a PLC.
For documentation purposes, it is a good idea to enter a comment for every tag.
Requirement
You have opened the project.
Procedure
1. Open the "HMI tags" folder in the project tree and double-click the entry "Standard tag
table". The tag table opens.
Alternatively, create and then open a new tag table.
2. Double-click "Add" in the "Name" column of the tag table. A new tag is created.
3. If the Inspector window is not open, select the "Inspector window" option in the "View" menu.
4. Select the "Properties > Properties >General" category in the Inspector window and, if
required, enter a unique tag name in the "Name" field. This tag name must be unique
throughout the project.
5. If required, select the "Display name" field to enter a name to be displayed in Runtime. The
name to be displayed is language-specific and can be translated for the required Runtime
languages. The display name is available for Basic Panels, Panels and Runtime Advanced.
6. Select "Internal tag" as the connection in the "Connection" field.
7. Select the required data type in the "Data type" field.
8. In the "Length" field, you must specify the maximum number of characters to be stored in
the tag according to the selected data type. The length is automatically defined by the data
type for numerical tags.
9. As an option, you can enter a comment regarding the use of the tag. To do so, click
"Properties > Properties > Comment" in the Inspector window and enter a text.
You can also configure all tag properties directly in the tag table. To view hidden columns,
activate the column titles using the shortcut menu.
Visualizing processes (Basic)
10.2 Working with Tags
STEP 7 Basic V12.0
System Manual, 01/2013, 2701
You can also create new tags alternatively directly at the application point, e.g. on an I/O field.
Click the button in the object list. You can then configure the new tag in the
Properties window that opens.
Result
An internal tag is created. You can now use this in your project.
In additional steps you can configure the tag, for example, by setting the start value and limits.
See also
Creating external tags (Page 2699)
Creating multiple tags
Introduction
In a tag table, you create additional identical tags by automatically filling the rows of the table
below a tag.
The tag names are incremented automatically when filling in automatically.
You can also use the auto fill function to fill table cells below a tag with a single tag property
and thus modify the corresponding tags.
If you apply the automatic filling in to already filled cells of a tab table, you will be asked whether
you want to overwrite the cells or insert new tags.
If you do not want to overwrite already configured tags, activate insert mode. Activate insert
mode by keeping the <Ctrl> key pressed during insertion. Already existing entries in the tag
table are moved down if insert mode is activated.
Requirement
You have opened the project.
A tag table is open.
The tag which is to serve as a template for other tags is configured.
Visualizing processes (Basic)
10.2 Working with Tags
STEP 7 Basic V12.0
2702 System Manual, 01/2013,
Procedure
1. If you want to create new tags, mark in the "Name" column the tag that should be used as
a template for the new tags.
If you want to copy a property of a tag to the tags below it, select the cell which contains
this property.
The selected cell will be highlighted in color and a small blue square will appear in its bottom
right corner. If you move the mouse over this square, the cursor will change to a black cross.
2. Hold down the mouse button and drag this square over the cells below that you wish to fill
automatically.
The marking will be extended to cover this area.
3. Now release the mouse button. All of the marked cells will be filled automatically.
New tags will be created in all empty cells in the marked area.
Result
Depending on which cells were selected, the function may automatically fill individual
properties or create new tags.
See also
Creating external tags (Page 2699)
10.2.2.2 Editing tags
Editing a Tag
Introduction
You can always rename, copy or delete tags.
When a tag is renamed, the new name must be unique for the whole device.
If you use the "Copy" command to copy a tag to the clipboard, the objects and references
linked to the tag are copied as well.
If you use the "Insert" command to add a tag to another device, the tag will be added without
the connected references. Only the object name of the reference will be inserted. If a reference
of the same name and valid properties exists in the target system, the existing reference will
then be connected to the copied tag.
If you copy a tag, the alarms linked to the tag are copied as well. If you add the copied tag to
another device, the tag is added together with the linked alarms.
Visualizing processes (Basic)
10.2 Working with Tags
STEP 7 Basic V12.0
System Manual, 01/2013, 2703
Requirement
The tag which you wish to rename, copy or delete must exist.
The tag table is open.
Renaming tags
1. In the "Name" field, select the tag in the tag table.
2. Select "Rename" from the shortcut menu.
3. Type in a new name.
The tag appears under its new name.
Copying tags
1. Select one or more tags in the tag table or in the Detail window.
2. Select "Copy" from the shortcut menu.
3. Click on the point at which you want to insert the tag. For example, click another tag table
in the same device or the tag table in a second device.
4. Select the "Insert" or "Extended insert" command from the shortcut menu. The tag is
inserted as described above.
Deleting a tag
1. Select one or more tags in the tag table.
2. Select the "Cross-reference" command from the "Tools" menu. In the "Cross-reference"
editor, check to see where the tags are used. In this manner, you can see what impact the
deletion of the tag will have on your project.
3. Select "Delete" in the pop-up menu of the tag.
All marked tags will be deleted.
Export and import of tags
WinCC gives you the option to export and import tags. With Export and Import, you have the
option to export tags from one project and import them into another project. There is also the
option to create larger numbers of tags outside of WinCC, edit them and subsequently import
into any WinCC project. See Importing and exporting tags (Page 3352) for additional
information.
Visualizing processes (Basic)
10.2 Working with Tags
STEP 7 Basic V12.0
2704 System Manual, 01/2013,
See also
Changing the tag configuration (Page 2705)
Configuring multiple tags simultaneously (Page 2705)
Using multiple tags simultaneously in a screen (Page 2706)
Reconnecting a tag (Page 2708)
Creating external tags (Page 2699)
Importing and exporting tags (Page 3352)
Changing the tag configuration
Introduction
You can modify tags at any time to adapt them to changed requirements in the project.
Changing the tag configuration
if you want to change the configuration of a tag, open the tag table in which the tag is contained.
Open the "Show all tags" tag table alternatively.
In the tag tables, you can perform such tasks as comparing and adjusting the properties of
multiple tags or sorting the tags by their properties.
Change the properties either directly in the table or in the inspector window.
If you change a tag property and this change causes a conflict with another property, it will be
highlighted in color to draw your attention to this fact. This could happen, for example, if you
connect the tag to another PLC which does not support this data type.
See also
Editing a Tag (Page 2703)
Configuring multiple tags simultaneously
Introduction
In WinCC, you can assign the same properties to multiple tags in a single operation. This
facilitates efficient programming.
Requirement
You created the tags you want to configure.
The tag table is open.
The Inspector window is open.
Visualizing processes (Basic)
10.2 Working with Tags
STEP 7 Basic V12.0
System Manual, 01/2013, 2705
Procedure
1. In the tag table, select all the tags that you want to configure at the same time.
If the selected property is identical for all the tags, the setting for this property will appear
in the Inspector window. The associated field will remain blank otherwise.
2. You can define the shared properties in the Inspector window or directly in the tag table.
if you change a property commonly on several tags, only this one property is changed. The
other properties of the tag remain unchanged.
Result
All marked tags will be reconfigured.
To edit tag properties which differ from one tag to the other, simply clear the multiple selection.
See also
Editing a Tag (Page 2703)
Using multiple tags simultaneously in a screen
Introduction
In WinCC, you can create multiple I/O fields that are linked with tags in one screen in a single
operation. This facilitates efficient programming.
Requirement
Several tags are set up.
A screen is open.
Visualizing processes (Basic)
10.2 Working with Tags
STEP 7 Basic V12.0
2706 System Manual, 01/2013,
Procedure
1. In the project tree, select the required tag table under "HMI tags".
2. Select the detail view at the bottom of the project tree. The detail view shows the tags that
exist in the selected tag group.
3. Mark the tags in the detail window.
4. Drag the tags to the screen. For each tag, this creates an I/O field that is connected to the
tag.
Note
When you move a PLC tag from the detail window to the work area by drag&drop, a network
and a connection are created additionally in the "Devices & Networks" editor.
See also
Editing a Tag (Page 2703)
Visualizing processes (Basic)
10.2 Working with Tags
STEP 7 Basic V12.0
System Manual, 01/2013, 2707
Reconnecting a tag
Introduction
WinCC enables you to automatically connect tags to addresses in the PLC. This procedure is
suitable if, for example, changes were made to the connection between the HMI device and
the PLC and the tag connections were lost. The function can also be used if you have
configured the control program and HMI project separately.
The shortcut menu "Reconnect PLC tag" is available for this.
The menu command is available under the following conditions:
An integrated connection to the PLC is present.
The absolute address from the PLC is entered in the HMI tag.
The HMI tag is configured with the correct data type.
The menu command is not available at a tag with symbolic addressing.
If you select multiple tags, the menu command is available if at least one of the selected tags
meets the above-mentioned requirements. Only the tags that meet the requirements are
connected.
Requirement
You have created an HMI tag.
The tag table is open.
A PLC tag with the absolute address from the PLC is present.
Procedure
Proceed as follows to reconnect tags:
1. Select the row with the tag in the tag table.
2. Open the shortcut menu and select the menu command "Reconnect PLC tag".
The system looks for a PLC tag whose absolute address and data type match the settings
for the HMI tag. If a matching PLC tag is found, the tag connection is established
immediately.
Result
The PLC tag is connected to the HMI tag.
See also
Editing a Tag (Page 2703)
Visualizing processes (Basic)
10.2 Working with Tags
STEP 7 Basic V12.0
2708 System Manual, 01/2013,
10.2.2.3 Configuring tags
Tag limits
Introduction
You can restrict the value range with limits for numerical tags.
Principle
You can specify a value range defined by a high and low limit for numerical tags.
If the process value violates the value range, you trigger a function list. If the operator enters
a value for the tag that is outside the configured value range, the input is rejected. The value
is not accepted.
Note
You enter the text of the analog alarms for limit violations in the "Analog alarms" editor.
Application example
Use the limit to warn the operator in good time when the value of a tag enters a critical range,
for example.
See also
Applying linear scaling to a tag (Page 2715)
Defining the start value of a tag (Page 2711)
Defining the acquisition cycle for a tag (Page 2719)
Defining Limits for a Tag (Page 2710)
Start value of a tag (Page 2711)
Updating the tag value in Runtime (Page 2712)
Linear scaling of a tag (Page 2713)
Connecting a tag to another PLC (Page 2715)
Indirect addressing of tags (Page 2716)
Addressing tags indirectly (Page 2717)
Using tags to trigger functions (Page 2718)
Address multiplexing (Page 2720)
Configuring address multiplexing with absolute addressing (Page 2721)
Configuring address multiplexing with symbolic addressing (Page 2723)
Creating external tags (Page 2699)
Visualizing processes (Basic)
10.2 Working with Tags
STEP 7 Basic V12.0
System Manual, 01/2013, 2709
Defining Limits for a Tag
Introduction
For numerical tags, you can specify a value range by defining a low and high limit.
Additionally, you configure the system to process a function list whenever a tag value drops
below or exceeds its configured value range.
Requirement
You created the tag for which you want to set limits.
The Inspector window with the properties for this tag is open.
Procedure
To define limits of a tag, follow these steps:
1. In the Inspector window select "Properties > Properties > Limits." If you want to define one
of the limits as a constant value, select "Constant" using the button. Enter a number in
the relevant field.
If you want to define one of the limits as a tag value, select "HMI tag" using the button.
Use the object list to define the tag for the limit.
2. To set an additional limit value for the tag, repeat step 1 with the appropriate settings.
Alternative procedure
You can also configure the high and low limit directly in the tag table. To view hidden columns,
activate the column titles using the shortcut menu.
Configuring a function list
You can configure a function list for exceeding the value range as follows:
1. If you want to start a function list when the value drops below the value range, click
"Properties > Events > Minimum violated" in the Inspector window. Create a function list in
this dialog.
2. If you want to start a function list when the value exceeds the value range, click "Properties
> Events > Maximum violated" in the Inspector window. Create a function list in this dialog.
Result
You have set a value range defined by a high and low limit for the selected tag. If the value
range is exceeded or undershot, a function list is carried out.
See also
Tag limits (Page 2709)
Visualizing processes (Basic)
10.2 Working with Tags
STEP 7 Basic V12.0
2710 System Manual, 01/2013,
Start value of a tag
Value of a tag at start of Runtime
You can configure a start value for numeric tags and tags for date/time values. The tag will be
preset to this value when Runtime starts. In this way, you can ensure that the tag has a defined
status when Runtime starts.
For external tags, the start value will be displayed on the HMI device until it is overwritten by
the PLC or by input.
If no start value was configured, the tag contains the value "0" when starting Runtime.
In WinCC Runtime Professional you can enter a tag value in place of the start value on a tag
with the "String" data type. The tag value is saved in the "Project texts" editor and is multilingual.
After the text has been translated, it is displayed in Runtime as a language-dependent start
value.
Application example
You can assign a default value to an I/O field. Enter the desired default value as start value
for the tag that is linked to the I/O field.
See also
Defining the start value of a tag (Page 2711)
Tag limits (Page 2709)
Defining the start value of a tag
Introduction
In WinCC you can configure a start value for a numeric tag and a tag for date/time values
which this adopts at Runtime start.
Requirement
You have created the tag for which you want to define a start value.
The Inspector window with the tag properties is open.
Procedure
To configure a start value, proceed as follows:
1. In the Inspector window select "Properties > Properties > Values."
2. Enter the desired "Start value."
Visualizing processes (Basic)
10.2 Working with Tags
STEP 7 Basic V12.0
System Manual, 01/2013, 2711
Alternative procedure
You can also configure the start value directly in the tag table. To view hidden columns, activate
the column titles using the shortcut menu.
Result
The start value you selected for the tag is transferred to the project.
See also
Tag limits (Page 2709)
Start value of a tag (Page 2711)
Updating the tag value in Runtime
Introduction
Tags contain process values which change while Runtime is running. Value changes are
handled differently at internal and external tags.
Principle
When Runtime starts, the value of a tag is equal to its start value. Tag values change in
Runtime.
In Runtime, you have the following options for changing the value of a tag:
A value change in an external tag in the PLC.
By input, for example, in an I/O field.
By running a system function, such as "SetValue."
Visualizing processes (Basic)
10.2 Working with Tags
STEP 7 Basic V12.0
2712 System Manual, 01/2013,
Updating the Value of External Tags
The value of an external tag is updated as follows:
Cyclic in operation
If you select the "Cyclic in operation" acquisition mode, the tag is updated in runtime as
long as it is displayed in a screen. The acquisition cycle determines the update cycle for
tag value updates on the HMI device. Cyclic acquisition is based on the selected scan cycle
time.
Cyclic continuous
If you select the "Cyclic continuous" acquisition mode, the tag will be updated continuously
in Runtime, even if it is not in the currently-open screen. This setting is activated for tags
that are configured to trigger a function list when their value changes, for example.
Only use the "Cyclic continuous" setting for tags that must truly be updated. Frequent read
operations increase communication load.
On demand
If you select the "On demand" acquisition mode, the tag is not updated cyclically. It will only
be updated on request, for example, by using the "Update Tag" system function.
See also
Tag limits (Page 2709)
Linear scaling of a tag
Introduction
Numeric data types can be processed with linear scaling. The process values in the PLC for
an external tag can be mapped onto a specific value range in the project.
Visualizing processes (Basic)
10.2 Working with Tags
STEP 7 Basic V12.0
System Manual, 01/2013, 2713
Principle
To apply linear scaling to a tag, you must specify one value range on the HMI device and one
on the PLC. The value ranges will be mapped to each other linearly.
50 100 0
127 254 0
cm
PLC
lnches
HMl device
As soon as data from the HMI device is written to an external tag, it will be automatically
mapped to the value range of the PLC. As soon as data from the HMI device is read from the
external tag, a corresponding transformation will be performed in the other direction.
Note
You can also use the system functions "LinearScaling" and "InvertLinearScaling" to
automatically convert process values.
Application example
The user enters length dimensions in centimeters but the PLC is expecting inches. The entered
values are automatically converted before they are forwarded to the controller. Using linear
scaling, the value range [0 to 100] on the PLC can be mapped onto the value range [0 to 254]
on the HMI device.
See also
Tag limits (Page 2709)
Visualizing processes (Basic)
10.2 Working with Tags
STEP 7 Basic V12.0
2714 System Manual, 01/2013,
Applying linear scaling to a tag
Introduction
To apply linear scaling to a tag, you must specify one value range on the HMI device and one
on the PLC. The value ranges will be mapped to each other linearly.
Requirement
The external tag to which linear scaling is to be applied must exist.
The Inspector window with the properties for this tag is open.
Procedure
To apply linear scaling to a tag, follow these steps:
1. In the Inspector window select "Properties > Properties > Linear scaling."
2. Click on "Enable" to switch on linear scaling.
Using this option, you can temporarily switch off linear scaling for testing purposes, for
example. Settings which were made earlier for linear scaling remain unchanged.
3. In the "PLC" area, enter the start and end values of the value range to be applied to the
process values on the PLC.
4. In the "HMI device" area, enter the end and start values of the value range to be applied to
the process values on the HMI device.
Result
In Runtime the data will be automatically mapped from one value range to the other.
Note
You can also use the "LinearScaling" and "InvertLinearScaling" system functions to
automatically convert process values.
See also
Tag limits (Page 2709)
Connecting a tag to another PLC
Introduction
In WinCC, you can change the PLC connection of a tag at any time. This is needed when you
change the configuration of your plant, for example.
Visualizing processes (Basic)
10.2 Working with Tags
STEP 7 Basic V12.0
System Manual, 01/2013, 2715
Depending on the PLC selected, you may need to modify the configuration of the tag. The tag
properties which must be changed will be highlighted in color.
Requirement
The external tag, whose connection you wish to change, must already exist.
The connection to the PLC must already exist.
The Properties window for this tag is open.
Procedure
To change the PLC connection of a tag, proceed as follows:
1. In the Inspector window select "Properties > Properties > General."
2. Select the new connection in the "Connection" field.
The tag properties that you must change will be highlighted in color in the tag table and in
the Inspector window.
3. Change all highlighted properties of the tag to suit the requirements of the new PLC.
Result
The external tag is connected to the new PLC.
See also
Tag limits (Page 2709)
Indirect addressing of tags
Principle
In multiplexes, a type of indirect addressing, the tag used is first determined at runtime. A list
of tags is defined for the multiplex tag. The relevant tag is selected from the list of tags in
runtime. The selection of the tag depends on the value of the index tag.
In Runtime, the system first reads the value of the index tag. Then the tag which is specified
in the corresponding place in the tag list is accessed.
Application example
Using indirect addressing, you could configure the following scenario:
The operator selects one of several machines from a selection list. Depending on the operator's
selection, data from the selected machine will be displayed in an output field.
To configure such a scenario, configure the index tag for a symbolic I/O field. Configure the
multiplex tag at an I/O field. Configure the tag list of the multiplex tag to reflect the structure of
the selection list.
Visualizing processes (Basic)
10.2 Working with Tags
STEP 7 Basic V12.0
2716 System Manual, 01/2013,
If the operator selects another machine, the value of the index tag will change. The selection
field then displays the content of the tag that is pointed to in the tag list in the multiplex tag by
the new index value.
See also
Tag limits (Page 2709)
Addressing tags indirectly
Introduction
With indirect addressing, the tag used is first determined at runtime. Instead of a single tag, a
list of tags is defined. The list entries consist of an index value and the name of the tag to be
used. Using an index tag, you can control which entry in the tag list will be accessed.
Requirement
The tag which you wish to address indirectly must already exist.
The index tag must exist.
The tags which will be contained in the tag list must already exist.
The Inspector window with the tag properties is open.
Procedure
To address tags indirectly, proceed as follows:
1. In the Inspector window select "Properties > Properties > Multiplexing".
2. Select the "Multiplexing" option to activate indirect addressing.
Using this option, you can temporarily switch off indirect addressing for testing purposes,
for example. Settings which were made earlier for indirect addressing remain unchanged.
3. Select an "Index tag" or define a new tag using the object list.
4. Click the first entry in the "Tags" column in the tag list.
5. Select a tag as a list entry or define a new tag using the object list.
The entry in the "Index" column will be generated automatically.
6. Repeat step 5 for all tags that you wish to add to the tag list.
7. If necessary, you can use drag-and-drop to change the order of the entries in the list.
Result
In runtime, the system will dynamically access the tag in the tag list which has the same index
value as the value currently in the index tag.
Visualizing processes (Basic)
10.2 Working with Tags
STEP 7 Basic V12.0
System Manual, 01/2013, 2717
See also
Tag limits (Page 2709)
Using tags to trigger functions
Introduction
You can use the values of variables as the triggering event for an action in runtime. To start
an action in Runtime, configure a function list for a tag. Include one or more system functions
in the function list. The function list is processed when the configured event occurs.
The following events are available for a tag:
Change in value of the tag
Function list processing is triggered by each change in the value of the variable.
If the tag contains arrays, the function list is processed whenever an element of the array
changes.
Violation of the tag's high limit
The function list is processed when the high limit is violated.
Violation of the tag's low limit
The function list is processed when the low limit is violated.
Requirement
The tag whose value you wish to use as an event already exists.
The Inspector window with the properties for this tag is open.
Procedure
To configure a tag with a function list, proceed as follows:
1. Under "Properties > Events >" in the Inspector window, select the event for which you want
to create a function list.
The function list associated with the selected event is shown.
2. Click "<Add function>". The second table column contains a selection button.
3. Click the selection button and select a system function.
4. Define the parameter values.
Result
The function list is processed when the configured event occurs in Runtime.
See also
Tag limits (Page 2709)
Visualizing processes (Basic)
10.2 Working with Tags
STEP 7 Basic V12.0
2718 System Manual, 01/2013,
Defining the acquisition cycle for a tag
Introduction
The value of an external tag can be changed in Runtime by the PLC to which the tag is linked.
To ensure that the HMI device is informed of any changes in tag values by the PLC, the values
must be updated on the HMI. The value is updated at regular intervals while the tag is displayed
in the process screen or is logged. The interval for regular updates is set with the acquisition
cycle. The update can also be made continuous.
Requirement
You have created the tag for which you want to define an acquisition cycle.
The Inspector window with the tag properties is open.
Procedure
To configure an acquisition cycle for a tag, follow these steps:
1. In the Inspector window select "Properties > Properties > General."
2. If you want to update the tag at regular intervals as long as it is being displayed on the
screen or logged, select "Cyclic in operation" as the acquisition mode.
Or:
If you want to update the tag at regular intervals even though it is not being displayed on
the screen or logged, select "Cyclic continuous" as the acquisition mode.
The "Cyclic continuous" setting is selected for a tag, for example, that has a function list
configured for a change of its value and that is not directly visible in a screen.
3. Select the required cycle time in the "Acquisition cycle" field or define a new acquisition
cycle using the object list.
Alternatively, you can configure the acquisition cycle directly in the work area of the tag table.
To view hidden columns, activate the column titles using the shortcut menu.
Note
Only use the "Cyclic continuous" acquisition mode for tags that really have to be continuously
updated. Frequent read operations generate a heavy communication load.
Result
The configured tag is updated in Runtime with the selected acquisition cycle.
See also
Tag limits (Page 2709)
Visualizing processes (Basic)
10.2 Working with Tags
STEP 7 Basic V12.0
System Manual, 01/2013, 2719
Address multiplexing
Introduction
Using address multiplexing, you can use a single tag to access a multitude of memory locations
within the PLC's address range. You read and write to the addresses without defining a tag
for each individual address.
Multiplexing with absolute addressing
When using multiplexing with absolute addressing, you configure tags as placeholders for the
address in the PLC to be addressed.
If you want to access, for example, an address of the format "%DBx.DBWy", the expression
for multiplexing is as follows:
"%DB[HMITag1].DBW[HMITag2]"
In Runtime, you supply the tag "HMITag1" with the required value for the data block you want
to address.
In Runtime, you supply the tag "HMITag2" with the required address from the data block.
Tags are supplied with values, for example, with the help of values from the PLC or via a script.
Multiplexing with absolute addresses is supported for the following PLCs and communication
drivers.
SIMATIC S7 300/400
SIMATIC S7 1200
Multiplexing with absolute addresses is not available for data blocks with optimized access.
Multiplexing with symbolic addressing
When multiplexing with symbolic addressing, you access an array element of an array tag in
a data block of the connected PLC by means of a multiplex tag and an index tag. The multiplex
tag contains the symbolic address of the data block which you want to access. The symbolic
address also contains the index tag via which you access the index of the array tag.
If you want to access, for example, the array tag "Arraytag_1" in the data block "Datablock_1",
the expression for symbolic addressing is as follows:
"Datablock_1.Arraytag_1["HMITag_1"]
You control the access to the index of the array elements with the HMI-Variable "HMITag_1".
In Runtime, you supply the tag with the index of the array element that you want to access.
Multiplexing with symbolic addressing is only available if the following components support
symbolic addressing:
the HMI device
PLC
Communication driver
Visualizing processes (Basic)
10.2 Working with Tags
STEP 7 Basic V12.0
2720 System Manual, 01/2013,
Symbolic addressing is currently only supported by the SIMATIC S7 1200 communication
driver.
See also
Tag limits (Page 2709)
Configuring address multiplexing with absolute addressing
Introduction
When using address multiplexing, you can efficiently access different addresses in the PLC
with the help of a small number of tags. Instead of the absolute address in the PLC, you use
tags in order to be able to change the address in Runtime.
Requirement
The tag for address multiplexing is created and connected to the PLC.
The Properties window for this tag is open.
Procedure
1. Select the tag for address multiplexing in the tag table, and select "Properties > Properties
> General" in the Inspector window. The general properties of the tag are displayed.
2. Select the "Int" data type for this example.
3. Select the access type "Absolute addressing".
Visualizing processes (Basic)
10.2 Working with Tags
STEP 7 Basic V12.0
System Manual, 01/2013, 2721
4. Click the selection button in the "Address" field. The address dialog opens.
5. Click the selection button in the "DB number" field and select the entry "HMI tag".
6. In the "DB number" field, click the button and select a tag for the DB number in the object
list. Or create a new tag with the help of the object list. Accept the tag by clicking the
button.
7. Repeat steps 3 and 4 for the "Address" field and configure a further tag for calling the
address area in the data block.
Visualizing processes (Basic)
10.2 Working with Tags
STEP 7 Basic V12.0
2722 System Manual, 01/2013,
The selection options in the Address dialog depend on the selected data type of the multiplex
tag. The Address dialog offers only address settings that can be configured with the selected
data type.
Result
In runtime, the multiplex tag is used to access the memory location corresponding to the
address currently found in the tag. You control access to the data block with the tag in the DB
number field. You control access to the address in the selected data block with the tag in the
"Address" field.
Note
The value in the memory location will only be read at the next update cycle for the addressed
tag.
If, for example, you use a multiplex tag in a script, do not attempt to access contents of the
memory location directly after changing it.
See also
Tag limits (Page 2709)
Configuring address multiplexing with symbolic addressing
Introduction
When using address multiplexing, you can efficiently access different addresses in the PLC
with the help of a small number of tags. Instead of the symbolic address in the PLC, you use
tags in order to be able to change the address in Runtime.
Requirement
The tag for address multiplexing is created.
The Properties window for this tag is open.
A data block with an array tag is created in the connected PLC.
The data block was compiled.
Visualizing processes (Basic)
10.2 Working with Tags
STEP 7 Basic V12.0
System Manual, 01/2013, 2723
Procedure
1. Select the tag for address multiplexing in the tag table, and select "Properties > Properties
> General" in the Inspector window. The general properties of the tag are displayed.
2. Select the connection to the PLC via the "Connection" field.
3. Select the access type "Symbolic addressing".
Visualizing processes (Basic)
10.2 Working with Tags
STEP 7 Basic V12.0
2724 System Manual, 01/2013,
4. Navigate to the data block of the PLC via the "PLC tag" field and select an array element
of the array tag.
5. Click the selection button in the "Address" field. The address dialog opens.
6. Click the selection button in the "Index tag" field and select the entry "HMI tag".
7. In the "Index tag" field, click the button and select a tag for the array index in the object
list. Or create a new tag with the help of the object list. Accept the tag by clicking the
button.
Result
In Runtime, the array element whose index value is contained in the index tag is accessed.
Visualizing processes (Basic)
10.2 Working with Tags
STEP 7 Basic V12.0
System Manual, 01/2013, 2725
See also
Tag limits (Page 2709)
10.2.3 Working with arrays
10.2.3.1 Basics on arrays
Definition
Array data of a uniform data type is successively arranged and is addressed within the address
space to allow access to these data by means of an index. The individual array elements are
addressed by means of an integer index. The properties of each array element are the same
and are configured at the array tag in a data block of the PLC program.
Advantages
You can configure multiple array elements with the same properties at one time using a single
array tag. You can then use each array element as any other tag in your configuration.
Restrictions
The following restrictions apply to the use of arrays:
Not all HMI devices support array tags.
An array may contain only one dimension.
The lower index of an array must begin with "0".
Application examples
Array tags can be used in the following situations:
To group process values in profile trends: You map process values to trends which are
acquired at different points in time, for example.
To access specific values which are grouped in trends: You output all values of the profile
trend by stepping up the index tag, for example.
Visualizing processes (Basic)
10.2 Working with Tags
STEP 7 Basic V12.0
2726 System Manual, 01/2013,
To configure discrete alarms with successive bit number.
To save the complete machine data records in a recipe.
License rule for runtime
An array tag is counted in WinCC Runtime as one PowerTag, regardless of the number of
array elements.
Special features
WARNING
Increased system load and performance losses
Read or write access to a single array element always includes read or write access to all
array elements of the array tag. Transfer of the data of large arrays from and to the PLC
usually takes longer compared to the transfer of a basic data type. This may cause
communication overload and disruption as a result.
Example:
An array tag which consists of 100 array elements of data type "Real" was configured.
If an array element with a length of four bytes changes, 100 x 4 bytes are written to the
PLC.
CAUTION
Data inconsistency at array tags
If the value of a single element must be changed in an array tag, the whole array is read,
changed and rewritten as a complete array. Changes carried out in the meantime to other
array elements in the PLC are overwritten during rewriting.
You should always prevent the HMI device and the PLC from concurrently writing values
to the same array tag. Use synchronous transfer of recipe data records to synchronize an
array tag with the PLC.
See also
Creating array tags (Page 2728)
Examples of arrays (Page 2729)
Basics of tags (Page 2692)
Visualizing processes (Basic)
10.2 Working with Tags
STEP 7 Basic V12.0
System Manual, 01/2013, 2727
10.2.3.2 Creating array tags
Introduction
Create an array tag to configure a large number of tags of the same data type. The array
elements are saved to a consecutive address space.
You can create an array tag as an internal tag or as an external tag.
If you want to create an array tag as an external tag, first configure an array tag in a data block
of the connected PLC. You then connect the array tag to an HMI tag.
Requirement
The HMI tag table is open.
Procedure
To create an array tag, follow these steps:
1. Double click <Add> in the "Name" column of the HMI tag table.
A new HMI tag is created.
2. Click in the Data type column and select the "Array" data type.
3. Click in the data type column. The dialog box for configuring the array is opened.
4. Select the desired data type for the array tag in the "Date type" field.
5. Define the number of array elements in the "Array limits" field. The lower limit must begin
with "0".
6. Click . The settings for the array are saved.
7. Save the project.
Visualizing processes (Basic)
10.2 Working with Tags
STEP 7 Basic V12.0
2728 System Manual, 01/2013,
Result
An array tag is created. The properties of the array elements are inherited from the parent
array tag.
See also
Basics on arrays (Page 2726)
10.2.3.3 Examples of arrays
Introduction
Array tags combine a number of tags, e.g. 100 array elements. You use array tags as complete
arrays in the following places:
In the "Alarms" editor
In the "Recipes" editor
For address multiplexing
In the trend view
You use individual array elements everywhere in the configuration like HMI tags.
Examples
You can configure an array tag with the corresponding number of array elements to handle
multiple tags of the same data type.
The individual array elements can be accessed indirectly by means of a multiplex index
tag, for example.
Use these index tags to operate and monitor the array elements.
See also
Basics on arrays (Page 2726)
10.2.4 Working with cycles
10.2.4.1 Cycle basics
Introduction
Cycles are used to control actions that regularly occur in runtime. Common applications are
the acquisition cycle and the update cycle.
Visualizing processes (Basic)
10.2 Working with Tags
STEP 7 Basic V12.0
System Manual, 01/2013, 2729
Principle
In Runtime, actions that are performed regularly are controlled by cycles. Typical applications
for cycles:
Acquisition of external tags
The acquisition cycle determines when the HMI device will read the process value of an
external tag from the PLC. Set the acquisition cycle to suit the rate of change of the process
values. The temperature of an oven, for example, changes much more slowly than the
speed of an electrical drive.
Do not set the acquisition cycle too low, since this will unnecessarily increase the
communication load of the process.
The smallest possible value for the cycle depends on the HMI device that will be used in your
project. For most HMIs, this value is 100 ms. The values of all other cycles are always an
integer multiple of the smallest value.
Application example
You can use cycles for the following tasks:
To regularly update a tag.
To draw attention to maintenance intervals.
See also
Basics of tags (Page 2692)
10.2.5 Displaying tags
10.2.5.1 Outputting tag values in screens
Introduction
In runtime you can output tag values in the screens of the operator device in the form of a
trend. A trend is a graphic representation of the values that a tag takes during runtime. Use
the "Trend display" graphic object to represent it. Process values for the trend display are
loaded by the PLC from the ongoing process.
The values to be displayed are determined individually within a fixed, configurable cycle.
Cyclically-triggered trends are suitable for representing continuous curves, such as the
changes in the operating temperature of a motor.
Displayed values
You will need to configure a trend view in a screen so that tag values are displayed on the HMI
device. When configuring the trend view, specify which tag values are to be displayed.
You can control the updating of the trend display by defining the cycle time.
Visualizing processes (Basic)
10.2 Working with Tags
STEP 7 Basic V12.0
2730 System Manual, 01/2013,
10.2.5.2 Configuring trend displays for values from the PLC
Introduction
You use a trend view to graphically represent values that a tag assumes during the
process.
Requirement
A screen is open.
The Inspector window with the trend view properties is open.
Procedure
To configure a trend view, follow these steps:
1. Add the "Trend view" object from the toolbox in the "Control" group to the screen.
2. Select the "Trend" category from the "Properties" group in the Inspector window and double-
click "<Add>" in the "Name" column.
3. Assign a name to the trend in the "Name" column.
4. In the "Style" column, use the selection button to open the "Style" dialog and select the
style of the line.
5. Select the number of trend values in the "Trend values" column.
Visualizing processes (Basic)
10.2 Working with Tags
STEP 7 Basic V12.0
System Manual, 01/2013, 2731
6. In the "Settings" column, use the selection button to open the "Data source" dialog and
select the tags to supply the trend with values.
Specify the cycle for reading the tags from the PLC.
7. You can make other settings in the dialogs of the Inspector window. For example, you can
select the "Display table" option in the "Table" category to display a value table beneath
the trend view.
Note
If you hold down the <CTRL> key and double-click the trend view, the trend view is
activated. You set the column width and the position of the columns in the table header
of the values table in active mode. In order to activate the trend view the zoom factor has
to be set to 100 %.
Result
In runtime, the values of the selected tags are displayed in the configured trend view.
Visualizing processes (Basic)
10.2 Working with Tags
STEP 7 Basic V12.0
2732 System Manual, 01/2013,
10.3 Working with alarms
10.3.1 Basics
10.3.1.1 Alarm system in WinCC
Introduction
The alarm system allows you to display and record operating states and faults on the HMI
device that are present or occur in a plant.
An alarm may have the following content:
N
o.
Time Date Alarm text Status Alarm class
5 12:50:24
:590
24.02.
2007
Boiler pressure above
high limit.
Incoming
Outgoing
Warning:
Color Red
Alarm system in WinCC
The alarm system processes a variety of alarm types. The alarm procedures can be broken
down into system-defined alarms and user-defined alarms:
User-defined alarms are used to monitor the plant process.
System-defined alarms monitor the HMI device.
The detected alarm events are displayed on the HMI device. Targeted access to the alarms
combined with supplementary information about individual alarms ensures that faults are
localized and cleared quickly. This reduces stoppages or even prevents them altogether.
The following figure shows the alarm system structure:
Visualizing processes (Basic)
10.3 Working with alarms
STEP 7 Basic V12.0
System Manual, 01/2013, 2733
None
Configuration
in WinCC
System alarms
Analog alarm
Discrete alarm
System-defined alarms User-defined alarms
HMl device HMl device
10.3.1.2 Alarm types
Overview of the alarm types
Introduction
The alarm types serve various purposes for monitoring the plant. The alarms from the individual
alarm types are configured and triggered in different ways.
Select the relevant tab in the "HMI alarms" editor to configure alarms based on the individual
alarm types.
Alarm types in WinCC
WinCC supports the following alarm types:
Visualizing processes (Basic)
10.3 Working with alarms
STEP 7 Basic V12.0
2734 System Manual, 01/2013,
User-defined alarms
Analog alarms
Analog alarms are used to monitor limit violations.
Discrete alarms
Discrete alarms are used to monitor states.
System-defined alarms
System events
System events belong to the HMI device and are imported into the project.
System events monitor the HMI device.
System-defined alarms
System alarms
Examples for alarms
"An online connection to the PLC is established."
Description
A system alarm indicates the status of the system, plus communication errors between the
HMI device and system.
Under "Runtime settings > Alarms" you specify how long a system alarm is shown on the HMI
device.
Support
The reference contains a list of the possible system events, along with the cause and possible
remedies. If you contact online support because of a system alarm on the HMI device, you will
need the alarm number and tags used in the system alarm.
User-defined alarms
Analog alarms
Description
Analog alarms signal limit violations during the process.
Visualizing processes (Basic)
10.3 Working with alarms
STEP 7 Basic V12.0
System Manual, 01/2013, 2735
Example
The speed of the mixer in a fruit juice mixing plant must not be too high or too low. You can
configure analog alarms to monitor the speed of the mixer. If the high or low limit for the speed
of the mixer is violated, an alarm is output on the HMI device containing the following alarm
text, for example: "Mixer speed is too low".
Discrete alarms
Description
Discrete alarms indicate a status in the current process.
Example
A fruit juice mixing plant consists of several tanks containing the ingredients. To ensure the
correct mixing ratio of water, fruit concentrate, sugar, and flavoring, the valves in the intakes
open and close at the right moment. This operation should be monitored.
You configure a suitable discrete alarm for all the valve states. If a valve on one of the four
tanks opens or closes, an alarm is displayed, such as "Water valve closed".
The operator can thus monitor whether the plant is producing correctly.
10.3.1.3 Alarm states
Introduction
An alarm assumes various alarm states in Runtime.
Description
Every alarm has an alarm status. The alarm states are made up of the following events:
Incoming (I)
The condition for triggering an alarm is satisfied. The alarm is displayed, such as "Boiler
pressure too high."
Outgoing (O)
The condition for triggering an alarm is no longer satisfied. The alarm is no longer displayed
as the boiler was vented.
Acknowledge (A)
The operator acknowledges the alarm.
Visualizing processes (Basic)
10.3 Working with alarms
STEP 7 Basic V12.0
2736 System Manual, 01/2013,
Alarms without acknowledgment
The following table shows the alarm states for alarms that do not have to be acknowledged:
Display text Status Description
I Incoming The condition for an alarm is satisfied.
IO Outgoing The condition for an alarm is no longer satisfied.
Alarms with acknowledgment
The following table shows the alarm states for alarms that have to be acknowledged:
Display text Status Description
I Incoming The condition for an alarm is satisfied
IO Outgoing
not acknowledged
The condition for an alarm is no longer satisfied. The
operator has not acknowledged the alarm.
IOA Outgoing
and subsequently
acknowledged
The condition for an alarm is no longer satisfied. The
operator has acknowledged the alarm after this time.
IA Incoming,
acknowledged
The condition for an alarm is satisfied. The operator
has acknowledged the alarm.
IAO Outgoing
but acknowledged first
The condition for an alarm is no longer satisfied. The
operator acknowledged the alarm while the condition
was still satisfied.
Each occurrence of these states can be displayed and logged on the HMI device and a protocol
printed.
Note
You can configure the display text for the alarm status.
10.3.1.4 Alarm classes
Basics on alarm classes
Introduction
Many alarms occur in a plant. These are all of different importance. You can assign the alarms
of your project to alarm classes to clearly show the user which of the alarms are most important.
Description
The alarm class defines how an alarm is displayed. The alarm class specifies if and how the
user has to acknowledge alarms of this alarm class.
Visualizing processes (Basic)
10.3 Working with alarms
STEP 7 Basic V12.0
System Manual, 01/2013, 2737
A new alarm class with mandatory acknowledgment is generated in WinCC.
Note
The choice of display modes for alarm classes depends on the options on your HMI device.
Examples of how to use alarm classes
The alarm "Speed of fan 1 in upper tolerance range" has alarm class "Warnings". The alarm
is displayed with a white background. The alarm does not have to be acknowledged.
The alarm "Speed of fan 2 has exceeded upper warning range" is assigned to the "Errors"
alarm class. The alarm is displayed with a red background and flashes at high frequency
in runtime. The alarm is displayed until the user acknowledges it.
Using alarm classes
Use the following alarm classes to define the acknowledgment model and display of alarms
for your project:
Predefined alarm classes
You cannot delete predefined alarm classes and edit them only to a limited extent.
Predefined alarm classes have been created for each HMI device under "HMI alarms >
Alarm classes".
Custom alarm classes
You can create new alarm classes under "HMI alarms > Alarm classes", configure how you
want the alarms to be displayed, and define an acknowledgment model for alarms of this
alarm class. The possible number of custom alarm classes depends on which runtime is
used in your project.
See also
Creating alarm classes (Page 2744)
Predefined alarm classes
Predefined alarm classes
The following alarm classes already created in WinCC for every HMI device:
Alarm classes for user-defined alarms
"Warnings"
The "Warnings" alarm class is intended to show regular states and routines in the process.
Users do not acknowledge alarms from this alarm class.
"Errors"
The "Errors" alarm class is intended to show critical or dangerous states or limit violations
in the process. The user must acknowledge alarms from this alarm class.
Visualizing processes (Basic)
10.3 Working with alarms
STEP 7 Basic V12.0
2738 System Manual, 01/2013,
Alarm class for system-defined alarms
"System"
The "System" alarm class contains alarms that display states of the HMI device and the
PLCs.
See also
Creating alarm classes (Page 2744)
10.3.1.5 Acknowledgment
Acknowledging alarms
Introduction
To make sure that an alarm was registered by the plant operator, configure this alarm so that
it is displayed until acknowledged by the operator. Alarms that display critical or hazardous
states in the process have to be acknowledged.
Description
Acknowledging an alarm changes the alarm status from "Incoming" to "Acknowledged". When
the operator acknowledges an alarm, the operator confirms that he or she has processed the
status that triggered the alarm.
Triggering acknowledgment of an alarm
In Runtime, you trigger alarm acknowledgments in various ways:
Acknowledgement by the authorized user at the HMI device
Automatic acknowledgment by the system without operator action, e.g. by means of
Tags
PLC
System functions in function lists
Acknowledging alarms that belong together
To make the alarm system clearer and easier to use in Runtime, you can configure an alarm
group. You can acknowledge all alarms belonging to this alarm group in a single pass.
Acknowledgment by the PLC
Discrete alarms will be automatically acknowledged by the PLC, if necessary. The
acknowledgment is triggered by a bit in the "Acknowledgment tag PLC". You define the bit and
tag at the configuration stage.
Visualizing processes (Basic)
10.3 Working with alarms
STEP 7 Basic V12.0
System Manual, 01/2013, 2739
Acknowledgment of an alarm on the HMI device
In Runtime, the user acknowledges an alarm in one of the following ways, depending on the
configuration:
Using the acknowledgment button <ACK> on the HMI device
Using the button in the alarm view
Using configured function keys or buttons in screens
Note
Acknowledgment button <ACK> on the HMI device
To ensure that critical alarms are processed only by authorized users, protect the "ACK"
button on the HMI devices, including the operating controls and display objects of the
alarms. Use the appropriate operator authorization for this.
Note
HMI device dependency
The acknowledgement key <ACK> is not available on all HMI devices.
Acknowledgment model
Overview
You define the acknowledgment model for an alarm class. Alarms that are assigned to this
alarm class will be acknowledged on the basis of this acknowledgment model. The following
acknowledgment model is used in WinCC:
Alarm without acknowledgment
This alarm comes and goes without having to be acknowledged. There is no visible
response from the system.
Alarm with simple acknowledgment
This alarm must be acknowledged as soon as the event that triggers the alarm occurs. The
alarm remains pending until it is acknowledged.
10.3.1.6 Alarm groups
Introduction
Many alarms from different areas and processes occur in a plant. You can compile associated
alarms into alarm groups.
Alarm groups
You can use the alarm groups to monitor the parts of the plant and to acknowledge the
associated alarms together as required.
Visualizing processes (Basic)
10.3 Working with alarms
STEP 7 Basic V12.0
2740 System Manual, 01/2013,
Alarm groups can contain alarms from different alarm classes. You only assign alarms that
require acknowledgment to alarm groups.
Using alarm groups
It is a good idea to compile alarm groups for alarms such as the following:
Alarms that are caused by the same fault.
Alarms of the same type
Alarms from a machine unit, such as "Fault in drive XY"
Alarms from an associated part of the process, such as "Fault in cooling water supply"
Display in Runtime
In Runtime, the "Alarm group" column displays the number of the alarm group to which the
alarm belongs.
10.3.1.7 Alarm number
Assigning alarm numbers
The system assigns unique alarm numbers within an alarm type.
Note
When adapting alarm numbers, observe the uniqueness of the alarm number within an alarm
type.
Visualizing processes (Basic)
10.3 Working with alarms
STEP 7 Basic V12.0
System Manual, 01/2013, 2741
10.3.2 Working with alarms
10.3.2.1 Alarm components and properties
Overview
You configure the components of alarms in WinCC. The following table shows the basic
components of alarms:
Alarm
class
Alarm
number
Time
of day
Date Alarm
status
Alarm text Alarm
group
Tooltip Trigger tag Limit
value
Warni
ng
1 11:09
:14
06.08.2
007
IO Maximum speed
reached
2 This alarm is ... speed_1 27
Syste
m
110001 11:25
:58
06.08.2
007
I Switch to "Online"
mode
0 This alarm is ... PLC-
Variable_1
Alarm class
Alarm classes, such as "Warnings" or "Errors." The alarm class defines the following for an
alarm:
Acknowledgment model
Appearance in Runtime (e.g. color)
Alarm number
An alarm is identified by a unique alarm number. The alarm number is assigned by the system.
You can change the alarm number to a sequential alarm number, if necessary, to identify
alarms associated in your project.
Time and date
Every alarm has a time stamp that shows the time and date at which the alarm was triggered.
Alarm status
An alarm has the events "Incoming," "Outgoing," "Acknowledge." For each event, a new alarm
is output with the current status of the alarm.
Alarm text
The alarm text describes the cause of the alarm.
The alarm text can contain output fields for current values. The values you can insert depend
on the Runtime in use. The value is retained at the time at which the alarm status changes.
Visualizing processes (Basic)
10.3 Working with alarms
STEP 7 Basic V12.0
2742 System Manual, 01/2013,
Alarm group
The alarm group bundles individual alarms.
Tooltip
You can configure a separate tooltip for each alarm; the user can display this tooltip in Runtime.
Trigger tag
Each alarm is assigned a tag as trigger. The alarm is output when this trigger tag meets the
defined condition, e.g. when its state changes or it exceeds a limit.
Limit value
Analog alarms indicate limit violations. Depending on the configuration, WinCC outputs the
analog alarm as soon as the trigger tag exceeds or undershoots the limit value.
10.3.2.2 Configuring alarms
Overview of alarm configuration tasks
Steps to configure alarms
Configuring alarms in WinCC involves the following steps:
1. Edit and create alarm classes
You use the alarm class to define how an alarm will be displayed in runtime and to define
the acknowledgment model for it.
2. Creating tags in the "HMI tags" editor
Configure the tags for your project.
You create range values for the tags.
3. Creating tags in the "HMI alarms " editor
Create custom alarms and assign these the tag to be monitored, alarm classes, alarm
groups, and other properties.
You can also assign system functions or scripts to the alarm events.
4. Output of configured alarms
To output configured alarms, configure an alarm view or an alarm window in the "Screens"
editor.
Additional configuration tasks
Additional tasks may be necessary for configuring alarms, depending on the requirements of
your project:
Visualizing processes (Basic)
10.3 Working with alarms
STEP 7 Basic V12.0
System Manual, 01/2013, 2743
1. Creating alarm groups
You assign the alarms of your project to alarm groups according to their association, such
as by the cause of the problem (power failure) or source of the error (Motor 1).
2. Configuring Loop-In-Alarm
A Loop-In-Alarm is configured in order to change to a screen containing relevant information
on an alarm received.
Creating alarm classes
Introduction
Create alarm classes in the "Alarm classes" tab of the "HMI alarms" editor. Some default alarm
classes are already created for every project. You can create additional custom alarm classes.
You can create up to 32 alarm classes.
Requirement
The "HMI alarms" editor is open.
The Inspector window is open.
Procedure
To create an alarm class, proceed as follows:
1. Click the "Alarm Classes" tab.
The predefined and existing custom alarm classes are displayed. The following table lists
the predefined alarm classes:
1. Double-click "<Add>" in the table.
A new alarm class is created. Each new alarm is automatically assigned a static ID.
The properties of the new alarm class are shown in the Inspector window.
2. Configure the alarm class under "Properties > Properties >General" in the Inspector window.
Enter a "Name" and the "Display name".
Depending on the HMI device, you can also activate logging, or automatic sending of e-
mails.
3. Define the acknowledgment model for the alarm class under "Properties > Properties >
Acknowledgment" in the Inspector window.
4. Change the default text under "Properties > Properties > Status" in the Inspector window.
This text indicates the status of an alarm in Runtime.
5. Change the default colors under "Properties > Properties > Colors" in the Inspector window.
Depending on the HMI device, also change the flashing characteristics.
These settings define how alarms from this alarm class are displayed in Runtime.
Visualizing processes (Basic)
10.3 Working with alarms
STEP 7 Basic V12.0
2744 System Manual, 01/2013,
Note
To display the alarm classes in color in Runtime, the "Use alarm class colors" option must
be activated. In the project navigation, enable "Runtime settings > Alarms > General > Use
alarm class colors" accordingly. This option is selected in a new project in WinCC.
Configuring alarm groups
Introduction
Create alarm groups on the "Alarm Groups" tab in the "HMI alarms" editor. An alarm group is
a compilation of single alarms. You assign alarms in an alarm group by association, such as
cause of the problem or source of the error. If you acknowledge an alarm from this alarm group
in Runtime, all other alarms in the alarm group are acknowledged automatically.
Requirement
You have created a project.
The "HMI alarms" editor is open.
The Inspector window is open.
Creating a new alarm group
1. Click the "Alarm Groups" tab.
The existing alarm groups are displayed.
2. In the work area of the table, double-click "<Add>" in the first free row.
A new alarm group is created.
3. You can overwrite the proposed "Name".
Result
An alarm group is created. For the group acknowledgment of alarms in Runtime, assign the
associated alarms that require acknowledgment to an alarm group.
Configuring discrete alarms
Introduction
Discrete alarms triggered by the PLC indicate status changes in a plant. They indicate the
opened or closed state of a valve, for example.
The following sections describes the configuration procedures in the "HMI alarms" editor. You
can also configure discrete alarms in the "HMI tags" editor.
Visualizing processes (Basic)
10.3 Working with alarms
STEP 7 Basic V12.0
System Manual, 01/2013, 2745
Requirements
The "HMI alarms" editor is open.
The Inspector window is open.
You have created the required alarm classes and alarm groups.
Procedure
To configure a discrete alarm, proceed as follows:
1. Open the "Discrete alarms" tab.
2. To create a new discrete alarm, double-click in the work area on "<Add>".
A new discrete alarm is created.
3. To configure the alarm, select "Properties > Properties >General" in the Inspector window:
Enter an alarm text as event text.
Use the functions of the shortcut menu to format the text on a character-by-character
basis, or to insert output fields for HMI tags, or texts from the text lists.
You can renumber the alarm.
Select the alarm class and the alarm group, if necessary.
4. In the Inspector window, select the tag and the bit that triggers the alarm under "Properties
> Properties > Trigger". Note the following information:
Use the data types "Int" or "UInt" to select an HMI tag.
Use the data types "Int" or "Word" to select a PLC tag.
Use trigger tag bits only for alarms.
Do not use trigger tags for anything else.
If you want to acknowledge the alarm via the PLC, use this tag also as PLC
acknowledgment tag.
Note
Note the method used to count bits in the utilized PLC when specifying the bit. For more
information, refer to the "Communication" section in the PLC Online Help.
Note
If the object does not yet exist in the selection list, create it directly in the object list and change
its properties later.
Status-dependent alarm texts
To display a different text independent of the alarm status, link a text list to the alarm text. You
control the text list with a tag.
Visualizing processes (Basic)
10.3 Working with alarms
STEP 7 Basic V12.0
2746 System Manual, 01/2013,
Additional settings for discrete alarms
Creating a tooltip
To configure a tooltip for the alarm, follow these steps:
Enter your text under "Properties > Properties > Tooltip".
Configuring event-driven tasks
To configure event-driven tasks, such as a loop-in alarm, follow these steps:
1. Select the discrete alarm.
2. Select "Properties > Events" in the Inspector window and configure a new function list for
the relevant event.
See also
Configuring loop-in alarm (Page 2751)
Configuring analog alarms
Introduction
Analog alarms indicate limit violations. For example, if the speed of a motor drops below a
certain value, an analog alarm is triggered.
Requirements
The "HMI alarms" editor is open.
The Inspector window is open.
You have created the required alarm classes and alarm groups.
Procedure
To configure an analog alarm, proceed as follows:
1. Click the "Analog alarms" tab.
2. To create a new analog alarm, double-click in the table on "<Add>".
A new analog alarm is created.
Visualizing processes (Basic)
10.3 Working with alarms
STEP 7 Basic V12.0
System Manual, 01/2013, 2747
3. To configure the alarm, select "Properties > Properties >General" in the Inspector window:
Enter an alarm text as event text.
Format the text character-for-character using the shortcut menu.
Using the shortcut menu, you can insert output fields for HMI tags, or text from text lists.
You can renumber the alarm.
Select the alarm class and the alarm group, if necessary.
4. Configure the tag that triggers the alarm under "Properties > Properties > Trigger >
Settings".
Do not use trigger tags for anything else.
Configure limit values for an analog alarm
1. In the Inspector window, click the button under "Properties > Properties > Trigger > Limit
> Value".
To use a constant as limit value, select "Constant".
Enter the required limit value.
To use a tag as limit value, select "HMI tag".
The button is shown. Use this button to select the tag you want to use.
Note
If the tag included in the selection does not yet exist, create it in the object list and
change its properties later.
2. Select the mode:
"High limit violation": The alarm is triggered when the limit is exceeded.
"Low limit violation": The alarm is triggered when the limit is undershot.
Visualizing processes (Basic)
10.3 Working with alarms
STEP 7 Basic V12.0
2748 System Manual, 01/2013,
Optional settings for analog alarms
Setting the delay time
To set the delay time, proceed as follows:
Enter a time period in the Inspector window under "Properties > Properties> Trigger >
Settings > Delay".
The alarm is only triggered when the trigger condition is still present after the delay time
has elapsed.
Setting the deadband
Note
If a process value fluctuates around the limit, the alarm associated with this fault may be
triggered multiple times. To prevent this from happening, configure a deadband or delay
time.
To enter the deadband, follow these steps:
1. Under "Properties > Properties> Trigger > Deadband > Mode", select the change in alarm
status for which the deadband is to be taken into account.
2. Enter a constant value under "Value".
3. To define the deadband value as a percentage of the limit, set the "in %" check box.
Creating a tooltip
To configure a tooltip for the alarm, follow these steps:
Select "Properties > Properties > Tooltip" in the Inspector window and enter your text.
Configuring event-driven tasks
To configure event-driven tasks, such as a loop-in alarm, follow these steps:
1. Select the analog alarm.
2. Select "Properties > Events" in the Inspector window and configure a new function list for
the relevant event.
See also
Configuring loop-in alarm (Page 2751)
Visualizing processes (Basic)
10.3 Working with alarms
STEP 7 Basic V12.0
System Manual, 01/2013, 2749
Adding an output field to alarm text
Introduction
In WinCC, you can insert output fields into the alarm text which display the content of tags.
Requirements
The "HMI alarms" editor is open.
The alarm is selected.
Output of a tag value in the alarm text
To insert an output field for a tag value in the alarm text, proceed as follows:
1. Place the cursor onto the required position in the event text.
2. Select "Insert tag output field" in the shortcut menu.
3. Open the object list under "Tag" and select a tag.
You can also create the tag in the object list.
4. Under "Format", specify the length of the output field and the format for tag value output in
the alarm text.
Configure an output field of sufficient size. Otherwise, the tag content is not output to the
full extent in the alarm.
5. Click to save your entries.
WinCC inserts a placeholder for the output field into the alarm text: "<tag: n, [tag name]>"
whereby n = text string length.
Editing output field properties
To edit the properties of an output field, proceed as follows:
Double-click on the output field in the alarm text and edit the settings.
Deleting an output field from the alarm text
To delete an output field from the alarm text, proceed as follows:
Select the output field in the alarm text and then select the "Delete" command from the
shortcut menu.
Note
The sequence of the tag output fields in the alarm text depends on the language. Changing
the tag of an output field in one language causes the modified output field to appear at the
end of the alarm text in all other languages.
Visualizing processes (Basic)
10.3 Working with alarms
STEP 7 Basic V12.0
2750 System Manual, 01/2013,
Formatting alarm text
Requirements
The "HMI alarms" editor is open.
An alarm has been created.
Procedure
To format an alarm text, proceed as follows:
1. Select the alarm to edit.
2. In the Inspector window, select the characters to format under "Properties > Properties >
General > Alarm text".
3. Select the formatting from the shortcut menu, e.g. "Underscored" or "Uppercase".
Result
The selected characters are displayed in Runtime with the selected formatting.
Removing format settings
To remove all text formats, proceed as follows:
1. In the Inspector window, select the characters whose formatting you want to remove in the
alarm text.
2. Select "Delete formatting characters" from the shortcut menu.
Result
The selected characters are displayed in unformatted notation in Runtime.
Configuring loop-in alarm
Introduction
A Loop-In-Alarm is configured in order to change to a screen containing relevant information
on an alarm received.
Requirements
The screen called by the Loop-In-Alarm has been created.
The "HMI alarms" editor is open.
Visualizing processes (Basic)
10.3 Working with alarms
STEP 7 Basic V12.0
System Manual, 01/2013, 2751
Procedure
To configure a Loop-In-Alarm for an alarm, proceed as follows:
1. Click the tab that contains the alarm for which you want to configure the Loop-In-Alarm.
2. Select the alarm.
3. In the Inspector window, select "Properties > Events > Loop-In-Alarm".
4. Select the "ActivateScreen" system function.
5. Select the screen called by the Loop-In-Alarm as parameter.
Note
To configure the Loop-In-Alarm for an alarm view with an "alarm line" format, use the
following system functions:
"EditAlarm" for HMI devices with keys
"AlarmViewEditAlarm" for HMI devices without keys
The system functions trigger the "Loop-In-Alarm" event. The alarm line has no buttons.
Result
If you click on the "Loop-In-Alarm" button of the alarm view in Runtime, a screen is opened
with information on the selected alarm.
See also
Configuring analog alarms (Page 2747)
Configuring discrete alarms (Page 2745)
Visualizing processes (Basic)
10.3 Working with alarms
STEP 7 Basic V12.0
2752 System Manual, 01/2013,
Alarms in the "HMI tags" Editor
Configuring discrete alarms in the "HMI tags" editor
Introduction
In WinCC, you can create and edit discrete and analog alarms, including the trigger tags, in
the "HMI tags" editor.
Note
If you delete, move or copy objects in the "HMI tags" editor, the changes also take effect in
the "HMI alarms" editor.
Requirements
The "HMI tags" editor is open.
Procedure
To configure a discrete alarm, proceed as follows:
1. To create a tag, click on "<Add>" in the table at the top of the work area.
A new tag is created.
2. Configure an internal or external tag as required.
Use the data types "Int" or "UInt" to select an HMI tag.
Use the data types "Int" or "Word" to select a PLC tag.
3. Select the tag at the top of the work area.
4. Click on "<Add>" in the table on the "Discrete alarms" tab at the bottom of the work area.
A new discrete alarm is created for the tag. If you have selected the incorrect data type,
the tag will be marked in the discrete alarm.
5. Configure the discrete alarm in the Inspector window:
Enter the alarm text under "Properties > Properties > General > Alarm text".
You can also insert output fields into the alarm text.
Select an alarm class.
Select the trigger bit of the tag that triggers the discrete alarm under "Properties >
Trigger".
6. You can create additional discrete alarms to monitor the tags.
Note
A tag is monitored using only one alarm type. You should therefore create either analog
alarms or discrete alarms for a tag.
Visualizing processes (Basic)
10.3 Working with alarms
STEP 7 Basic V12.0
System Manual, 01/2013, 2753
Result
The configured discrete alarms are created in the "HMI tags" editor and displayed in the "HMI
alarms" and "HMI tags" editors.
Configuring analog alarms in the "HMI tags" editor
Introduction
In WinCC, create the discrete and analog alarms, including the trigger tags, in the "HMI tags"
editor. You can also edit the alarms as in the "HMI alarms" editor. You can create up to two
range values for a tag. You monitor these limits with analog alarms.
Requirements
The "HMI tags" editor is open.
Procedure
To configure an analog alarm in the "HMI tags" editor, proceed as follows:
1. To create a tag, click on "<Add>" in the table at the top of the work area.
A new tag is created.
2. Configure an internal or external tag as required.
3. In the Inspector window, configure the range values of the tags under "Properties >
Properties > Range":
Select whether to use a "Constant" or an "HMI tag" as limit value for your range values.
The object list opens when you select "HMI tag". Select the tag you want to use.
Visualizing processes (Basic)
10.3 Working with alarms
STEP 7 Basic V12.0
2754 System Manual, 01/2013,
1. Click the "Analog Alarms" tab at the bottom of the work area.
Create an analog alarm for both range values.
2. Select an analog alarm and configure it in the Inspector window:
Enter the alarm text under "Properties > Properties > General > Alarm text".
You can also insert output fields into the alarm text.
You can change the default alarm class.
3. Configure the analog alarms as in the "HMI alarms" editor.
4. Complete the configuration of all analog alarms.
Note
A tag is monitored using only one alarm type. You should therefore create either analog
alarms or discrete alarms for a tag.
Result
The configured analog alarms are created in the "HMI tags" editor and displayed in the "HMI
alarms" and "HMI tags" editors.
10.3.2.3 Configuring alarm output
Overview of configuring alarm output
Steps to complete when configuring alarm output
You configure the alarm output in WinCC in the following steps:
1. Create alarm view
Use the display and control objects in the "Screens" editor to display alarms in Runtime.
2. Configure acknowledgment
In the "Screens" editor, you can set the operator action that will trigger the acknowledgment.
Visualizing processes (Basic)
10.3 Working with alarms
STEP 7 Basic V12.0
System Manual, 01/2013, 2755
Additional configuration tasks
Additional tasks may be necessary for configuring alarm views, depending on the requirements
of your project:
1. Setting up authorizations
To make sure only authorized operators process the alarms, assign authorizations for the
alarm view and the function keys of the HMI device.
2. Configuring the filtering of the alarm view
You configure the filtering of the alarms in Runtime in the "Screens" editor. You can also
configure alarm views that only display selected alarms.
3. Configure operator input alarms
Configure the operator input alarms on the operator controls of the HMI device in the
"Screens" editor. A preconfigured operator input alarm is output for an operator action. An
operator input is, e.g. the acknowledgment of an alarm.
Displaying alarms
Options for displaying alarms on the HMI device
WinCC offers the following options for displaying alarms on the HMI device:
Alarm view
The alarm view is configured in a screen. More than one alarm can be displayed
simultaneously, depending on the configured size. You can configure multiple alarm views
with different contents.
Alarm window
The Alarm window is configured in the "Global screen" editor. The alarm window can display
multiple alarms at the same time, depending on the configured size. An event can trigger
closing and reopening of the alarm window. To hide it during configuration, create an alarm
window on its own level.
Additional signals
Alarm indicator
The alarm indicator is a configurable, graphical icon. When an alarm comes in, the alarm
indicator is displayed on the HMI device. You configure the alarm indicator in the "Global
screen" editor.
The alarm indicator has two states:
Flashing: At least one alarm that requires acknowledgment is pending.
Static: The alarms are acknowledged but at least one of them has not gone out yet.
The alarm indicator also displays the number of pending alarms according to the HMI
device.
System functions
You can configure a list of functions for the event associated with an alarm. These functions
must be executed in Runtime when the event occurs.
Use system functions for alarms in WinCC to control the alarm view or the alarm window
other than via the toolbar.
Visualizing processes (Basic)
10.3 Working with alarms
STEP 7 Basic V12.0
2756 System Manual, 01/2013,
Displaying the predefined alarm classes in Runtime
The following table shows the symbols used to display the predefined alarm classes in the
alarm view:
Alarm class Displayed icon
"Errors" !
"System" $
"Warnings" <No symbol>
Configuring an alarm view
Introduction
Current alarms are displayed in Runtime in an alarm view or alarm window.
Requirement
A screen is open in the "Screen" editor.
The "Tools" task card is open.
Visualizing processes (Basic)
10.3 Working with alarms
STEP 7 Basic V12.0
System Manual, 01/2013, 2757
Configuring alarms for the alarm view
To specify the alarms that will be shown in the alarm view, proceed as follows:
1. Insert an "Alarm view" object from the "Tools" task card into the screen.
2. Select the alarm view.
In the Inspector window, select "Properties > Properties > General > View > Current
alarm states".
Set whether to display alarms with and/or without mandatory acknowledgment.
To display all alarms in the alarm buffer, enable "Alarm buffer".
3. In the table, activate the alarm classes to be displayed in the alarm view.
Visualizing processes (Basic)
10.3 Working with alarms
STEP 7 Basic V12.0
2758 System Manual, 01/2013,
Configuring the layout of the alarm view
To specify how the alarms are shown in the alarm view, proceed as follows.
1. Under "Properties > Properties > Layout > Settings > Lines per alarm" in the Inspection
window, specify the number of lines to display for each alarm.
2. In "Properties > Properties > View", select the control elements that are available on the
HMI device.
3. Configure the columns under "Properties > Properties > Columns":
Under "Visible columns" select the columns to be output in the alarm view.
Under "Properties Column", define the properties of the columns.
Under "Sort", select the sorting order of the alarms.
Result
Alarms of various alarm classes are output in the alarm view during runtime.
See also
Alarm view (Page 2673)
Configuring an alarm window
Introduction
The alarm window displays current alarms. The alarm window is configured in the "Global
Screen" editor and opens regardless of the current screen. The HMI device can still be used,
even if alarms are pending and displayed. An alarm window is displayed and configured like
an alarm view.
To hide an alarm window during configuration, create it on its own level.
Visualizing processes (Basic)
10.3 Working with alarms
STEP 7 Basic V12.0
System Manual, 01/2013, 2759
Requirement
The "Global Screen" editor is open.
The "Tools" task card is displayed.
The Inspector window is open.
Procedure
Proceed as follows to configure an alarm window:
1. Insert an "Alarm window" object from the "Tools" task card into the global screen.
2. Configure the alarm window like an alarm view.
3. Under "Properties > Properties > Mode > Window" in the Inspector window, select how
the alarm window reacts and is operated in Runtime.
Activate "Modal" if the alarm window is to retain the focus in Runtime after a screen
change.
This option is important, as switching back and forth between the screen and different
windows with <Ctrl+TAB> is not supported.
Result
During runtime, the alarms of the selected alarm class are displayed in the alarm window.
See also
Alarm window (Page 2676)
Configuring an alarm indicator
Introduction
The alarm indicator uses a warning triangle to indicate that alarms are pending or require
acknowledgement. If an alarm of the configured alarm class occurs, the alarm indicator is
displayed.
The alarm indicator has two states:
Flashing: At least one alarm that requires acknowledgment is pending.
Static: At least one of the acknowledged alarms has not gone out yet.
During configuration, specify whether Runtime has to open an alarm window when you operate
the alarm indicator.
Visualizing processes (Basic)
10.3 Working with alarms
STEP 7 Basic V12.0
2760 System Manual, 01/2013,
Requirement
The "Global Screen" editor is open.
The "Tools" task card is open.
The Inspector window is open.
Procedure
Proceed as follows to configure the alarm indicator:
1. Insert the "Alarm indicator" object from the "Tools" task card into the work area.
2. Select the alarm indicator.
3. Under "Properties > Properties > General" in the Inspector window, select the alarm
classes to be displayed by the alarm indicator.
Specify whether to display pending and/or acknowledged alarms in the alarm indicator.
4. Under "Properties > Event", assign system function "ShowAlarmWindow" to an event of
the alarm indicator.
Note
If you have configured a permanent window in the screen or template, do not position the
alarm window and alarm indicator in the vicinity of the permanent window. Otherwise the
alarm window and the alarm indicator are not displayed in Runtime. However, the
permanent window is not visible in the "Global screen" editor.
Result
The alarm indicator is displayed if alarms from the selected alarm class are pending or need
to be acknowledged in Runtime. The alarm window opens when the user operates the alarm
indicator.
Visualizing processes (Basic)
10.3 Working with alarms
STEP 7 Basic V12.0
System Manual, 01/2013, 2761
See also
Alarm indicator (Page 2678)
10.3.2.4 Acknowledging alarms
Configuring alarm acknowledgment by means of alarm class
Introduction
To configure an alarm with alarm acknowledgment, assign it to an alarm class with the "Alarm
with single acknowledgment" acknowledgment model.
Requirement
The "HMI alarms" editor is open.
The required alarm class has been created.
The required alarm has been created.
Selecting the acknowledgment model for an alarm class
The acknowledgment model for a predefined alarm class has already been set. You can only
set the acknowledgment model for user-defined alarm classes. Proceed as follows:
1. In the "HMI alarms" editor, click the "Alarm class" tab and select the alarm class.
2. Select the required acknowledgment model under "Properties > Properties >
Acknowledgment" in the Inspector window.
Assign alarms to an alarm class requiring acknowledgment
Proceed as follows to assign an alarm to an alarm class requiring acknowledgment.
1. In the "HMI alarms" editor, click the tab for the alarm type and select the alarm.
2. Under "Properties > Properties > General" in the Inspector window, select the alarm class
of the alarm.
Result
The alarm will not disappear in Runtime until it is acknowledged by the operator.
Visualizing processes (Basic)
10.3 Working with alarms
STEP 7 Basic V12.0
2762 System Manual, 01/2013,
Configuring trigger for alarm acknowledgment
Introduction
You always specify the acknowledgment requirement for an alarm using the alarm class. Then
the operator acknowledges the alarm using the "ACK" function key of the HMI device or the
"Acknowledgment" button of the alarm view.
The following options are also available to trigger acknowledgment:
Configuring a button to acknowledge an alarm
Acknowledgment of a Discrete Alarm by the PLC
Requirement
The "HMI alarms" editor is open.
The required alarm class has been created.
The required alarm has been created.
An alarm view and a button are created in the "Screens" editor.
Configuring a button to acknowledge an alarm
To configure a button for acknowledging an alarm, proceed as follows:
1. Select the button in the "Screens" editor.
2. Under "Properties > Events" in the Inspector window, assign the
"AlarmViewAcknowledgeAlarm" system function to the "Click" event.
3. Select the alarm view as parameter.
Visualizing processes (Basic)
10.3 Working with alarms
STEP 7 Basic V12.0
System Manual, 01/2013, 2763
Acknowledgment of a Discrete Alarm by the PLC
1. In the "HMI alarms" editor, click the "Discrete alarm" tab and select the discrete alarm.
2. In the Inspector window, select the tag and the bit that acknowledges the PLC alarm under
"Properties > Properties > Acknowledgment > PLC".
Sending alarm acknowledgments to the PLC
Requirement
The "HMI alarms" editor is open.
The required alarm has been created and assigned to an alarm class requiring
acknowledgment.
Note
You cannot send the acknowledgment of analog alarms to the PLC.
Sending alarm acknowledgments to the PLC
To configure that acknowledgment of an alarm is sent to the PLC, follow these steps:
1. In the "HMI alarms" editor, click the "Discrete alarm" tab and select the discrete alarm.
2. In the Inspector window, select "Properties > Properties > Acknowledgment".
3. Under "HMI", select the tag and the bit set by the alarm acknowledgment function.
Note
The HMI device and PLC only have read access to the acknowledgment tag memory area.
Visualizing processes (Basic)
10.3 Working with alarms
STEP 7 Basic V12.0
2764 System Manual, 01/2013,
Result
If the operator acknowledges the alarm in Runtime, the operating step is forwarded to the PLC.
10.3.3 Operating alarms in Runtime
10.3.3.1 Alarms in Runtime
Alarms
Alarms indicate events and states on the HMI device which have occurred in the system, in
the process or on the HMI device itself. A status is reported when it is received.
An alarm could trigger one of the following alarm events:
Incoming
Outgoing
Acknowledge
Loop-in-alarm
The configuration engineer defines which alarms must be acknowledged by the user.
An alarm may contain the following information:
Date
Time
Alarm text
Location of fault
Status
Alarm class
Alarm number
Alarm group
Alarm classes
Alarms are assigned to various alarm classes.
"Warnings"
Alarms of this class usually indicate states of a plant such as "Motor switched on". Alarms
in this class do not require acknowledgment.
"Errors"
Alarms in this class must always be acknowledged. Error alarms normally indicate critical
errors within the plant such as "Motor temperature too high".
Visualizing processes (Basic)
10.3 Working with alarms
STEP 7 Basic V12.0
System Manual, 01/2013, 2765
"System"
System alarms indicate states or events which occur on the HMI device.
System alarms provide information on occurrences such as operator errors or
communication faults.
Custom alarm classes
The properties of this alarm class must be defined in the configuration.
Alarm buffer
Alarm events are saved to an internal buffer. The size of this alarm buffer depends on the HMI
device type.
Alarm view
The alarm view shows selected alarms or alarm events from the alarm buffer. Whether alarm
events have to be acknowledged or not is specified in your configuration.
Alarm window
An alarm window shows all pending alarms or alarms awaiting acknowledgement of a particular
alarm class. The alarm window is displayed as soon as a new alarm occurs.
You can configure the order in which the alarms are displayed. You can choose to display the
alarms in ascending or descending order of their occurrence. The alarm window can also be
set to indicate the exact location of the fault, including the date and time of the alarm event.
By means of configuration, the display can be filtered in such a way that only alarms that
contain a specific character string will be shown.
Alarm indicator
The alarm indicator is a graphic icon that is displayed on the screen when an alarm of the
specified alarm class is activated.
The alarm indicator can have one of two states:
Flashing: At least one unacknowledged alarm is pending.
Static: The alarms are acknowledged but at least one of them has not gone out yet. The
displayed number indicates the number of queued alarms.
Visualizing processes (Basic)
10.3 Working with alarms
STEP 7 Basic V12.0
2766 System Manual, 01/2013,
10.3.3.2 Simple alarm view, simple alarm window in runtime
Application
The simple alarm view shows selected alarms or alarm events from the alarm buffer. The layout
and operation of the simple alarm window correspond to that of the simple alarm view.
Note
In the Engineering System, for example, dynamize the visibility of an object in the
"Animations" tab of the Inspector window. In Runtime, the "Simple alarm view" does not
support animations. If you configured an animation and, for example, run a consistency check
on the project, an error alarm is displayed in the output window.
Layout
Depending on the configuration, in the alarm view different columns with information regarding
an alarm or an alarm event are displayed.
To differentiate between the different alarm classes, the first column in the alarm view contains
an icon:
Icon Alarm class
! "Errors"
empty "Warnings"
depends on the configuration Custom alarm classes
$ "System"
Visualizing processes (Basic)
10.3 Working with alarms
STEP 7 Basic V12.0
System Manual, 01/2013, 2767
Operation
You use the alarm view as follows, depending on how it is configured:
Acknowledging alarms
Editing alarms
Control elements
The buttons have the following functions:
Button Function
Acknowledge alarm
Loop-In-Alarm
Changes to the screen that contains information about the error event
Displaying a tooltip for an alarm
Displays the full text of the selected alarm in a separate window, namely the alarm text
window
In the alarm text window, you can view alarm texts that exceed the space available in
the Alarm view. Close the alarm text window with the button.
Scrolls one alarm up.
Scrolls one page up in the alarm view.
Scrolls one page down in the alarm view.
Scrolls one alarm down.
Format of the control elements
The display of the buttons for using the simple alarm view depends on the configured size.
You should therefore check on the HMI device whether all the required buttons are
available.
10.3.3.3 Alarm indicator in Runtime
Application
The alarm indicator is displayed if alarms of the specified alarm class are pending or require
acknowledgment.
Visualizing processes (Basic)
10.3 Working with alarms
STEP 7 Basic V12.0
2768 System Manual, 01/2013,
Layout
The alarm indicator can have one of two states:
Flashing: At least one unacknowledged alarm is pending.
Static: The alarms are acknowledged but at least one of them has not gone out yet. The
displayed number indicates the number of queued alarms.
Operation
Depending on the configuration, when operating the alarm indicator an alarm window is
opened. The alarm indicator can only be operated with the touch screen.
10.3.3.4 Acknowledging alarms
Introduction
You can acknowledge alarms in Runtime according to your project configuration settings. You
can acknowledge alarms as follows:
Using the display and control object buttons
Using the "ACK" key on your HMI device
Using individually-configured function keys or buttons
If an operator authorization is configured for an individual control, the alarms can only be
acknowledged by authorized users.
To automatically acknowledge alarms in Runtime, use the system functions and the option
"Acknowledgment by the PLC".
Acknowledgment variants
You acknowledge individual alarms or multiple alarms together in Runtime. They are
distinguished as follows:
Single acknowledgment
Acknowledgment of an alarm using a button or a function key.
Acknowledge alarm groups
Acknowledgment of all the alarms of an alarm group using a button or a function key.
Requirement
An alarm is displayed on the HMI device.
Procedure
To acknowledge an alarm, proceed as follows:
1. Select the alarm.
2. Click on the button.
Visualizing processes (Basic)
10.3 Working with alarms
STEP 7 Basic V12.0
System Manual, 01/2013, 2769
Result
The alarm status changes to "Acknowledged". If the condition for triggering an alarm no longer
applies, the alarm status also changes to "Outgoing", and it is no longer displayed on the HMI
device.
10.3.4 Reference
10.3.4.1 System functions for alarms
System functions
System functions are predefined functions you can use to implement many tasks in runtime,
even with no programming knowledge. You use system functions in a function list.
The table shows all the system functions available for displaying and editing alarms.
System function Effect
EditAlarm Triggers the Loop-In-Alarm event for all selected
alarms.
ClearAlarmBuffer Deletes alarms from the alarm buffer on the HMI
device.
ClearAlarmBufferProtoolLegacy Function such as "ClearAlarmBuffer". This system
function has been retained to ensure compatibility
and uses the old ProTool numbering.
AlarmViewEditAlarm Triggers the event Loop-In-Alarm for all alarms
selected in the specified alarm view.
AlarmViewAcknowledgeAlarm Acknowledges the alarms that are selected in the
specified alarm view.
AlarmViewShowOperatorNotes Displays the configured tooltip for the alarm
selected in the specified alarm view.
AcknowledgeAlarm Acknowledges all selected alarms.
ShowAlarmWindow Hides or shows the alarm window on the HMI
device.
10.3.4.2 System events
Basics on system events
System events
System events on the HMI device provide information about internal states of the HMI device
and PLC.
Visualizing processes (Basic)
10.3 Working with alarms
STEP 7 Basic V12.0
2770 System Manual, 01/2013,
The following overview illustrates when a system event occurs and how to eliminate the cause
of error.
Note
HMI device dependency
Some of the system events described in this section apply to the individual HMI devices based
on their scope of functions.
Note
System events are output in an alarm view. System events are output in the language
currently set on your HMI device.
System event parameters
System events may contain encrypted parameters. The parameters are of relevance when
troubleshooting because they provide a reference to the source code of the Runtime software.
These parameters are output after the "Error code:" text.
30000 - Alarms errors when using system functions
Meaning of the system events
All system events that can be displayed are listed below. The system events are divided into
different ranges.
Table 10-2 30000 - Alarms errors when using system functions
Number Effect/causes Remedy
30010 The tag could not accept the function result, e.g.
when it has exceeded the value range.
Check the tag types of the system function parameters.
30011 A system function could not be executed because
the function was assigned an invalid value or type in
the parameter.
Check the parameter value and tag type of the invalid
parameter. If a tag is used as a parameter, check its
value.
30012 A system function could not be executed because
the function was assigned an invalid value or type in
the parameter.
Check the parameter value and tag type of the invalid
parameter. If a tag is used as a parameter, check its
value.
40000 - Linear scaling alarms
Meaning of the system alarms
All system alarms that can be displayed are listed below. The system alarms are divided into
different ranges:
Visualizing processes (Basic)
10.3 Working with alarms
STEP 7 Basic V12.0
System Manual, 01/2013, 2771
Table 10-3 40000 - Linear scaling alarms
Number Effect/causes Remedy
40010 The system function could not be executed since the
parameters could not be converted to a common tag
type.
Check the parameter types in the configuration.
40011 The system function could not be executed since the
parameters could not be converted to a common tag
type.
Check the parameter types in the configuration.
50000 - Data server alarms
Meaning of the system alarms
All system alarms that can be displayed are listed below. The system alarms are divided into
different ranges:
Table 10-4 50000 - Data server alarms
Number Effect/causes Remedy
50000 The HMI device is receiving data faster than it is
capable of processing. Therefore, no further data is
accepted until all current data have been processed.
Data exchange then resumes.
--
50001 Data exchange has been resumed. --
70000 - Win32 function alarms
Meaning of the system events
All system events that can be displayed are listed below.
Table 10-5 70000 - Win32 function alarms
Number Effect/causes Remedy
70010 The application could not be started because it could
not be found in the path specified or there is
insufficient memory space.
Check whether the application exists in the specified
path or close other applications.
70011 The system time could not be modified.
The error alarm only appears in connection with area
pointer "Date/time PLC". Possible causes:
An invalid time was transferred in the job mailbox.
The Windows user has no right to modify the
system time.
If the first parameter in the system event is displayed
with the value 13, the second parameter indicates
the byte containing the incorrect value.
Check the time which is to be set.
Using Windows NT/XP: Users running WinCC Runtime
must be granted the right to set the system time of the
operating system.
Visualizing processes (Basic)
10.3 Working with alarms
STEP 7 Basic V12.0
2772 System Manual, 01/2013,
Number Effect/causes Remedy
70012 Error when executing the function "StopRuntime"
with the "Runtime and operating system" option.
Windows and WinCC Runtime are not closed.
The error was possibly generated because other
programs cannot be closed.
Close all programs currently running.
Then close Windows.
70013 The system time could not be modified because an
invalid value was entered. Incorrect separators may
have been used.
Check the time which is to be set.
70014 The system time could not be modified. Possible
causes:
An invalid time was transferred.
The Windows user has no right to modify the
system time.
Windows rejects the setting request.
Check the time which is to be set.
Using Windows NT/XP: Users running WinCC Runtime
must be granted the right to set the system time of the
operating system.
70015 The system time could not be read because
Windows rejects the reading function.
--
70016 An attempt was made to select a screen by means
of a system function or job. This is not possible
because the screen number specified does not exist.
Or: A screen could not be generated due to
insufficient system memory.
Or: The screen is blocked.
Or: Screen call has not been executed correctly.
Check the screen number in the function or job with the
screen numbers configured.
Assign the number to a screen if necessary.
Check the details for the screen call and whether the
screen is blocked for specific users.
70017 Date/time is not read from the area pointer because
the address set in the PLC is either not available or
has not been set up.
Change the address or set up the address in the PLC.
70018 Acknowledgment that the password list has been
successfully imported.
--
70019 Acknowledgment that the password list has been
successfully exported.
--
70020 Acknowledgment for activation of alarm reporting. --
70021 Acknowledgment for deactivation of alarm reporting. --
70022 Acknowledgment to starting the Import Password
List action.
--
70023 Acknowledgment to starting the Export Password
List action.
--
70024 The range of values of the tag was exceeded in the
system function.
No calculation of the system function.
Check and correct the calculation.
70025 The range of values of the tag was exceeded in the
system function.
No calculation of the system function.
Check and correct the calculation.
70026 No other screens are stored in the internal screen
memory.
No other screens can be selected.
--
70027 The backup of the RAM file system has been started. --
Visualizing processes (Basic)
10.3 Working with alarms
STEP 7 Basic V12.0
System Manual, 01/2013, 2773
Number Effect/causes Remedy
70028 The files from the RAM have been copied in the
Flash memory.
The files from the RAM have been copied in the
Flash memory. Following a restart, these saved files
are copied back to the RAM file system.
--
70029 Backup of the RAM file system has failed.
No backup copy of the RAM file system has been
made.
Check the settings in the "Control Panel > OP" dialog
and save the RAM file system using the "Save Files"
button in the "Persistent Storage" tab.
70030 The parameters configured for the system function
are faulty.
The connection to the new PLC was not established.
Compare the parameters configured for the system
function with the parameters configured for the PLCs
and correct them as necessary.
70031 The PLC configured in the system function is not an
S7 PLC.
The connection to the new PLC was not established.
Compare the S7 PLC name parameter configured for
the system function with the parameters configured for
the PLC and correct them as necessary.
70032 The object configured with this number in the tab
sequence is not available in the selected screen.
The screen changes but the focus is set to the first
object.
Check the number of the tab sequence and correct it if
necessary.
70033 An e-mail cannot be sent because a TCP/IP
connection to the SMTP server no longer exists.
This system event is generated only at the first
attempt. All subsequent unsuccessful attempts to
send an e-mail will no longer generate a system
event. The event is regenerated when an e-mail has
been successfully sent in the meantime.
The central e-mail component in WinCC Runtime
attempts to connect to the SMTP server at cyclic
intervals (1 minute) in order to transmit the remaining
e-mails.
Check the network connection to the SMTP server and
re-establish it if necessary.
70034 Following a disruption, the TCP/IP connection to the
SMTP server could be re-established.
The queued e-mails are then sent.
--
70036 No SMTP server for sending e-mails is configured.
An attempt to connect to an SMTP server has failed
and it is not possible to send e-mails.
WinCC Runtime generates the system event after
the first attempt was made to send an e-mail.
Configure an SMTP server:
In the WinCC Engineering System
using "Device settings > Device settings"
In the Windows CE operating system
using "Control Panel > Internet Settings > E-mail >
SMTP Server"
70037 An e-mail cannot be sent for unknown reasons.
The contents of the e-mail are lost.
Check the e-mail parameters (recipient etc.).
70038 The SMTP server has rejected sending or
forwarding an e-mail because the domain of the
recipient is unknown to the server or because the
SMTP server requires authentication.
The contents of the e-mail are lost.
Check the domain of the recipient address or disable
the authentication on the SMTP server if possible.
SMTP authentication is currently not used in
WinCC Runtime.
70039 The syntax of the e-mail address is incorrect or
contains illegal characters.
The contents of the e-mail are discarded.
Check the e-mail address of the recipient.
70040 The syntax of the e-mail address is incorrect or
contains illegal characters.
--
Visualizing processes (Basic)
10.3 Working with alarms
STEP 7 Basic V12.0
2774 System Manual, 01/2013,
Number Effect/causes Remedy
70041 The import of the user management was aborted
due to an error.
Nothing was imported.
Check your user administration or download it again to
the panel.
70042 The range of values of the tag was exceeded while
executing the system function.
The system function was not calculated.
Check and correct the calculation.
70043 The range of values of the tag was exceeded while
executing the system function.
The system function was not calculated.
Check and correct the calculation.
70044 An error occurred while sending the e-mails. The e-
mails were not sent.
Check the SMTP settings and the error message in the
system event.
70045 Cannot load a file required for encrypting the e-mail. Update the operating system and Runtime.
70046 The server does not support encryption. Select an SMTP server that supports encryption.
70047 The SSL versions of the HMI device and SMTP
server may not be compatible.
Contact your network administrator or the operator of
the SMTP server.
110000 - Offline function alarms
Meaning of the system events
All system events that can be displayed are listed below.
Table 10-6 110000 - Offline function alarms
Number Effect/causes Remedy
110000 The operating mode was changed. "Offline" mode
is now set.
--
110001 The operating mode was changed. "Online" mode
is now set.
--
110002 The operating mode was not changed. Check the connection to the PLCs.
Check whether the address range for the Coordination"
area pointer is present in the PLC.
110003 The operating mode of the specified PLC was
changed by the "SetConnectionMode" system
function.
The "offline" operating mode is now set.
--
110004 The operating mode of the specified PLC was
changed by the "SetConnectionMode" system
function.
The "online" operating mode is now set.
--
110005 An attempt was made to use the
"SetConnectionMode" system function to set the
specified PLC to "online" mode, although the entire
system is in "offline" mode. This changeover is not
allowed. The PLC remains in "offline" mode.
Switch the complete system to "online" mode and repeat
execution of the system function.
110006 The content of the "project ID" area pointer does not
match the project ID configured in WinCC. The
WinCC Runtime is therefore terminated.
Check:
the project ID entered on the PLC.
the project ID entered in WinCC.
Visualizing processes (Basic)
10.3 Working with alarms
STEP 7 Basic V12.0
System Manual, 01/2013, 2775
120000 - Trend alarms
Meaning of the system alarms
All system alarms that can be displayed are listed below.
Table 10-7 120000 - Trend alarms
Number Effect/causes Remedy
120000 The trend is not displayed because you configured
an incorrect axis to the trend or an incorrect trend.
Change the configuration.
120001 The trend is not displayed because you configured
an incorrect axis to the trend or an incorrect trend.
Change the configuration.
120002 The trend is not displayed because the tag assigned
attempts to access an invalid PLC address.
Check whether the data area for the tag exists in the
PLC, the configured address is correct and the value
range for the tag is correct.
140000 - Connection alarms: Connection + device
Meaning of the system events
All system events that can be displayed are listed below.
Table 10-8 140000 - Connection alarms: Connection + device
Number Effect/causes Remedy
140000 An online connection to the PLC is established. --
140001 The online connection to the PLC was shut down. --
140003 No tag update or write operations are executed. Check whether the connection is up and the PLC is
switched on.
In the Control Panel, check the set parameters using the
"Set PG/PC interface" function.
Restart the system.
140004 No tag update or write operations are executed due
to an incorrect access point, or incorrect module
configuration.
Check the connection and whether the PLC is switched
on.
Check the access point or the module configuration
(MPI, PPI, PROFIBUS) in the Control Panel with "Set
PG/PC interface".
Restart the system.
140005 No tag update or write operations are executed due
to an incorrect HMI device address (possibly too
high).
Use a different address for the HMI device.
Check the connection and whether the PLC is switched
on.
Check the parameters set in the "Set PG/PC interface"
dialog of the Control Panel.
Restart the system.
140006 No tag update or write operations are executed due
to an incorrect baud rate setting.
Select a different baud rate in WinCC (according to
module, profile, communication peer, etc.).
Visualizing processes (Basic)
10.3 Working with alarms
STEP 7 Basic V12.0
2776 System Manual, 01/2013,
Number Effect/causes Remedy
140007 An incorrect bus profile prevents tag updates or
write operations (see %1).
The following parameters could not be written to the
registry database:
1: Tslot
2: Tqui
3: Tset
4: MinTsdr
5: MaxTsdr
6: Trdy
7: Tid1
8: Tid2
9: Gap Factor
10: Retry Limit
Check the custom bus profile.
Check the connection and whether the PLC is switched
on.
Check the parameters set in the "Set PG/PC interface"
dialog of the Control Panel.
Restart the system.
140008 An incorrect baud rate prevents tag updates or write
operations. The following parameters could not be
written to the registry database:
0: General error
1: Wrong version
2: Profile cannot be written to the registry database.
3: The subnet type cannot be written to the registry
database.
4: The Target Rotation Time cannot be written to
the registry database.
5: Incorrect Highest Station Address (HSA).
Check whether the connection is up and the PLC is
switched on.
In the Control Panel, check the set parameters using the
"Set PG/PC interface" function.
Restart the system.
140009 No tag updates or write operations because the S7
communication module was not found.
To reinstall the module, open the Control Panel and
select "Set PG/PC interface".
140010 No S7 communication partner found because the
PLC is shut down.
DP/T:
The option "PG/PC is the only master" is not set in
the Control Panel under "Set PG/PC interface".
Switch on the PLC.
DP/T:
If only one master is connected to the network, disable
"PG/PC is the only master" in "Set PG/PC interface".
If several masters are connected to the network, enable
these. Do not change any settings, for this will cause bus
errors.
140011 No tag updates or write operations because
communication is down.
Check the connection and whether the communication
partner is switched on.
140012 Initialization error (e.g. if WinCC Runtime was
closed in Task Manager).
Or:
Another application (e.g.STEP7) with different bus
parameters is active and the driver cannot be
started with the new bus parameters (baud rate, for
example).
Restart the HMI device.
Or:
Start WinCC Runtime and then start your other
applications.
140013 The MPI cable is disconnected and, therefore, there
is no power supply.
Check the connections.
140014 The configured bus address is in use by another
application.
Change the HMI device address in the PLC
configuration.
140015 Incorrect baud rate
Or:
Incorrect bus parameters (e.g. HSA)
Or:
OP address > HSA or: Incorrect interrupt vector
(interrupt not registered by the driver)
Correct the parameters.
Visualizing processes (Basic)
10.3 Working with alarms
STEP 7 Basic V12.0
System Manual, 01/2013, 2777
Number Effect/causes Remedy
140016 The hardware does not support the configured
interrupt.
Change the interrupt number.
140017 The set interrupt is in use by another driver. Change the interrupt number.
140018 SIMOTION Scout disabled the consistency check.
Only a corresponding note appears.
In SIMOTION Scout, reactivate the consistency check
and once again download the project to the PLC.
140019 SIMOTION Scout is downloading a new project to
the PLC. Connection to the PLC is canceled.
Wait until the end of the reconfiguration.
140020 Mismatch of the PLC and project (FWX file)
versions.
The connection to the PLC is canceled.
The following remedies are available:
Download the current version to the PLC using
SIMOTION Scout.
Recompile the project using WinCC ES, close
WinCC Runtime, and restart with the new configuration.
140021 Setup of the connection to the PLC failed. Incorrect
configuration of the "Access password" for the
connection to the PLC.
Select the "Access password" area in the "Connections"
editor to check the password entered for the connection
to the PLC.
The "Password" for the connection to the PLC is
assigned in the "Security" area of the PLC properties.
140022 Setup of the connection to the PLC failed. Incorrect
configuration of the access password for the
connection to the PLC.
Select the "Access password" area in the "Connections"
editor to check the password entered for the connection
to the PLC.
The "Password" for the connection to the PLC is
assigned in the "Security" area of the PLC properties.
180000 - General alarms
Meaning of the system events
All system events that can be displayed are listed below.
Table 10-9 180000 - General alarms
Number Effect/causes Remedy
180000 A component/OCX received configuration data with
a version ID which is not supported.
Install a newer component.
180001 System overload because too many actions are
running in parallel. Certain actions can be executed,
while others are discarded.
Several remedies are available:
Generate alarms at a slower rate (polling).
Initiate scripts and functions at greater intervals.
If the alarm appears more frequently:
Restart the HMI device.
180002 The screen keyboard could not be activated.
Possible causes:
"TouchInputPC.exe" was not registered due to
faulty Setup.
Reinstall WinCC Runtime.
Visualizing processes (Basic)
10.3 Working with alarms
STEP 7 Basic V12.0
2778 System Manual, 01/2013,
190000 - Tag alarms
Meaning of the system events
All system events that can be displayed are listed below.
Table 10-10 190000 - Tag alarms
Number Effect/causes Remedy
190000 It is possible that the tag is not updated. --
190001 The tag is updated after the cause of the last error
state has been eliminated (recovery of normal
operation).
--
190002 The tag is not updated because communication with
the PLC is down.
Select system function "SetOnline" to enable
communication.
190004 The tag is not updated because the address
configured for this tag does not exist.
Check the configuration.
190005 The tag is not updated because the configured PLC
type does not exist for this tag.
Check the configuration.
190006 The tag is not updated because it is not possible to
map the PLC type in the data type of the tag.
Check the configuration.
190007 The tag value is not modified because the
connection to the PLC is interrupted or the tag is
offline.
Set online mode or reconnect to the PLC.
190008 The configured tag limits were violated due to one
of the following events:
Value input
System function
Script
Observe the configured or current tag limits.
190009 An attempt was made to assign this tag a value that
is outside the valid range of values for this data type.
For example, input of the value 260 for a byte tag,
or input of the value -3 for an unsigned word tag.
Observe the range of values for the data type of the tags.
190010 The rate at which values are written to the tag is too
high (e.g. initiated in a script loop).
Values will be lost because buffer capacity is limited
to 100 operations.
The following remedies are available:
Extend the interval between multiple write actions.
Do not use an array tag longer than 6 words when
configuring an acknowledgment on the HMI device
using "HMI acknowledgment tag".
190011 Possible cause 1:
The value entered could not be written to the
configured PLC tag because the high or low limit
was exceeded.
The system discarded the entry and restored the
original value.
Possible cause 2:
The connection to the PLC was interrupted.
Note that the value entered must be within the range of
values of the control tag.
Check the connection to the PLC.
Visualizing processes (Basic)
10.3 Working with alarms
STEP 7 Basic V12.0
System Manual, 01/2013, 2779
Number Effect/causes Remedy
190012 It is not possible to convert a value from a source
format to a target format, for example:
An attempt is being made to write a counter value
that is outside the valid, PLC-specific range of
values.
A tag of the type Integer should be assigned a value
of the type string.
Check the range of values, or the data type of the tag.
190013 You entered a string that exceeds the tag length.
The string is truncated automatically to a valid
length.
Always enter strings that do not exceed the valid tag
length.
190100 - Area pointer alarms
190100 - Area pointer alarms
Number Effect/causes Remedy
190100 The area pointer is not updated because the
address configured for this pointer does not exist.
Type
1 Warnings
2 Errors
3 PLC acknowledgment
4 HMI device acknowledgment
5 LED image
6 Trend request
7 Trend transfer 1
8 Trend transfer 2
No.:
Consecutive number displayed in WinCC ES.
Check the configuration.
190101 The area pointer is not updated because it is not
possible to map the PLC type to the area pointer
type.
Parameter type and no.:
see alarm 190100
--
190102 The area pointer is updated after the cause of the
last error state has been eliminated (recovery of
normal operation). Parameter type and no.: See
alarm 190100.
--
Visualizing processes (Basic)
10.3 Working with alarms
STEP 7 Basic V12.0
2780 System Manual, 01/2013,
200000 - PLC coordination alarms
200000 - PLC coordination alarms
Number Effect/causes Remedy
200000 Coordination is not executed because the address
configured in the PLC does not exist/is not set.
Change the address or set up the address in the PLC.
200001 Coordination is canceled because the write access
to the address configured in the PLC is not possible.
Change the address or set the address in the PLC at an
area which allows write access.
200002 Coordination is not carried out at the moment
because the address format of the area pointer
does not match the internal storage format.
Internal error
200003 Coordination can be executed again because the
last error state is eliminated (return to normal
operation).
--
200004 The coordination may not be executed. --
200005 No more data is read or written. Possible causes:
The cable is defective.
The PLC does not respond, is defective, etc.
System overload
Ensure that the cable is plugged in and the PLC is
operational.
Restart the system if the system alarm persists.
210000 - PLC job alarms
210000 - PLC job alarms
Number Effect/causes Remedy
210000 Jobs are not processed because the configured
address does not exist/has not been set up in
the PLC.
Change the address or set up the address in the PLC.
210001 Jobs are not processed because read/write
access to the configured address is not possible
in the PLC.
Change the address, or set up the address in a PLC
area at which read/write access is possible.
210002 Jobs are not executed because the address
format of the area pointer does not match the
internal storage format.
Internal error
210003 The job buffer is processed again because the
last error status has been eliminated (recovery
of normal operation).
--
210004 The job buffer is possibly not going to be
processed.
--
210005 A job mailbox with invalid number was initiated. Check the PLC program.
210006 An error occurred while executing the job
mailbox. As a result, the control job is not
executed. Observe the next/previous system
event.
Check the parameters of the control job. Recompile
the configuration data.
Visualizing processes (Basic)
10.3 Working with alarms
STEP 7 Basic V12.0
System Manual, 01/2013, 2781
220000 - WinCC communication driver alarms
220000 - WinCC communication driver alarms
Number Effect/causes Remedy
220001 The tag is not downloaded because write access
to data type Bool/Bit is not supported by the
sublevel communication driver/HMI device.
Change the configuration.
220002 The tag is not downloaded because write access
to data type Byte is not supported by the
sublevel communication driver/HMI device.
Change the configuration.
220003 The communication driver cannot be loaded as
it is possibly not installed.
Install the driver by reinstalling WinCC Runtime.
220004 Communication is down and no update data is
transferred because the cable is not connected
or defective etc.
Check the connection.
220005 Communication is up. --
220006 The connection between the specified PLC and
the specified port is active.
--
220007 The connection to the specified PLC is
interrupted at the specified port.
Check the following:
Is the cable plugged in?
Is the PLC OK?
Is the right port being used?
Is your configuration OK (port parameters,
protocol settings, PLC address)?
Restart the system if the system event persists.
220008 The communication driver cannot access or
open the specified port. This port might be in use
by another application, or a port that does not
exist on the target device is being used.
No communication with the PLC.
Close all applications that access the port and restart
the computer.
Use another port that exists in the system.
Visualizing processes (Basic)
10.3 Working with alarms
STEP 7 Basic V12.0
2782 System Manual, 01/2013,
230000 - Screen object alarms
230000 - Screen object alarms
Number Effect/causes Remedy
230000 The value entered could not be used. The system
discards this entry and restores the previous
value.
Possible causes:
The range of values is exceeded.
You entered invalid characters
The valid maximum number of users has
been exceeded.
Enter a practical value, or delete a user that is no
longer required.
230002 The user currently logged on does not have the
necessary authorization, so the system discards
the entry and restores the previous value.
Log on as user with appropriate authorization.
230003 Change to the specified screen failed because
this screen is not available/configured. The
current screen remains selected.
Configure the screen and check the selection
function.
230005 The range of values of the tag has been
exceeded in the I/O field.
The original tag value is retained.
Observe the range of values for the tag when
entering a value.
230100 During navigation in the Web browser, the
system returned a message which may be of
interest to the user.
The Web browser continues to run but may not
(fully) show the new page.
Navigate to another page.
230200 The HTTP channel connection was interrupted
due to an error. This error is explained in detail
by another system event.
Data is no longer exchanged.
Check the network connection.
Check the server configuration.
230201 The HTTP channel connection is set up.
Data is exchanged.
--
Visualizing processes (Basic)
10.3 Working with alarms
STEP 7 Basic V12.0
System Manual, 01/2013, 2783
Number Effect/causes Remedy
230202 WININET.DLL has detected an error. Usually,
this error occurs if it is not possible to connect to
the server, or the server denies a connection
because the client lacks proper authorization.
An unknown server certificate may also be the
cause if the connection is encrypted by means of
SSL.
The alarm text provides details.
This text is always in the language of the
Windows installation because it is returned by the
Windows OS.
Process values are no longer exchanged.
The part of the alarm returned by the Windows
OS might not be displayed, e.g. "An error has
occurred". WININET.DLL returns the following
error: Number: 12055 Text:HTTP: <no error text
available>."
Depending on the cause:
When an attempt to connect fails, or a timeout occurs:
Check the network connection and the network.
Check the server address.
Check whether the WebServer is actually running
on the target station.
Incorrect authorization:
The configured user name and/or password do
not match the entries on the server. Set
consistent data.
If the server certificate is rejected:
Certificate signed by an unknown CA ( ):
Ignore this point, or install a certificate that has
been signed with one of the root certificates
known to the client station.
The date of the certificate is invalid:
Ignore this point, or install a certificate with valid
date on the server.
Invalid CN (Common Name or Computer Name):
Ignore this point, or install a certificate with a
name that corresponds to the server address.
230203 Although a connection can be made to the
server, the HTTP server refused to connect.
Possible causes:
WinCC Runtime does not run on the server
The HTTP channel is not supported (503
Service unavailable).
Other errors can only occur if the Webserver
does not support the HTTP channel. The
language of the alarm text depends on the
Webserver.
Data is not exchanged.
On 503 Service unavailable error:
Check whether WinCC Runtime is running on the
server and whether the HTTP channel is supported.
230301 Internal error. An English text explains the error
in more detail. The error may be caused by
insufficient memory.
OCX does not work.
--
230302 The name of the remote server cannot be
resolved.
An attempt to connect has failed.
Check the configured server address.
Check whether the DNS service is available on the
network.
230303 The remote server is not running on the
addressed computer.
incorrect server address.
An attempt to connect has failed.
Check the configured server address.
Check whether the remote server is running on the
target computer.
230304 The remote server on the addressed computer is
incompatible with VNCOCX.
An attempt to connect failed.
Use a compatible remote server.
230305 Authentication has failed due to incorrect
password.
An attempt to connect failed.
Configure the correct password.
Visualizing processes (Basic)
10.3 Working with alarms
STEP 7 Basic V12.0
2784 System Manual, 01/2013,
Number Effect/causes Remedy
230306 Error in the connection to the remote server. This
may occur as a result of network problems.
An attempt to connect failed.
Check whether the network cable is plugged in, or
whether there are network problems.
230307 The connection to the remote server was shut
down. Possible causes:
The remote server was shut down
The user instructed the server to close all
connections.
The connection is cancelled.
--
230308 This alarm provides information on the
connection status.
An attempt is made to connect.
--
260000 - Password system alarms
260000 - Password system alarms
Number Effect/causes Remedy
260000 An unknown user or an unknown password has
been entered in the system.
The current user is logged off from the system.
Log on to the system as a user with a valid password.
260001 The logged in user does not have sufficient
authorization to execute the protected functions
on the system.
Log on to the system as a user with sufficient
authorization.
260002 This alarm output when the "TrackUserChange"
system function is triggered.
--
260003 The user has logged off from the system. --
260004 The user name entered into the user view
already exists in the user management.
Select another user name because user names have
to be unique in the user management.
260005 The entry is discarded. Enter a shorter user name.
260006 The entry is discarded. Use a shorter or longer password.
260007 The logoff time entered is outside the valid range
from 0 to 60 minutes.
The new value entered is discarded and the
original value is retained.
Enter a logon timeout value between 0 and 60
minutes.
260008 An attempt was made in WinCC to read a
PTProRun.pwl file created with ProTool V 6.0.
Reading of the file was canceled due to
incompatibility of the format.
--
260009 You have attempted to delete the user "Admin"
or "PLC User". These users are fixed
components of the user management and
cannot be deleted.
If you need to delete a user, because perhaps you
have exceeded the maximum number permitted,
delete another user.
260012 The password entries in the "Change Password"
dialog and in the confirmation field do not match.
The password is not changed. User will be
logged off.
You have to log on to the system again. Then enter
the identical password twice to be able to change the
password.
Visualizing processes (Basic)
10.3 Working with alarms
STEP 7 Basic V12.0
System Manual, 01/2013, 2785
Number Effect/causes Remedy
260013 The password entered in the "Change
Password" dialog is invalid because it is already
in use.
The password is not changed. User will be
logged off.
You have to log on to the system again. Then enter a
new password that has not been used before.
260014 You have tried to log on with an incorrect
password three times in a row.
You will be locked out and assigned to group no.
0.
You can log on to the system with your correct
password. Only an administrator can change the
assignment to a group.
260024 The password you entered does not meet the
necessary security guidelines.
Enter a password that contains at least one number.
260025 The password you entered does not meet the
necessary security guidelines.
Enter a password that comprises at least three
characters.
260028 Upon system start-up, an attempt to log on, or
when trying to change the password of a
SIMATIC log-on user, the system attempts to
access the SIMATIC Logon Server.
If attempting to log on, the new user is not logged
in. If a different user was logged on before, then
this user is logged off.
Check the connection to the SIMATIC Logon Server
and its configuration; for example:
1. Port number
2. IP address
3. Server name
4. Functional transfer cable
Or use a local user.
260030 The SIMATIC Logon user could not change his
password on the SIMATIC Logon Server. The
new password is possibly noncompliant with
password rules set on the server, or the user is
not authorized to change his password.
The old password remains and the user is
logged off.
Log in again and choose a different password. Check
the password rules on the SIMATIC Logon Server.
260033 The action change password or log on user
could not be carried out.
Check the connection to the SIMATIC Logon Server
and its configuration; for example:
1. Port number
2. IP address
3. Server name
4. Functional transfer cable
Or use a local user.
260034 The last logon operation has not yet ended. A
user action or a logon dialog can therefore not
be called.
The logon dialog is not opened. The user action
is not executed.
Wait until the logon operation is complete.
260035 The last attempt to change the password was
not completed. A user action or a logon dialog
can therefore not be called.
The logon dialog is not opened. The user action
is not executed.
Wait until the procedure is complete.
260036 There are insufficient licenses on the SIMATIC
Logon Sever. The logon is not authorized.
Check the licensing on the SIMATIC Logon Server.
Visualizing processes (Basic)
10.3 Working with alarms
STEP 7 Basic V12.0
2786 System Manual, 01/2013,
Number Effect/causes Remedy
260037 There is no license on the SIMATIC Logon
Sever. A logon is not possible.
It is not possible to log on via the SIMATIC Logon
Server, only via a local user.
Check the licensing on the SIMATIC Logon Server.
260040 The system attempts to access the SIMATIC
Logon Server upon system start-up or when
trying to change the password.
If attempting to log on, the new user is not logged
in. If a different user was logged on before, then
this user is logged off.
Check connection to the domain and its configuration
in the Runtime security settings editor.
Or use a local user.
260043 It was not possible to log the user on to the
SIMATIC Logon Server. The user name or the
password could be incorrect or the user does not
have sufficient rights to log on.
The new user is not logged in. If a different user
was logged on before, then this user is logged
off.
Try again. If necessary, check the password data on
the SIMATIC Logon Server.
260044 It was not possible to log the user on to the
SIMATIC Logon Server as his account is
blocked.
The new user is not logged in. If a different user
was logged on before, then this user is logged
off.
Check the user data on the SIMATIC Logon Server.
260045 The SIMATIC Logon user is not associated to
any or several groups.
The new user is not logged in. If a different user
was logged on before, then this user is logged
off.
Check user data on the SIMATIC Logon Server and
the configuration in your WinCC project. A user may
only be assigned to one group.
270000 - System alarms
270000 - System Alarms
Number Effect/causes Remedy
270000 The alarm does not indicate the tag because it
is accessing an invalid address in the PLC.
Check whether the data area for the tag exists on the
PLC, whether the configured address is correct, and
whether the value range for the tag is correct.
270001 There is a device-specific limit as to how many
alarms may be queued for viewing (see the
operating instructions). This limit has been
exceeded.
The view no longer contains all the alarms.
However, all alarms are written to the alarm
buffer.
--
270002 The view shows alarms of a log for which there
is no data in the current project.
Placeholders are output for the alarms.
Delete old log data, if necessary.
Visualizing processes (Basic)
10.3 Working with alarms
STEP 7 Basic V12.0
System Manual, 01/2013, 2787
Number Effect/causes Remedy
270003 The service cannot be set up because too many
devices want to access this service.
A maximum of four devices can execute this
action.
Reduce the number of HMI devices which want to use
the service.
270004 Access to the persistent alarm buffer is not
possible. Alarms cannot be restored or backed
up.
If the problems persist at the next restart, contact
Customer Support (delete Flash).
270005 Persistent alarm buffer corrupted: Alarms
cannot be restored.
If the problems persist at the next restart, contact
Customer Support (delete Flash).
270006 Project modified: Alarms cannot be restored
from the persistent alarm buffer.
The project was compiled and downloaded again to
the HMI device. The error should no longer occur at
the next restart of the HMI device.
270007 A configuration problem is preventing you from
the restoring the data (e.g. a DLL was deleted,
or unknown directory).
Update the operating system and download your
project again to the HMI device.
290000 - Recipe system alarms
290000 - Recipe system alarms
Number Effect/causes Remedy
290000 The recipe tag could not be read or written. It is
assigned the start value.
The alarm can be entered in the alarm buffer for
up to four more faulty tags. After that, alarm
290003 is output.
Check the configuration to see whether the address
has been set up in the PLC.
290001 An attempt was made to assign the recipe tag a
value that is outside the valid range of values for
this type.
The alarm can be entered in the alarm buffer for
up to four more faulty tags if necessary. After
that, alarm 290004 is output.
Observe the range of values for the tag type.
290002 It is not possible to convert a value from a source
format to a target format.
The alarm can be entered in the alarm buffer for
up to four more faulty recipe tags if necessary.
After that, alarm 290005 is output.
Check the range of values or type of the tag.
290003 This alarm is output after alarm 290000 was
triggered more than five times.
In this case, no further separate alarms are
generated.
Check the configuration to see whether the tag
addresses have been set up in the PLC.
290004 This alarm is output after alarm 290001 was
triggered more than five times.
In this case, no further separate alarms are
generated.
Observe the range of values for the tag type.
290005 This alarm is output after alarm 290002 was
triggered more than five times.
In this case, no further separate alarms are
generated.
Check the range of values or type of the tag.
Visualizing processes (Basic)
10.3 Working with alarms
STEP 7 Basic V12.0
2788 System Manual, 01/2013,
Number Effect/causes Remedy
290006 The limits configured for the tag have been
exceeded by the values entered.
Observe the configured or current tag limits.
290007 There is a difference between the source and
target structure in the recipe currently being
processed. The target structure contains an
additional recipe tag that is not available in the
source structure.
The recipe tag specified is assigned its start
value.
Insert the specified recipe tag into the source
structure.
290008 There is a difference between the source and
target structure in the recipe currently being
processed.The source structure contains an
additional recipe tag that is not available in the
target structure and cannot be assigned.
The value is discarded.
Remove the specified recipe tag in the specified
recipe from the project.
290010 The storage location configured for the recipe is
invalid.
Possible causes:
Invalid characters, write protection, data carrier
out of space or not available.
Check the configured storage location.
290011 A data record of the specified number does not
exist.
Check the source for the number (constant or tag
value).
290012 A recipe of the specified number does not exist. Check the source for the number (constant or tag
value).
290013 An attempt was made to save a data record
under a data record number that already exists.
The operation is not executed.
The following remedies are available:
Check the source for the number (constant or tag
value).
First, delete the data record.
Modify the "Overwrite" function parameter.
290014 The specified import file was not found. Check the following:
The file name
Ensure that the file is in the specified directory.
290020 Check back to verify that the download of data
records from the HMI device to the PLC has
started.
--
290021 Check back to verify that the download of
records from the HMI device to the PLC was
completed.
--
290022 Check back to indicate that the download of data
records from the HMI device to the PLC was
canceled due to an error.
Check the following conditions in the configuration:
Are the tag addresses configured in the PLC?
Does the recipe number exist?
Does the data record number exist?
Is the "Overwrite" function parameter set?
290023 Check back to verify that the download of data
records from the PLC to the HMI device has
started.
--
290024 Check back to verify that the download of data
records from the PLC to the HMI device was
completed.
---
Visualizing processes (Basic)
10.3 Working with alarms
STEP 7 Basic V12.0
System Manual, 01/2013, 2789
Number Effect/causes Remedy
290025 Check back to indicate that the download of data
records from the PLC to the HMI device was
canceled due to an error.
Check the following conditions in the configuration:
Are the tag addresses configured in the PLC?
Does the recipe number exist?
Does the data record number exist?
Is the "Overwrite" function parameter set?
290026 An attempt was made to read/write a data record
that is not free at present.
This error can occur if recipes were configured
for download with synchronization.
Set the mailbox status to zero.
290027 Unable to connect to the PLC at present. As a
result, the data record cannot be read or written.
Possible causes:
No hardware connection to the PLC (no cable
plugged in, cable is defect), or the PLC is
switched off.
Check the connection to the PLC.
290030 This alarm is output after you selected screen
which contains a recipe view in which a data
record is already selected.
Reload the data record from the storage location, or
retain the current values.
290031 While saving, it was detected that a data record
with the specified number already exists.
Overwrite the data record, or cancel the action.
290032 During the export of data records, a file with the
specified name was found.
Overwrite the file, or cancel the process.
290033 Confirmation prompt before deleting data
records.
--
290040 A data record error with error code %1 that
cannot be described in more detail occurred.
The action is canceled.
It is possible that the mailbox was not installed
correctly on the PLC.
Check the storage location, the data record, the "Data
record" area pointer, and the connection to the PLC.
Restart the action after a short waiting time.
If the error persists, contact Customer Support.
Forward the relevant error code to Customer Support.
290041 A data record or file cannot be saved because
the storage location is out of sufficient space.
Delete files no longer required.
290042 An attempt was made to execute several recipe
actions simultaneously. The last action is not
executed.
Retrigger the action after a short waiting time.
290043 Confirmation prompt before saving data records. --
290044 The database for the recipe was corrupted and
will be deleted.
--
290050 A check back indicates that the export of data
records was started.
--
290051 A check back indicates successful completion of
the export of data records.
--
290052 A check back indicates that the export of data
records was canceled due to an error.
Ensure that the structure of the data records at the
storage location and the current recipe structure on
the HMI device are identical.
290053 A check back indicates that the import of records
was started.
--
290054 A check back indicates successful completion of
the import of data records.
--
Visualizing processes (Basic)
10.3 Working with alarms
STEP 7 Basic V12.0
2790 System Manual, 01/2013,
Number Effect/causes Remedy
290055 A check back indicates that the import of data
records was canceled due to an error.
Ensure that the structure of the data records at the
storage location and the current recipe structure on
the HMI device are identical.
290056 Error when reading/writing the value in the
specified row/column.
The action was canceled.
Check the specified row/column.
290057 The tags of the recipe specified were toggled
from "offline" to "online" mode.
Each change of a tag in this recipe is now
immediately transferred to the PLC.
--
290058 The tags of the specified recipe were toggled
from "online" to "offline" mode.
Modifications to tags in this recipe are no longer
immediately transferred to the PLC but must be
transferred there explicitly by downloading a
data record.
--
290059 A check back indicates that the specified record
was successfully saved.
--
290060 A check back indicates that the specified data
record memory was cleared.
--
290061 A check back indicates that deletion of the data
record memory was canceled due to an error.
--
290062 The data record number exceeds the maximum
of 65536.
This data record cannot be created.
Select another number.
290063 This occurs when you execute system function
"ExportDataRecords" while the "Overwrite"
parameter is set to "No".
An attempt was made to save a recipe under a
file name that already exists.
The export is canceled.
Check the parameters of the "ExportDataRecords"
system function.
290064 A check back indicates that the deletion of data
records was started.
--
290065 A check back indicates successful completion of
the deletion of data records.
--
290066 Confirmation prompt before deleting data
records.
--
290068 Confirmation prompt for deletion of all recipe
data records.
--
290069 Confirmation prompt for deletion of all recipe
data records.
--
290070 The data record specified was not found in the
import file.
Check the source of the data record number, or the
data record name (constant, or tag value).
290071 When the editing data record values, you
entered a value that is below the low limit of the
recipe tag.
The entry is discarded.
Enter a value within the recipe tag limits.
290072 When editing data record values, you entered a
value that exceeds the high limit of the recipe tag.
The entry is discarded.
Enter a value within the recipe tag limits.
Visualizing processes (Basic)
10.3 Working with alarms
STEP 7 Basic V12.0
System Manual, 01/2013, 2791
Number Effect/causes Remedy
290073 An action (e.g. saving a record) failed for an
unknown reason.
The error corresponds to status alarm
IDS_OUT_CMD_EXE_ERR in the large recipe
view.
--
290074 While saving, a data record with the specified
number but with different name was found.
Overwrite the record, change the record number or
cancel the action.
290075 A data record of this name already exists.
The data record is not saved.
Select a different data record name.
290110 The default values could not be set due to an
error.
--
290111 The recipes subsystem cannot be used. Recipe
views have no content and recipe-specific
functions will not be executed.
Possible causes:
Error when loading the recipes.
The recipe structure was changed in the ES.
The recipes were not included in the latest
project download. This means that the new
configuration data no longer matches the old
recipes on the device.
Download the project to the device again, including
the recipes (the corresponding check box in the
download dialog must be check marked).
Visualizing processes (Basic)
10.3 Working with alarms
STEP 7 Basic V12.0
2792 System Manual, 01/2013,
10.4 Working with recipes
10.4.1 Basics
10.4.1.1 Definition and applications
Introduction
Related data, e.g. machine parameter assignments or production data, are combined in
recipes.
Examples:
Machine parameter settings that are needed to convert production to a different product
variant.
Product components that result in different compositions for different end products.
A recipe has a fixed data structure. The structure of a recipe is defined in the configuration. A
recipe contains recipe data records. These differ in terms of their values, but not their structure.
Recipes are saved on the HMI device. A recipe data record is always transferred completely
and in a single pass between the HMI device and the PLC.
Note
Restrictions in the import/export
It is not possible to export or import the recipes for Basic Panels.
Complete recipe data but not individual recipe data records can be exported and imported
with ProSave to the CSV format and transmitted to the HMI device. Runtime is stopped in
the meantime.
Using recipes
Recipes can be used in the following situations:
Manual production
You select the required recipe data and display it on the HMI device. You modify the recipe
data as required and save it on the HMI device. You transfer the recipe data to the PLC.
Automatic production
The control program starts transfer of the recipe data between the PLC and HMI device.
You can also start the transfer from the HMI device. Production is then implemented
automatically. It is not essential to display or modify the data.
Teach-in mode
You optimize production data that was optimized manually on the system, e.g. axis positions
or filling volumes. The values thus determined are transferred to the HMI device and saved
in a recipe data record. You can then transfer the saved recipe data back to the PLC at a
later date.
Visualizing processes (Basic)
10.4 Working with recipes
STEP 7 Basic V12.0
System Manual, 01/2013, 2793
Entering and modifying the recipe data
You enter the data in the individual recipe data records and modify it as required. The following
options are available:
Data entry during configuration
If the production data exists already, you enter the data in the "Recipes" editor during recipe
configuration.
Entering the data in Runtime
If you have to frequently modify production data, you can do this directly in Runtime as
follows:
Enter the data directly on the HMI device.
Set the parameters directly on the machine. You then transfer the data from the PLC to
the HMI device and save it in the recipe.
10.4.1.2 Examples for using recipes
Recipes are used in the manufacturing industry and mechanical engineering, for example. The
following recipes show typical applications which you can implement with the recipe function
of WinCC:
Machine parameter assignment
One field of application for recipes is the assignment of machine parameters in the
manufacturing industry: A machine cuts wooden boards to a certain size and drills holes.
The guide rails and drill have to be moved to new positions according to the board size.
The required position data are stored as data records in a recipe. You reassign the machine
parameters using "Teach in" mode if, for example, a new board size is to be processed.
You transfer the new position data directly from the PLC to the HMI device and save it as
a new data record.
Batch production
Batch production in the food processing industry represents another field of application for
recipes: A filling station in a fruit juice plant produces juice, nectar, and fruit drinks in a
variety of flavors. The ingredients are always the same, differing only in their mixing ratios.
Each flavor corresponds to a recipe. Each mixing ratio corresponds to a data record. All of
the required data for a mixing ratio can be transferred to the machine control at the touch
of a button.
10.4.1.3 Structure of recipes
Introduction
The basic structure of a recipe is illustrated with reference to the filling station in a fruit juice
plant.
There may be several different recipes in an HMI device. A recipe can be compared to an
index card box that contains several index cards. The index card box contains several variants
for manufacturing a product family. All the data for each manufacturing variant is contained on
a single index card.
Example:
Visualizing processes (Basic)
10.4 Working with recipes
STEP 7 Basic V12.0
2794 System Manual, 01/2013,
In a soft drinks production plant, a recipe is needed for different flavors. Drink variants include
fruit juice drink, juice and nectar.
Recipe
The recipe contains all the recipe data records for the different drink variants.
5
30
23
80
15
35
20
70
Juice
Recipe
Water:
Flavor:
Sugar:
Concentrate:
Water:
Sugar:
Flavor:
Concentrate:
Nectar
Recipe data record
Recipe element
Recipe data records
Each index card represents a recipe data record needed to manufacture a product variant.
Recipe entries
Each index card in a drawer has the same structure. All the index cards contain fields for the
different ingredients. Each field corresponds to a recipe entry. All the records of a recipe thus
contain the same entries. The records differ, however, in the value of the individual entries.
Example:
All the drinks contain the following ingredients:
Water
Concentrate
Sugar
Flavoring
The records for juice drink, fruit juice or nectar differ, however, in the quantity of sugar used
in production.
Visualizing processes (Basic)
10.4 Working with recipes
STEP 7 Basic V12.0
System Manual, 01/2013, 2795
10.4.1.4 Displaying recipes
Introduction
You need to configure the recipe view to display recipes. You can change the values of a recipe
in the recipe view and thereby influence the manufacturing process or a machine.
Recipe view
The recipe view is an off-the-shelf WinCC display and operator control for managing recipe
data records. The recipe view is always part of a screen. The recipe view shows recipe data
records in tabular form. You adapt the appearance and the possible operations to suit your
specific needs.
Beverage
Juice
Nectar
1
2
3
If you are editing recipes with a recipe view in your project, the values are saved in recipe data
records. The values are not transferred between the HMI device and PLC until you use the
relevant operator control.
10.4.1.5 Flow of data for recipes
Interaction between the components
There is interaction between the following components at runtime:
Recipe view
Recipes are displayed and edited in the recipe view on the HMI device.
The recipe data records from the internal memory of the HMI device are displayed and
edited in the recipe view.
HMI device recipe memory
Recipes are saved in the form of recipe data records in the HMI device's recipe memory.
Recipe tags
The recipe tags contain recipe data.
Visualizing processes (Basic)
10.4 Working with recipes
STEP 7 Basic V12.0
2796 System Manual, 01/2013,
Overview of the flow of data
The following figure illustrates the flow of data in recipes:
PLC
Recipe 1
Recipe 2
Recipe 3
Recipe n
Recipe memory HMl device
Recipe view
Recipe tag
To transfer recipe data records to the PLC, use the "To PLC" button in the recipe view or an
operator control with the system function "RecipeViewSetDataRecordToPLC".
Data are exchanged with the PLC by recipe tags. On Basic Panels you cannot use recipe tags
outside a recipe, e.g. not in I/O fields.
10.4.1.6 Synchronization of recipe data records with the PLC
Overview
When recipe data records are transferred between the HMI device and PLC, both
communication peers access common communication areas on the other peer.
Recipe data records are always transferred directly. The values of the tags are written directly
to or read directly from the configured addresses without being placed on the clipboard.
Visualizing processes (Basic)
10.4 Working with recipes
STEP 7 Basic V12.0
System Manual, 01/2013, 2797
Data transfer types
There are two ways to transfer recipe data records between the HMI device and PLC:
Transfer without coordination
Coordinated transfer via the "Data record" area pointer.
Note
Coordinated transfer
Transfer with coordinated transfer is used to prevent the uncontrolled overwriting of data
in either direction in your control program.
Requirements for coordinated transfer
The following requirements apply to coordinated transfer:
The "Data record" area pointer must be set up for the required connection in the
"Communication > Connections" editor.
In the properties of the recipe "Coordinated transfer of data records" is activated.
The connection to the PLC is specified in the properties of the recipe with which the HMI
device coordinates the transfer.
Coordinated transfer
In the case of coordinated transfer, both the PLC and the HMI device set the status bits in the
shared data compartment.
Coordinated transfer of recipe data records can be a useful solution in the following cases:
The PLC is the "active partner" for the transfer of recipe data records.
The PLC evaluates information about the recipe number and name, as well as the recipe
data record number and name.
The transfer of recipe data records is started by the following PLC jobs:
"Set_data_record_in_PLC"
"Get_data_record_from_PLC"
10.4.2 Elements and basic settings
10.4.2.1 "Recipes" editor
Introduction
You can create, configure and edit recipes, recipe entries and recipe data records in the
"Recipes" editor. The "Recipes" editor also allows you to enter values in recipe data records.
Visualizing processes (Basic)
10.4 Working with recipes
STEP 7 Basic V12.0
2798 System Manual, 01/2013,
Structure of the "Recipes" editor
You create recipes in the top part of the table editor. You can also configure them there or in
the Inspector window.
The bottom part of the table editor has the following tabs:
Elements
Define the recipe elements of the selected recipe using the table cells provided here. You
can move recipe elements within the table with the shortcut menu commands, "Up" and
"Down".
Data records
Define the values of the data records of the selected recipe using the table cells provided
here.
You can then configure the selected recipe, the recipe element or the recipe data record in the
Inspector window. You will find further notes on configuring the components of a recipe under
"Configuring Recipes".
Recipe settings
The following settings are available for recipes:
Setting Description
Name of the recipe This is a unique identification for the recipe within the HMI device.
Display name Appears in the recipe view, for example, in Runtime. You can configure
display names in multiple languages. Assign descriptive names or
designations which the operator can associate directly with a recipe, e.g. "fruit
juice drink".
Recipe number This is a unique identification for the recipe within the HMI device.
Version Information about the recipe. The date and time of the last change to the
recipe is set by default.
Path Defines the storage location for recipes. The recipes are stored as a file.
Size type [fixed] The recipe data records are limited to a predetermined number by default.
Number of data
records [fixed]
Maximum number of data records in a recipe in Runtime. The number is
limited by the recipe memory of the HMI device.
Visualizing processes (Basic)
10.4 Working with recipes
STEP 7 Basic V12.0
System Manual, 01/2013, 2799
Setting Description
Communication type
[fixed]
The recipe data records are written directly to the addresses of the recipe
tags and read from there.
Tooltip Tooltip for the recipe which is shown to the operator in Runtime.
Note
Path
The storage location depends on the storage media available on the HMI device.
Basic Panels and OP77A, TP177A (Portrait)
These HMI devices have no external memory. Recipes are always saved in the internal Flash
memory. The "Path" setting is therefore not available.
Recipe element settings
You can make the following settings on the "Elements" tab:
Setting Description
Name of the recipe element Identifies a recipe element uniquely within the recipe. Enter meaningful
names or labels that you can allocate uniquely, such as axis labels on
a machine or ingredients such as "Flavoring".
Display name Appears in the recipe view, for example, in Runtime. You can configure
display names in multiple languages. Assign meaningful names or
designations which the operator can associate directly, e.g. "fruit juice
flavoring".
Recipe tag An assigned tag in Runtime stores the current value of the recipe
element in the recipe data record.
Data type Data type of the recipe tag.
Data length [fixed] Data length of the recipe tag, depending on the data type.
Text list Text is assigned to a value or range of values in a text list. You can
display this text in an output field, for example.
The assigned recipe tag must have the data type of a number. The tag
value must be within the range of values of the text list.
Default value This is used as the default entry when you create a new recipe data
record.
Minimum value [fixed] The smallest representable value of a number-based recipe tag,
depending on the type of data.
Maximum value [fixed] The largest representable value of a number-based recipe tag,
depending on the type of data.
Decimal places Determines how many places a decimal number is rounded to, e.g. 3
decimal places and vice versa by what power of ten an integer value
is multiplied, e.g. 1,000.
Tooltip Tooltip about the recipe element which is shown to the operator in
Runtime.
Visualizing processes (Basic)
10.4 Working with recipes
STEP 7 Basic V12.0
2800 System Manual, 01/2013,
Recipe data record settings
You can make the following settings on the "Data records" tab:
Setting Description
Name of the recipe data
record
Identifies a recipe data record uniquely within the recipe.
Display name Appears in the recipe view, for example, in Runtime. You can configure
display names in multiple languages. Assign meaningful names or
product numbers which the operator can associate directly with a
product, e.g. "yellow fruit juice E231".
Recipe data record number Identifies a recipe data record uniquely within the recipe.
Recipe elements 1 to n You can store various values for each recipe element even during
configuration. Together with the values of the other recipe elements, a
value always forms a recipe data record. You can store multiple recipe
data records.
If enabled in the transfer settings, the recipe data records are
transferred to the HMI device when downloading the project and
existing data records on the HMI device are overwritten.
Comment Comment about the recipe data record
10.4.3 Displaying and editing recipes in Runtime
10.4.3.1 Simple recipe view
Recipe view
The simple recipe view is a ready-made display element and operator control that is used to
manage recipe data records. The recipe view shows recipe data records in tabular form.
The displayed buttons and information in the columns are adjustable.
The values displayed or entered in the recipe view are saved in recipe data records. The
displayed recipe data record can be written into the PLC by buttons or values can be read in
from the PLC.
Layout of the display
The simple recipe view consists of three areas:
Recipe list
Data record list
Element list
In the simple recipe view, each area is shown separately on the HMI device. Depending on
the configuration, the simple recipe view starts with the recipe list.
The figure below shows an example of the data record list.
Visualizing processes (Basic)
10.4 Working with recipes
STEP 7 Basic V12.0
System Manual, 01/2013, 2801
Beverage
Juice
Nectar
1
2
3
Display of values
Note
Processed recipe data record is changed in the background
Only applies for Basic Panels: if an operator has changed a recipe data record and a PLC
job wants to read or write any recipe data record of this recipe, the PLC job is stopped and
a system alarm is output. On the other hand, the changed value is displayed immediately if
only the PLC job and no operator has changed recipe data.
Does not apply for Basic Panels: If an operator has changed a recipe data record and a PLC
job has changed the values of the recipe data record concerned, the recipe view is not
updated automatically. To update the recipe view, reselect the respective recipe data record.
See also
Recipe view (Page 2681)
10.4.3.2 Behavior of the recipe view in Runtime
Screen change
If you change to another screen and have not yet saved changes to the recipe data in the
recipe view, you will be prompted to save the recipe data. The recipe name and the name of
the recipe data record are displayed to show which recipe data have not been saved yet.
Create, change, copy or delete recipe data records
If you attempt to create a new recipe data record and a recipe data record already exists, a
system alarm will appear on screen.
Operating the recipe view with function keys
The Recipe view can be operated with function keys, e.g. if the HMI device does not have
touch functionality. You can assign functions such as "SaveDataRecord" to the function keys
on the HMI device.
Visualizing processes (Basic)
10.4 Working with recipes
STEP 7 Basic V12.0
2802 System Manual, 01/2013,
Display after import of recipe data
Note
Availability
Import and export of recipe data is not available for Basic Panels and OP77A, TP177A
(Portrait).
If you open the recipe view during the import of recipe data, only the recipe data that is already
completely imported will be displayed. The recipe view is not automatically updated with a data
import. In order to have a complete view of all the recipe data, do not open the recipe view
until the system prompts you that the recipe data has been imported successfully. Alternatively,
update the recipe view after successful completion of the import procedure.
Updating tag for recipes and recipe data records
Note
Availability
Tags for recipes and recipe data records are not available for Basic Panels and OP77A,
TP177A (Portrait).
The current recipe data record or its number can be saved to a tag, depending on the
configuration. The tag will be updated under the following conditions:
The recipe data record has been loaded.
The screen with the recipe view was not exited during loading.
This operation may take some time.
10.4.4 Configuring recipes
10.4.4.1 General configuration procedure
Carry out the following configuration steps when you create a new recipe:
Step Description
1 Define the structure of the recipe.
2 Create tags according to the recipe structure.
Assign process names to these tags.
3 Create the recipe.
Visualizing processes (Basic)
10.4 Working with recipes
STEP 7 Basic V12.0
System Manual, 01/2013, 2803
Step Description
4 Enter the required properties for the recipe:
Language-dependent view name of the recipe
"Coordinated transfer of data records" option
Not for Basic Panels:
Recipe storage location
"Synchronize recipe view and recipe tags" option
"Manual transfer of individual modified values (teach-in mode)" option
5 Create the recipe elements and enter the required properties:
Language-dependent view name of the recipe elements
Tag binding of the recipe elements
Standard values and decimal places (power of ten) for the recipe elements
6 Create the recipe data records.
Enter the language-specific display names for the recipe data records.
7 Configure a screen with recipe view or a recipe screen.
Note
Basic Panels and OP77A, TP177A (Portrait)
The selection of the storage location is not available for these devices. The recipes are always
saved in the internal Flash memory.
Recipe tags cannot be used outside a recipe, e.g. not in I/O fields, not in alarms as trigger
tags, not in systems functions as parameters, etc.
Note
Restrictions recipe view and recipe image
Only the simple recipe view is available in Basic Panels and OP77A, TP177A. Recipe images
are not available in Basic Panels and OP73, OP77A, TP177A (Portrait).
10.4.4.2 Creating and Editing Recipes
Creating a new recipe
Introduction
To create a complete recipe, start by creating a new recipe, assign the corresponding recipe
elements and then define the associated values in a recipe data record.
Requirement
The tags for the recipe have been created.
The "Recipes" editor is open.
Visualizing processes (Basic)
10.4 Working with recipes
STEP 7 Basic V12.0
2804 System Manual, 01/2013,
Create recipe
Create a recipe as follows:
1. Click "Add" in the first free row of the table in the "Recipes" editor.
The new recipe is created and displayed on a line.
2. Enter a descriptive name for the recipe under "Name" in the "General" area.
This name identifies the recipe unambiguously within the project.
3. Select "Display name" to enter the language-specific name to be displayed in runtime.
4. Select a recipe number in "Number".
The number identifies the recipe unambiguously within the HMI device.
The recipe is automatically assigned a version that indicates the date and time of the last
change. As an alternative, you can enter specific information relating to the recipe.
5. Specify the storage location for recipe data records in "Data medium". The options offered
depend on the specific HMI device used.
Note
Basic Panels and OP77A, TP177A (Portrait)
The selection of the storage location is not available for these devices. The recipes are
always saved in the internal Flash memory.
Recipe tags cannot be used outside a recipe, e.g. not in I/O fields, not in alarms as trigger
tags, not in systems functions as parameters, etc.
6. Enter a tooltip that is shown to the operator in runtime.
Visualizing processes (Basic)
10.4 Working with recipes
STEP 7 Basic V12.0
System Manual, 01/2013, 2805
7. To compare recipe tags which are configured in I/O fields with the recipe view in Runtime,
activate "Synchronize recipe view and recipe tags" in the Inspector window under
"Properties > Synchronization".
Note
Basic Panels and OP77A, TP177A (Portrait)
Because the recipe tags cannot be additionally used in I/O fields in screens for Basic
Panels, the "Synchronize recipe view and recipe tags" is not available; you will also not
be able to use the "Manual transfer of individual modified values (teach-in mode)" option.
8. Deactivate "Manual transfer of individual modified values (teach-in mode)" to specify that
the recipe tags are automatically transferred to the PLC when editing the I/O fields.
9. Activate "Coordinated transfer of data records" to monitor the transfer of recipe data in
Runtime using area pointers.
10.Select the appropriate connection to the PLC for coordinated transfer under "Synchronize
with".
Create recipe element
To create recipe elements, proceed as follows:
1. Click the "Elements" tab.
2. Click "Add" in the first free line of the table editor.
A new recipe element is created.
3. Enter a descriptive name for the element under "Name".
The name identifies the element uniquely within the recipe.
4. Enter a language-specific display name for the element under "Display name".
The display name appears in the recipe view, for example, in runtime.
Visualizing processes (Basic)
10.4 Working with recipes
STEP 7 Basic V12.0
2806 System Manual, 01/2013,
5. Select the tag you want to link to the recipe element under "Tag".
The value of the recipe data element is saved in Runtime in this tag, which is stored in a
recipe data record.
6. Enter a tooltip.
The tooltip is shown to the operator in Runtime.
7. Under "Default value", enter the value that you want to use as the default entry when you
create a new recipe data record.
8. To assign text to a value or range of values, select the relevant text list here. The assigned
recipe tag must have the data type of a number. The tag value must be within the range of
values of the text list.
The text stored in the text list is displayed in an output field, for example, in Runtime.
9. Determine exactly how many places a decimal number is rounded to in the "Decimal places"
column, e.g. 3 decimal places and vice versa by what power of ten an integer value is
multiplied, e.g. 1,000.
Examples for 3 decimal places: Entering "5" for a recipe element with the "Integer" data
type gives the value "5000". Entering "5.6789" for a recipe element with the "Real" data
type gives the value "5.679".
10.Create as many recipe entries as needed for the recipe. The maximum number of recipe
entries possible depends on the HMI device being used.
Visualizing processes (Basic)
10.4 Working with recipes
STEP 7 Basic V12.0
System Manual, 01/2013, 2807
Create recipe data record with known recipe values
To create recipe elements, proceed as follows:
1. Click the "Data records" tab.
2. Click "Add" in the first free line of the table editor.
A new recipe data record is created. The recipe data record has a separate column for
every recipe element created in the recipe.
3. Enter a descriptive name under "Name".
The name identifies the data record uniquely within the recipe.
4. Enter a language-specific name under "Display name".
The display name appears in the recipe view, for example, in runtime.
5. Enter a recipe data record number under "Number".
The recipe data record number identifies the recipe data record uniquely within the recipe.
6. If you already know the recipe values at the configuration stage, you can enter the relevant
value for each recipe element.
7. Create as many data records as you need for the recipe.
Visualizing processes (Basic)
10.4 Working with recipes
STEP 7 Basic V12.0
2808 System Manual, 01/2013,
Enter the values in runtime
The following options are available for entering values in the recipe data records at runtime:
Transfer data directly from the PLC (Teach-in mode)
Import of values from a CSV file
Input values on the HMI device
Note
Basic Panels and OP77A, TP177A (Portrait)
The import of values is not available for these devices.
Result
The complete recipe is configured.
Recipe data records with date or time stamp
If you use date or time data, make sure that the system setting for time and date on the
configuring computer match those on the target system. Example: You load a recipe data
record on the target system at 13:55 in which 14 h is stored as the processing time. If it is
already 14:05 on the target computer, the recipe will not be processed. If an operator processes
the recipe, change information will not written back correctly into the database.
After loading to the target system, check the recipes with date or time stamps on the target
system.
Editing a recipe
Purpose
You want to modify, extend or delete parts of a recipe.
Requirement
You have created at least one recipe.
The "Recipes" editor is open.
Changing recipe settings
To change the recipe settings, proceed as follows:
1. Select the recipe that you want to change in the "Recipes" editor.
The Inspector window opens.
2. Change the recipe configuration in the Inspector window.
You change recipe elements and recipe data records in the same way.
Visualizing processes (Basic)
10.4 Working with recipes
STEP 7 Basic V12.0
System Manual, 01/2013, 2809
Change recipe values
To change recipe values, proceed as follows:
1. Select the recipe whose values you want to change.
2. Click the "Data records" tab.
3. Enter the new values in the value columns.
Adding a recipe element
To add more recipe elements to a recipe, proceed as follows:
1. Select the recipe to which you want to add more elements in the "Recipes" editor.
2. Click the "Elements" tab.
3. Click "Add" in the first free line.
The recipe element is created.
4. Configure the recipe element.
You add recipe data records in the same way.
Managing recipes
Requirement
You have created a recipe with recipe elements and recipe data record.
The "Recipes" editor is open.
Renaming recipes
We distinguish between internal names and display names for recipes, recipe entries and
recipe data records.
To rename recipe elements, proceed as follows:
1. Select the recipe that you want to rename.
The Inspector window opens.
2. Select the "Rename" command from the shortcut menu.
3. Enter the new name.
You rename recipe elements and recipe data records on the relevant tab in the same way.
Note
The view names in the "Recipes" editor can also be renamed under "Languages &
Resources > Project Texts". This possibility is useful when you have already configured
in several languages for example.
Visualizing processes (Basic)
10.4 Working with recipes
STEP 7 Basic V12.0
2810 System Manual, 01/2013,
Copying and pasting recipes
To copy and paste recipes, proceed as follows:
1. Select the recipe that you want to copy.
2. Select the "Copy" command from the shortcut menu.
3. Select the "Paste" command from the shortcut menu in the first free table row.
The copied recipe is pasted into the table. The recipe elements and recipe data records are
also copied in the appropriate tab with the recipe.
You also copy the recipe elements and recipe data records on the appropriate tab in the same
way.
If a recipe data record of the same name already exists, the name of the copied recipe data
record is extended by one digit. This ensures that the name is unique. Recipe data records
can only be copied or pasted within the same recipe.
Deleting a recipe
To delete a recipe, proceed as follows:
1. Select the recipe that you want to delete.
2. Select the "Delete" command from the shortcut menu.
The recipe is deleted.
You delete recipe elements and recipe data records on the relevant tab in the same way.
Note
When a recipe is deleted, the recipe data records contained in the recipe are also deleted.
Note
When you delete a recipe element, the associated values in the recipe data records are also
deleted. The assigned tags are retained.
Visualizing processes (Basic)
10.4 Working with recipes
STEP 7 Basic V12.0
System Manual, 01/2013, 2811
10.4.4.3 Configuring the display of recipes
Configuring the simple recipe view
Requirement
The recipe has been created.
The "Screens" editor is open.
The screen has been created and opened.
NOTICE
Data loss with several recipe views in the screen
Applies only to Basic Panels, OP73, OP77A, TP177A and TP177A (Portrait): If two or
more recipe views show the same recipe in a screen, you have a conflict when accessing
the data.
The result is data loss and unpredictable status of recipe data.
Make sure the operators do not select and edit the same recipe in different recipe views.
Display only one recipe in a recipe view.
Display a different recipe in each recipe view.
Procedure
To configure a simple recipe view, proceed as follows:
1. Paste the recipe view into the screen. You will find the recipe view under "Controls" in the
"Tools" task card.
2. Only in devices which also support the extended recipe view: Activate "Simple view" under
"Properties > Display > Mode".
Visualizing processes (Basic)
10.4 Working with recipes
STEP 7 Basic V12.0
2812 System Manual, 01/2013,
3. If you want to display only the recipe data records of a specific recipe in the recipe view,
select the specific recipe under "Properties > General > Recipe".
4. If you only want to display the recipe data in the recipe view, deactivate "Processing mode"
in the "Recipe data record" area.
5. You can define additional options for the recipe view under "Properties > Appearance" and
"Properties > Layout".
Visualizing processes (Basic)
10.4 Working with recipes
STEP 7 Basic V12.0
System Manual, 01/2013, 2813
6. Select "Properties > Simple view" to select the position, the field length, and the number of
lines required.
Select "Position > Top" to display the recipe value in the first line of the recipe entry.
Select "Position > Bottom" to display the recipe value in the last line of the recipe entry.
7. Under "Properties" > Toolbar" specify which menu commands are available in the recipe
view in Runtime.
Result
The simple recipe view is configured. You can use the recipe view to display and edit recipe
data during runtime.
Deactivation of the editing mode in "Properties > Properties > General" has no impact on the
toolbar icons. The buttons you activated in "Properties > Toolbar" can still be used even if
editing mode is disabled.
Visualizing processes (Basic)
10.4 Working with recipes
STEP 7 Basic V12.0
2814 System Manual, 01/2013,
10.4.5 Using recipes in Runtime
10.4.5.1 Using the simple recipe view
Description of the simple recipe view
Layout
The simple recipe view consists of the following display areas:
Recipe list
Data record list
Element list
This application is illustrated below:
Beverage
Juice
Nectar
1
2
3
In the simple recipe view, each area is shown separately on the HMI device. You can use the
shortcut menu to operate each of these display areas.
The simple recipe view always begins with the recipe list.
Operation
You have the following options for using the simple recipe view, according to the configuration:
Create, change, copy or delete recipe data records
Read recipe data records from the PLC or transfer to the PLC
Using the display area and shortcut menu
Toggle between the display areas and the shortcut menus to operate the simple recipe views.
The table below shows the operation of the display area.
Button Key Function
<Enter> The next lowest display area is opened, i.e. the data record
list or the element list.
<Esc> The previous display area opens.
Visualizing processes (Basic)
10.4 Working with recipes
STEP 7 Basic V12.0
System Manual, 01/2013, 2815
Button Key Function
<INS> Creates a new data record for the selected recipe if the list
of recipes or recipe data records is displayed. Then changes
to the list of recipe element.
Requirement: "Properties >General > Processing mode" is
activated.
The button can be simulated with the "Key
SimulateSystemKey" function even on devices without keys.
<DEL> Deletes the selected recipe data record in the list of recipe
data records.
Requirement: "Properties >General > Processing mode" is
activated.
<Up>/<Down> Selects the previous/next entry.
<Pg Up>/<Pg Down> Moves the display up or down one page.
<Home>/<End> Selects the first/last entry. The first/last entry is selected.
The table below shows the operation of the shortcut menu:
Button Key Function
<Right> The shortcut menu of the display area opens.
<Esc> The menu is closed.
The display area opens.
Input of the number of
the menu command
The menu command is executed.
Shortcut menus of the simple recipe view
You can click the button in each display area to call up a selection of commands. The
command selection lists those commands that are available in the current display area. A
number is assigned to each command. The command is executed when you enter this number.
Alternatively select the command and press the <Return> key.
Shortcut menus in the recipe list
Menu command Function
New A new recipe data record is created for the selected recipe.
If a start value is configured, it is displayed in the input field.
Display tooltip The tooltip configured for the recipe is displayed.
Open The record list of the selected recipe opens.
Visualizing processes (Basic)
10.4 Working with recipes
STEP 7 Basic V12.0
2816 System Manual, 01/2013,
Shortcut menus of the recipe data record list
Menu command Function
New Creates a new recipe data record.
If a start value is configured, it is displayed in the input field.
Deleting The displayed record is deleted.
Save as The selected data record is saved under a different name. A dialog box opens
where you can enter the name.
Rename Renames the selected data record. A dialog box opens where you can enter
the name.
Open The element list of the selected data record opens.
Previous The recipe list opens.
Shortcut menus of the recipe element list
Menu command Function
Save The selected data record with the recipe element is saved.
To PLC The displayed values of the selected data record are transferred from the
HMI device to the PLC.
From PLC The recipe values from the PLC are displayed in the recipe view of the HMI
device.
Save as The data record is saved under a new name. A dialog box opens where you
can enter the name.
Display tooltip The tooltip configured for the recipe element is displayed.
Rename The selected recipe element is renamed. A dialog box opens where you can
enter the name.
Previous The data record list opens.
Shortcut menus in the data record list
Note
HMI device dependency
The following menu commands are configured in Basic Panels and in OP 77A, TP 177A,
TP 177A (Portrait) and TB 177B.
Menu command Function
To PLC The displayed values of the selected data record are transferred from the
HMI device to the PLC.
From PLC The recipe values from the PLC are displayed in the recipe view of the HMI
device.
Visualizing processes (Basic)
10.4 Working with recipes
STEP 7 Basic V12.0
System Manual, 01/2013, 2817
Managing recipe data records
Recipe data record administration
You have the following options for managing the simple recipe view, according to the
configuration:
Creating new recipe data records
Copy recipe data records
Edit recipe data records
Delete recipe data records
Creating new recipe data records
To create a new recipe data record, proceed as follows:
1. Select the recipe on the HMI device in which you want to create a new recipe data record.
2. Select the "New" command from the shortcut menu for the recipe list.
A new data record with the next available number will be created.
The element list of the new recipe data record opens.
3. Enter values for the elements of the recipe data record.
The configuration data may already contain default values for the recipe data record.
4. Select the "Save" command from the shortcut menu for the element list.
The dialog "Save as" opens.
5. Enter the name and number of the recipe data record.
6. Click the "OK" button.
Result
The new recipe data records will be saved to the selected recipe. If the recipe data records
already exists, a system event will be output to the screen.
Copying a recipe data record
To copy a recipe data record, proceed as follows:
1. Select the recipe on the HMI device in which you want to copy an existing recipe data record.
2. On the HMI device, select the recipe data record of which you want to save a copy.
3. Select the "Save As" command from the shortcut menu for the data record list.
The dialog "Save as" opens. The recipe data record is automatically given the next free
recipe data record number.
4. Under name, enter the name of the record.
5. Click the "OK" button.
Visualizing processes (Basic)
10.4 Working with recipes
STEP 7 Basic V12.0
2818 System Manual, 01/2013,
Result
The recipe data record is stored under the new name.
Modify recipe data record
To change a recipe data record, proceed as follows:
1. Select the recipe on the HMI device in which you want to edit an existing recipe data record.
2. Select the recipe data record that you want to edit on the HMI device.
3. Select the recipe data record.
The element list of the recipe data record is displayed.
4. Replace the old values with new ones.
5. Select the "Save" command from the shortcut menu for the element list.
Result
The modified values are applied to the recipe data record.
Deleting a recipe data record
To delete a recipe data record, proceed as follows:
1. Select the recipe on the HMI device from which you want to delete an existing recipe data
record.
2. Select the recipe data record that you want to delete on the HMI device.
3. Select the "Delete" command from the shortcut menu for the data record list.
4. Confirm this security prompt to delete the data record.
Result
The recipe data record is deleted.
Read recipe data record from PLC
Introduction
In Runtime, you can change values directly in the plant that are also stored in recipes in the
HMI device. This applies if a valve was opened further directly in the plant than was specified
in the recipe. The values of the recipe data records saved in the HMI device possibly no longer
match the values in the PLC.
You can read the values of the recipe tags from the PLC and write them to a recipe data record.
The read values are written to the recipe data record that is currently displayed on the HMI
device.
Visualizing processes (Basic)
10.4 Working with recipes
STEP 7 Basic V12.0
System Manual, 01/2013, 2819
Procedure
To read a recipe data record from the PLC, proceed as follows:
1. Open the recipe on the HMI device.
The data record list opens.
2. Select the element list of the recipe data record to which you want to apply the values from
the PLC.
3. Select the "From PLC" command from the shortcut menu for the element list.
The values are read from the PLC and displayed in the current recipe data record.
4. If you want to save the values, select the "Save" or "Save As" command.
Result
The values are read from the PLC, visualized on the HMI device and saved to the recipe data
record.
Transferring a recipe data record to the PLC
Introduction
For the values of a data record that was changed in the recipe view to take effect, you must
transfer the values to the PLC.
The values displayed in the recipe view are always transferred to the PLC.
Procedure
To transfer a recipe data record to the PLC, proceed as follows:
1. Open the recipe you want to use.
The data record list opens.
2. Select the element list of the recipe data record whose values you want to transfer to the
PLC.
3. Select the "To PLC" command from the shortcut menu for the element list.
Result
The values of the recipe data record are transferred to the PLC.
Visualizing processes (Basic)
10.4 Working with recipes
STEP 7 Basic V12.0
2820 System Manual, 01/2013,
10.4.6 Example
10.4.6.1 Example of creating a recipe
Task
In this example, you create three recipes for a fruit juice mixing machine. The fruit juice mixing
machine produces drinks with "orange", "apple" and "tropical" flavors. You create a recipe for
each flavor.
Each recipe contains a recipe data record for the following mixing ratios:
Beverage
Nectar
Juice
Settings
The settings relate to an HMI device which is connected to a SIMATIC S7-300 or
SIMATIC S7-400.
In this example, you will need the following tags, recipes, recipe entries and recipe data records:
Tags:
Name PLC connection Address Type
Liter water Yes DB 120, DBW 0 Integer
Liter concentrate Yes DB 120, DBW 4 Integer
Kilo sugar Yes DB 120, DBW 8 Integer
Gram flavoring Yes DB 120, DBW 12 Integer
Recipes:
Orange
Apple
Tropical
Recipe entries:
Recipe element Associated tag
Liter water Liter water
Liter concentrate Liter concentrate
Kilo sugar Kilo sugar
Gram flavoring Gram flavoring
Recipe data records for drink, nectar and juice:
Visualizing processes (Basic)
10.4 Working with recipes
STEP 7 Basic V12.0
System Manual, 01/2013, 2821
Data record name Liter water Liter concentrate Kilo sugar Gram flavoring
Beverage 30 70 45 600
Nectar 50 50 10 300
Juice 5 95 3 100
Procedure
To create a recipe, proceed as follows:
1. Create the following tags with the settings specified above: "LiterWater", "LiterConcentrate",
"KiloSugar" and "GramFlavoring".
2. Create the "Orange", "Apple" and "Tropical" recipes with the settings indicated above.
Create the recipe entries in each recipe.
3. Not for Basic Panels: Configure each recipe so that you can synchronize the recipe data
records between the recipe screen and recipe view. The values of the recipe tags should
not be transferred automatically to the PLC.
You will have to make the following settings in the Properties dialog for the recipe concerned:
Under "Properties > Options":
Activate the "Synchronize recipe view and recipe tags" option.
Activate the "Manual transfer of individual modified values (teach-in mode)" option.
4. Create the data records indicated above in each recipe. Enter the values indicated above
in each of the data records.
Result
The "Orange", "Apple" and "Tropical" recipes have been created.
Visualizing processes (Basic)
10.4 Working with recipes
STEP 7 Basic V12.0
2822 System Manual, 01/2013,
10.5 Configuring user administration
10.5.1 Field of application of the user administration
Principle
The access protection controls access to data and functions in Runtime. This feature protects
your applications against unauthorized operation. Safety-related operations are already limited
to specific user groups when a project is being created. To this purpose you set up users and
user groups that you equip with characteristic access rights, so-called authorizations. You then
configure the authorizations required for operation of safety-related objects. Operators only
have access, for example, to specific operator controls. Commissioners, for example, have
unlimited access in Runtime.
Definition
You administer users, user groups and authorizations centrally in the user administration of
WinCC. You transfer users and user groups together with the project to the HMI device. The
users and passwords are managed on the HMI device in the User view.
Application example
You configure the "Service" authorization so that only service technicians have access to the
configuration parameters. You assign the authorization to the "Service technician" user group.
This allows all members of this group to set the protected configuration parameters.
NOTICE
Access protection does not protect against incorrect operations. It is your job to ensure that
only authorized personnel with appropriate training will design, commission, operate and
maintain plants and machines.
Access protection is not suitable for defining work routines and monitoring their observance.
10.5.2 Form of the user administration
Introduction
In case of a project in manufacturing engineering, the environment at the equipment
manufacturer has to be differentiated from the environment at the end customer as plant
operator.
The equipment manufacturer allows users, for example Mr. Foreman, a specific access within
the application or HMI device. However, a user Foreman does not exist at the end customer.
The machine manufacturer cannot know the end users and the tasks they have to perform for
configuration. The final users are usually set after commissioning at the end customer.
Visualizing processes (Basic)
10.5 Configuring user administration
STEP 7 Basic V12.0
System Manual, 01/2013, 2823
Program
WinCC Workbench
Administrator Configuration
User group
"Service Technician"
Authorizations
Miller
Smith group
Foreman
Operator
controls
Edit recipe data records
Change system parameters
Log process values
Mr. Foreman
Block
Process
values
Recipe
System
parameters
Logging
Principle
To minimize the work required for management, authorizations are assigned via user groups
and not directly to individual users.
A user group assembles configured authorizations according to common jobs. For example,
all permissions required for a service job are collected in a "Service technician" group. When
you create a user who should be responsible for servicing, you simply assign him to the
"Service technician" group.
The user view enables user administration in Runtime. Use user view to create, delete and
assign an authorization to users in Runtime.
The user administration separates the administration of the users from the configuration of the
authorizations. This ensures flexibility at the access protection.
Defaults can be set for the user administration during the configuration phase in the
Engineering System.
10.5.3 Basics
10.5.3.1 Users
Introduction
You can create users in the "Users" tab of the "User administration" editor and assign them to
user groups. The "Users" tab is part of the user administration in WinCC.
Visualizing processes (Basic)
10.5 Configuring user administration
STEP 7 Basic V12.0
2824 System Manual, 01/2013,
Open
To open the "Users" tab, double-click "User administration" in the project window.
Work area
The users are managed in the work area:
You create or delete users.
You assign users to user groups.
Note
You can assign a user to exactly one user group.
Inspector window
When you select a user, you can change the password in the "General" group. Under
"Automatic logoff" you can specify if the user is to be automatically logged off by the HMI device
when there is no operator activity after the specified time.
10.5.3.2 Users work area
Introduction
The "Users" work area lists the users and user groups in table form. You administrate the users
and assign them to a user group.
Principle
The work area consists of the "Users" and "Groups" tables.
Visualizing processes (Basic)
10.5 Configuring user administration
STEP 7 Basic V12.0
System Manual, 01/2013, 2825
The "Users" table shows the existing users. When you select a user in this table, the "Groups"
table shows the user group to which the user belongs.
Note
For the user "Administrator", the default password is "administrator". For security reasons,
you should change the password of this user.
10.5.3.3 User groups
Introduction
You can create users and authorizations in the "User groups" tab of the "User Administration"
editor. The "User groups" tab is part of the user administration in WinCC.
Open
Double-click the "User administration" in the project window. Open the "User groups" tab.
Work area
The user groups and authorizations are managed in the work area:
You create new user groups and authorizations or delete them.
You assign the authorizations to the user groups.
Inspector window
When a user group or an authorization is selected, you can edit the name in the "General"
group. You can also enter a brief description in the "Comment" group.
10.5.3.4 User groups work area
Introduction
The "User groups" work area shows a table of the groups and their authorizations. You
administer the user groups and assign authorizations to them.
Visualizing processes (Basic)
10.5 Configuring user administration
STEP 7 Basic V12.0
2826 System Manual, 01/2013,
Principle
The work area consists of the "Groups" and "Authorizations" tables.
The "Groups" table shows the existing user groups. When you select a user group in this table,
the "Active" column of the "Authorizations" table shows the authorizations which were assigned
to the user group.
The number of the user group and of the authorization is assigned by the user administration.
The designations and descriptions are assigned by you.
The number of predefined authorizations are fixed. Authorizations that you create can be freely
edited. Ensure that the assigned numbers are unique.
10.5.3.5 Settings for the user administration
Introduction
In the "Runtime settings > User administration" editor, configure the security settings for users
and their passwords in runtime.
Open
Double-click the "Runtime settings" editor in the project window. Click "User administration".
Work area
You carry out the settings for the validity of passwords in runtime in the work area. You
determine the complexity of the password, for example.
Visualizing processes (Basic)
10.5 Configuring user administration
STEP 7 Basic V12.0
System Manual, 01/2013, 2827
Effects in runtime
The security settings have the following effects in runtime, depending on the configuration.
"General" group
"Enable limit for logon attempts" check box selected
The number entered in the "Number of incorrect logon attempts" box defines the number
of logon attempts a user is allowed before being assigned to the "Unauthorized" group.
"Enable limit for logon attempts" check box not selected
The user has an unlimited number of logon attempts in runtime.
"Number of incorrect logon attempts" field
If you enter "4" in the field, for example, and the fourth logon attempt fails, the user is
automatically assigned to the "Unauthorized" group.
You can specify 1 to 9 attempts.
"Logon only with password" check box
When the check box is selected, the user will be authenticated by the password. The
user name is not required.
To match users to passwords, you cannot configure passwords more than once.
"Hierarchy level" group
"Group-specific rights for user administration" check box
When this check box is selected, administrators only manage users whose group
number is less than or equal to their own.
For example, an administrator whose group number is 5 can only manage users whose
group number is less than or equal to 5. This means that the administrator can assign
users only to groups with a group number less than or equal to 5.
Visualizing processes (Basic)
10.5 Configuring user administration
STEP 7 Basic V12.0
2828 System Manual, 01/2013,
"Password" group
"Enable password aging" checkbox selected
The password expires after the number of days set in the "Validity of the password
(days)" field.
The "Password aging" column is selected in the "User groups" editor. This enables you
to specify group-by-group, if the passwords should expire or if the password generations
should be saved. Passwords never expire for groups for which password aging is not
enabled.
"Prewarning time (days)" field
The user is informed that the password will expire the specified number of days before
the password expires.
"Password generations" field
If the user changes the password, the new password must be different from the specified
number of previous passwords. The number of password generations ranges from 1 to
5.
"Password complexity" group
"Must include special characters" check box selected
The user must enter a password containing at least one special character at any position.
"Must include number" check box selected
The user must enter a password containing at least one number at any position.
"Minimum password length" field
The user must enter a password with a minimum length, as specified in the "Minimum
password length" field.
The minimum length of the password is 3 characters.
10.5.4 Setting up the user administration
10.5.4.1 Basics on user administration
Principle
This section addresses four target groups. The topics are organized correspondingly. The
target groups serve as examples for different groups of persons who use the user
administration.
1. Administrator OEM
2. Administrator RT
3. Planners
4. Operator
As Administrator OEM you create the user groups, users and authorizations for Runtime in
the Engineering System of, for example, an equipment manufacturer.
As Administrator RT you administer users in Runtime by means of the "User view."
Visualizing processes (Basic)
10.5 Configuring user administration
STEP 7 Basic V12.0
System Manual, 01/2013, 2829
As the project engineer you assign the authorizations to the user groups in the Engineering
System. In addition, you configure the authorizations for objects.
As Operator you log on in runtime. You can only access a protected object if you have the
required authorization.
Note
The Administrator RT target group already exists in the Runtime user administration as the
predefined user group "Administrator group." For a better understanding the predefined user
groups and authorizations are not used below.
10.5.4.2 Administering users for Runtime
Creating an authorization
Introduction
You create an authorization and assign it to one or more user groups.
Requirements
The "User groups" work area is open.
Procedure
1. Double-click "Add" in the "Authorizations" table.
2. Enter "Archive data" as the name of the authorization.
3. Enter a brief description as the "Comment."
Creating a user group
Introduction
User groups are created so that you do not have to assign an authorization to every single
user. You create a user group, assign authorizations and then assign users to it.
Note
The name of the user group has to be unique within the project. Otherwise the input is not
accepted.
Visualizing processes (Basic)
10.5 Configuring user administration
STEP 7 Basic V12.0
2830 System Manual, 01/2013,
Note
Using SIMATIC Logon
Ensure that the names of the user groups in Windows and WinCC are identical.
Requirements
The "User groups" work area is open.
Procedure
1. Double-click "Add" in the "Groups" table.
2. Enter "Operators" as the "Name" of the user group.
3. Change the "Number" of the user group as required.
4. Enter "Display name" of the "Operators" user group.
5. Enter a brief description as the "Comment".
In runtime, the user view shows the display name of the user group. The display name of the
user group depends on the language. You can specify the name in several languages and
switch between languages in runtime.
See also
Assigning an authorization (Page 2831)
Creating users (Page 2832)
Assigning a user to a user group (Page 2833)
Managing user groups (Page 2835)
User administration (Page 2834)
Assigning an authorization
Introduction
When you allocate an authorization to a user group, all assigned users have this authorization.
Requirements
An "Archive data" authorization has been created.
An "Operators" user group has been created.
The "User groups" work area is open.
Visualizing processes (Basic)
10.5 Configuring user administration
STEP 7 Basic V12.0
System Manual, 01/2013, 2831
Procedure
1. Click on the "Operators" user group in the "Groups" table. The "Authorizations" table shows
all authorizations.
2. Activate the "Archive data" authorization in the "Authorizations" table.
Note
The "Archive data" authorization is only a designation and does not having any relation
to the function "Archiving." You have to establish this relation yourself. To do so, configure
the "StartArchiving" system functions at a control button and select "Archive data" as the
"Authorization."
See also
Creating a user group (Page 2830)
Creating users
Introduction
You create a user so that users can log on with their user names in runtime after loading to
the device.
As an alternative, you can create and change users by means of the "User view" in Runtime.
In order for a created user to have authorizations you have to assign him to a user group and
allocate authorizations to the user group.
The logon is successful when the user name entered during the logon matches a user in
Runtime. In addition, the entered password must agree with the stored password of the user.
Note
Note that the entry is case-sensitive.
Requirements
The "Users" work area is open.
Procedure
1. Double-click "Add" in the "Users" table.
2. Enter "Foreman" as the user name.
Note
The user name must be unique within the project. Otherwise the input is not accepted.
Visualizing processes (Basic)
10.5 Configuring user administration
STEP 7 Basic V12.0
2832 System Manual, 01/2013,
3. Click the button in the "Password" column. A dialog box for entering the password is
displayed.
4. Enter the password of the user.
5. To confirm the password enter it a second time in the lower field.
6. Close the dialog box by using the icon.
7. If a user is to be logged off after a specific time period, activate "Automatic logoff".
8. Click in the "Logoff time" column. The preset value for "Logoff time" is 5 minutes.
9. Enter a brief description as the "Comment".
See also
Creating a user group (Page 2830)
Assigning a user to a user group
Introduction
When you assign a user to a user group, the user has the authorizations of the user group.
Note
You have to assign a user to exactly one user group. The assignment is checked during the
consistency check and generation of the project.
Requirements
The user "Foreman" has been created.
An "Operators" user group has been created.
The "Users" work area is open.
Procedure
1. Click on the "Foreman" user in the "Users" table. The "Groups" table shows all user groups.
2. Activate the "Operators" user group in the "Groups" table.
See also
Creating a user group (Page 2830)
Visualizing processes (Basic)
10.5 Configuring user administration
STEP 7 Basic V12.0
System Manual, 01/2013, 2833
User administration
Introduction
In the work area, you can administer users and assign them to user groups.
Requirements
The "Users" work area is open.
Changing the user name
1. In the "Users" table, double-click the field in the "Name" column to change the user name.
2. Change the user name.
3. Confirm your entry with <Return>.
Alternatively, select the user in the work area. Change the user name under "Properties >
Properties > General" in the Inspector window.
Changing the password of the user
1. Click the button in the "Password" column of the "Users" table. A dialog for entering the
password opens.
2. In the "Enter password" field, enter the new password.
3. Reenter the new password in the "Confirm password" field.
4. Confirm your entry with <Return>.
Alternatively, select the user in the work area. Change the password under "Properties >
Properties > General" in the Inspector window.
Displaying invisible columns
1. Position the mouse cursor on the title of the "Users" table.
2. Right-click to open the shortcut menu and enable the display of the "Logoff time" column,
for example.
Changing the logoff time of the user
1. In the "Users" area, double-click on the field in the "Logoff time" column to change the logoff
time.
2. Change the logoff time.
3. Confirm your entry with <Return>.
Alternatively, select the user in the work area. Change the logoff time under "Properties >
Properties > Automatic logoff" in the Inspector window.
Visualizing processes (Basic)
10.5 Configuring user administration
STEP 7 Basic V12.0
2834 System Manual, 01/2013,
Deleting a user
1. Select the line of the user to be deleted.
2. Open the shortcut menu with the right mouse button and select the "Delete" command.
Note
Predefined users cannot be deleted.
See also
Creating a user group (Page 2830)
Managing user groups
Introduction
In the workplace you administer user groups and assign authorizations for use in runtime.
Requirements
The "User groups" work area is open.
Changing the name of the user group
1. In the "Groups" table, double-click the field in the "Name" column to change the name of
the user group.
2. Change the name of the user group.
3. Confirm your entry with <Return>.
Alternatively, select the user group in the work area. Change the name under "Properties >
Properties > General" in the Inspector window.
Note
Predefined user groups cannot be deleted.
Displaying invisible columns
1. Position the mouse cursor on the title of the "Users" table.
2. Right-click to open the shortcut menu and enable the display of the "Display name" column,
for example.
Visualizing processes (Basic)
10.5 Configuring user administration
STEP 7 Basic V12.0
System Manual, 01/2013, 2835
Changing the displayed name of the user group
1. In the "Groups" table, double-click the field in the "Display name" column to change the
display name of the user group.
2. Change the displayed name of the user group.
3. Confirm your entry with <Return>.
Alternatively, select the user group in the work area. Change the display name under
"Properties > Properties > General" in the Inspector window.
Deleting a user group
1. Mark the line of the user group to be deleted.
2. Open the shortcut menu with the right mouse button and select the "Delete" command.
Note
Predefined user groups cannot be deleted.
Changing the name of the authorization
1. In the "Authorizations" table, double-click the field in the "Name" column to change the
name of the authorization.
2. Change the name of the authorization.
3. Confirm your entry with <Return>.
Alternatively, select the authorization in the work area. Change the name under "Properties >
Properties > General" in the Inspector window.
Deleting authorizations
1. Mark the line of the authorization to be deleted.
2. Open the shortcut menu with the right mouse button and select the "Delete" command.
Note
Predefined authorizations cannot be deleted.
See also
Creating a user group (Page 2830)
Visualizing processes (Basic)
10.5 Configuring user administration
STEP 7 Basic V12.0
2836 System Manual, 01/2013,
10.5.4.3 Managing users in Runtime
Users in Runtime
Principle
You create users and user groups and assign authorizations to them. You configure objects
with authorizations. After download to the HMI device, all objects which were configured with
an authorization are protected against unauthorized access in Runtime.
User view
When you configure a user view in the Engineering System, you administer users in this user
view following download to the HMI device.
NOTICE
Changes in the user view are effective immediately in Runtime. Changes in runtime are not
updated in the engineering system. When downloading the user administration to the HMI
device, all changes in the user view are overwritten after a security prompt and based on the
settings.
Users who have a "User administration" authorization have unlimited access to the user view.
This allows them to administer all users. Any other user has only limited access to the user
view for self administration.
User view
Purpose
You configure a user view in the engineering system to also administer the users in
Runtime.
Structure
The user view shows the following in each line:
The user
The corresponding user group.
If no user is logged on, the user view is empty. The content of the individual fields is displayed
after logon.
Visualizing processes (Basic)
10.5 Configuring user administration
STEP 7 Basic V12.0
System Manual, 01/2013, 2837
User view of an administrator
When an administrator is logged on, the user view shows all the users. The administrator
changes the user name and the password. The administrator creates new users and assigns
them to an existing user group.
User view of a user
When no administrator is logged on, the user view shows only the logged-on user. Users can
change their own passwords.
Configuring a user view
Introduction
You configure a user view in the Engineering System to also administer users in Runtime.
Visualizing processes (Basic)
10.5 Configuring user administration
STEP 7 Basic V12.0
2838 System Manual, 01/2013,
Requirements
A screen has been created.
Procedure
1. Select the "User view" object from the "Controls" category in the toolbox.
2. Drag-and-drop the "User view" object into the screen.
3. Click on "Properties > Properties" in the Inspector window.
4. Specify the appearance of the "User view".
5. You can, for example, select " "Display mode > Fit to size > Fit object to contents".
Result
You have created a user view in the screen.
Creating users
Introduction
You create a user so that users can log on under their user name in runtime.
As an alternative, you can create users in the engineering system and download them to the
HMI device.
The logon is successful only when the user name entered during the logon matches a user in
runtime. In addition, the password entered at logon has to match that of the user.
Note
Note that the entry is case-sensitive.
You assign the user to a user group. The user then has the authorizations of the user group.
Note
Runtime users must be assigned to a user group. The user group is created in the Engineering
System. The designation of the user group is language-dependent.
Requirements
The user view is open.
A "Group 2" user group has been created.
Visualizing processes (Basic)
10.5 Configuring user administration
STEP 7 Basic V12.0
System Manual, 01/2013, 2839
Procedure
1. Click "<New User>" in the user view. A dialog opens.
2. Enter "Foreman" as the user name.
3. Press the <Return> button.
4. Click "Password."
5. Enter the password of the user.
6. Press the <Return> button. The password is hidden.
7. Click in the "Group" column.
8. Select "Group 2" as the "Group".
9. Press the <Return> button.
10.Click in the "Logoff time" column.
11.Enter the time after which the user is logged off automatically.
Managing users in the simple user view
Introduction
If you have configured a user view in the engineering system, the users and user groups can
be managed in runtime.
NOTICE
Changes in the user view are effective immediately in runtime. Changes in runtime are not
updated in the Engineering System. When downloading the user administration to the HMI
device, all changes in the user view are overwritten after a security prompt and based on the
settings.
Requirements
Runtime is enabled.
The simple user view has been created.
Visualizing processes (Basic)
10.5 Configuring user administration
STEP 7 Basic V12.0
2840 System Manual, 01/2013,
The screen with the simple user view is open.
You have the default "User administration" authorization.
Note
If you do not have a "User administration" authorization, you can only change your own
password and your logoff time.
Changing a user name
1. Click on the line of the user whose name you want to change. A dialog box opens.
2. Enter a new user name.
3. Click "OK" to confirm your entry.
Note
The user can then no longer log on with his previous password in runtime. If you delete
the name and press <Return>, the user is deleted.
Changing the user password in basic user display
1. Click on the line of the user whose password you want to change. A dialog box opens.
2. Enter a new password.
3. Click "OK" to confirm your entry.
Note
The user can then no longer log on with his previous password in runtime.
If you delete the password in the basic user view and press <Return>, a message will be
generated. The message specifies that the password does not lie within the defined limits.
Changing the logoff time of the user
1. Click on the line of the user whose logoff time you want to change. A dialog box opens.
2. Enter a new logoff time.
3. Click "OK" to confirm your entry.
Visualizing processes (Basic)
10.5 Configuring user administration
STEP 7 Basic V12.0
System Manual, 01/2013, 2841
Deleting a user
1. Click the name of the user to be deleted.
2. Delete the name.
3. Press the <Return> button.
Note
The user can no longer log on in runtime.
Assigning a user to a different user group
1. Click on the line of the user whose user group you want to change. A dialog box opens.
2. Click on the "User group" box.
3. Select a user group.
4. Click "OK" to confirm your selection.
Unlocking users
Unlock locked out users
The check box "Activate limit for login attempts" is activated in the "Runtime settings > User
administration".
The number 3 is entered in the field "Number of invalid login attempts".
If users have three failed attempts at login, e.g. by entering an incorrect password, they are
assigned to the "Unauthorized" group. The user loses all authorizations. The user can still log
on, but no longer has any authorizations. Only a user with administrator rights re-assigns the
unauthorized user to a user group.
Logging on as a user
Introduction
As a rule you log-on as a user by means of a special button. The logon dialog box is displayed
to this purpose.
The logon dialog box is displayed by default during access to a protected object if
No user is logged on in runtime.
The logged-on user does not have the required authorization.
Note
The system always opens the logon dialog on the OP 73, OP 77A, TP 177A and Basic
Panels HMI devices when you press an access-protected button:
Visualizing processes (Basic)
10.5 Configuring user administration
STEP 7 Basic V12.0
2842 System Manual, 01/2013,
Requirements
Under "Runtime settings > User administration" the
"Enable limit for logon attempts" check box has been selected.
The number 3 is entered in the field "Number of incorrect login attempts".
The "ShowLogonDialog" system function is configured on a button called "Logon".
Procedure
1. Click the "Logon" button. The logon dialog box is displayed.
2. Enter your user name as it was specified in the user administration, for example "Foreman".
If someone has logged on before you, the name of the user will be displayed.
3. Enter the corresponding password. The input is concealed.
4. Click "OK" to close the dialog box.
Logon was successful
If you have entered the user name "Foreman" and the entered password corresponds with the
stored password, you are logged on as the user "Foreman" in runtime. You have the
authorizations of the user "Foreman".
When the user "Foreman" accesses a protected object such as the "Logging" button, access
to this protected object will only be authorized if the user "Foreman" has the required
authorization. The programmed function is executed immediately.
If you do not have the required authorization after the successful log-on, a corresponding error
message is displayed. However, you remain logged on in runtime.
Logon was unsuccessful
An error message is displayed.
In order to maintain security, you or the user logged-on before you no longer has any
authorizations. However, access to unprotected objects remains possible. The user view does
not, however, show any entries. The user view and the authorizations change after the next
successful log-on.
If the third login attempt has failed, the user will be assigned to the "Unauthorized" group. For
this reason, do not configure a user group with this display name.
If the "Log off" function is called up or the logoff time of the user has expired, the user is logged
off.
Visualizing processes (Basic)
10.5 Configuring user administration
STEP 7 Basic V12.0
System Manual, 01/2013, 2843
10.5.4.4 Configuring access protection
Access protection
Introduction
You configure an authorization at an object in order to protect it against access. All logged-on
users who have this authorization can then access the object. If a user does not have
authorization to operate an object, the logon dialog is displayed automatically.
Note
Several system functions are available under "User administration" so that user, password,
and user group can be edited, for example, in the PLC.
Configuring authorization (Basic,Advanced; Professional)
Introduction
You configure the "Archive data" authorization for a button. Then only those users who have
the appropriate authorization have access to this button, for example all the users of the
"Operators" user group.
This ensures that access to the command button is protected. If a logged-on user who belongs
to the "Operators" user group and has the required authorizations clicks the button, alarms
and variables are archived.
An example describes in detail how to configure a command button with access protection.
Requirements
The "Operators" user group has been created.
The "Archive data" authorization has been created.
A screen has been created and opened.
The screen contains a button.
Procedure
1. Click the button in the screen.
2. Click "Properties > Properties > Security" in the Inspector window.
3. Select "Archive data" as the "Authorization".
Visualizing processes (Basic)
10.5 Configuring user administration
STEP 7 Basic V12.0
2844 System Manual, 01/2013,
4. In the Inspector window, select "Properties > Events > Click".
5. Select a system function from the function list.
Note
The "Enable" and "Disable" events are only used to detect whether an object was selected
or deselected. The events do not, however, trigger a password prompt.
Do not use the "Enable"or "Disable" event if you want to configure access protection at
the function call of the object.
10.5.5 Reference
10.5.5.1 Objects with access protection
Introduction
The following objects can be configured with an authorization:
Date/time field
I/O field
Graphic I/O field
Recipe view
Switch
Button
Symbolic I/O field
System diagnostic view
10.5.5.2 Default user groups and authorizations
Principle
The predefined user groups and authorizations have the following numbers:
User group Number
"Administrator group" 1
"Users" 2
Visualizing processes (Basic)
10.5 Configuring user administration
STEP 7 Basic V12.0
System Manual, 01/2013, 2845
Authorization Number
"User administration" 1
"Monitor" 2
"Operate" 3
10.5.6 Examples
10.5.6.1 Example: Configuring a button with logon dialog box
Task
In the following example, you configure the function "ShowLogonDialog" for a button. A
different user can then log on in runtime when the shift changes, for example. In the process
the user previously logged on is logged off.
Note
In runtime the logon dialog box is not displayed by default until you access a protected object.
Either no user is logged on or the logged-on user does not have the required authorization.
Requirements
A screen has been created.
A button has been created in the screen.
Procedure
1. Click the button in the screen.
2. Click "Properties > Events > Release" in the Inspector window.
Visualizing processes (Basic)
10.5 Configuring user administration
STEP 7 Basic V12.0
2846 System Manual, 01/2013,
3. Click the entry "Add function" in the "Function list" table.
4. Select the system function "ShowLogonDialog" from the "User administration" group.
Result
If the user clicks on the button in runtime, the function "ShowLogonDialog" is called up. When
the function "ShowLogonDialog" is called up, the logon dialog box is displayed. The user logs
on with his user name and password.
10.5.6.2 Example: Logging the logon and logoff events
Task
In the following example, you configure the function "TraceUserChange" to the event "User
change".
Principle
The "TraceUserChange" function is called when a user logs on or off. When a function is called
up, a system message with information about the corresponding user is output.
This system message can be archived. When archiving, the system message is provided with
a date stamp and time stamp. This ensures that you can track which user was logged on at
the HMI device at which time and for how long.
Requirements
You have created an HMI device with Runtime Advanced.
The Inspector window is open.
Visualizing processes (Basic)
10.5 Configuring user administration
STEP 7 Basic V12.0
System Manual, 01/2013, 2847
Procedure
1. Double-click the "Scheduler" in the Project view.
2. Double-click "Add" in the table of the tasks.
3. Enter "Logon-Protocol" as the "Name".
4. Select "User change" as the "Trigger".
5. Open "Properties > Events" in the Inspector window.
6. Click the entry "Add function" in the "Function list" table.
7. Select the "TraceUserChange" system function.
Result
A system message is output when a user logs on or logs off.
10.5.6.3 Example of user management
Example: Structure of user management
Task
In the following example you set up a user administration for different users and user groups.
The example orientates itself to a typical requirement profile from manufacturing engineering.
Principle
Completely different groups of persons are involved in a plant or project. Each group of persons
protects its respective data and functions against access by others. For this purpose, users
are created and assigned to a user group.
You can reproduce different views through user groups.
Example:
Organizational view: Commissioners, Operators, Shift I, Shift II
Technological view: Axis control, Tool changers, Plant North, Plant South
The following example orientates itself to the organizational view.
Every user group has characteristic requirements regarding access protection: A user group
has operating authorizations for specific application cases. A programmer changes, for
example, recipe data records.
In the example the users Miller, Group Smith and Foreman are created and assigned to
different user groups.
Ms. Miller works as a programmer in the engineering system. The Group Smith are
commissioners. Mr. Foreman is an operator.
Visualizing processes (Basic)
10.5 Configuring user administration
STEP 7 Basic V12.0
2848 System Manual, 01/2013,
Requirements
A new project has been created.
The "User administration" editor is open.
Procedures overview
Working with user administration has the following procedure in the example:
1. Creating authorizations The planner specifies which authorizations are required for access
protection.
2. Configuring authorizations: The planner specifies which objects may be operated and which
functions may be executed.
3. Creating user groups and allocating authorizations: The administrator creates the user
groups together with the planner. The planner uses the authorizations to specify who may
operate objects and change parameters.
4. Creating users and assigning them to a user group: The administrator administers the users.
Result
The aim is the following structure of the user administration of users, user groups and
authorizations:
Users User groups Authorizations
Miller Smith Foreman Roles Changing
recipe
records
Changing
system
parameters
Changing
process
parameters
Managing
Administrator group x
X Programmer X
X Commissioning
engineers
X X X
X Operators x
The user "Foreman" who belongs to the "Operators" user group has access to the configured
"To Recipe view" button.
Note
Alternatively, you can create several users as operators with different operating
authorizations, for example, Operator Level 1, Operator Level 2.
Example: Creating and configuring authorizations
Task
The following example shows you how to create the authorizations
Visualizing processes (Basic)
10.5 Configuring user administration
STEP 7 Basic V12.0
System Manual, 01/2013, 2849
Procedure
1. Open the "User groups" work area.
2. Double-click "Add" in the "Authorizations" table.
3. Enter "Change recipe data records" as the "Name" of the authorization.
4. Repeat steps 2 and 3 to create additional authorizations: "Change system parameters",
"Change process parameters".
Result
Example: Configuring a button with access protection
Task
In the following example you use a system function to create a button for a screen change.
You protect the "To Recipe view" button against unauthorized operation. To do so, you
configure the "Change recipe data records" authorization at the "To Recipe view" button.
Requirements
A "Change recipe data records" authorization has been created.
A "Recipes" screen has been created.
A "Start" screen has been created and opened.
A button has been created and marked in the "Start" screen.
Visualizing processes (Basic)
10.5 Configuring user administration
STEP 7 Basic V12.0
2850 System Manual, 01/2013,
Procedure
1. Click "Properties > Properties > General" in the Inspector window.
2. Enter "To Recipe view" as the text.
3. Click "Properties > Events > Click" in the Inspector window.
4. Click the "Add function" entry in the first line of the "Function list" table.
5. Select the "ActivateScreen" system function in the "Screens" group.
6. Click the button in the "Screen name" field. A dialog box for selecting the screen opens.
7. Select the "Recipes" screen and use the button to close the dialog box.
8. Click "Properties > Properties > Security" in the Inspector window.
9. Select "Change recipe data records" as the "Authorization."
Result
Access to the "To Recipe view" button is protected. If, for example, the user "Smith" clicks the
button in Runtime, the function "Recipe view" screen is called up. Prerequisite is that the user
"Smith" has logged on correctly and has the required authorization. The "Recipes" screen
contains a recipe view and other screen objects.
Visualizing processes (Basic)
10.5 Configuring user administration
STEP 7 Basic V12.0
System Manual, 01/2013, 2851
If the logged-on user does not have the required authorization or if no user is logged on, the
"Logon dialog box" is displayed.
Example: Creating user groups and assigning authorizations:
Task
In the following example you create the user groups and assign authorizations to them.
Procedure
1. Open the "User groups" work area.
2. Double-click "Add" in the "Groups" table.
3. Enter "Programmer" as the "Name".
4. Repeat steps 2 and 3 to create the "Commissioner" and "Operator" user groups.
5. Click "Administrator" in the "Groups" table.
6. Activate the "Change system parameters" authorization in the "Authorizations" table.
Interim result
Visualizing processes (Basic)
10.5 Configuring user administration
STEP 7 Basic V12.0
2852 System Manual, 01/2013,
Procedure
1. Click "Operator" in the "Groups" table.
2. Activate the "Change recipe data records" authorization in the "Authorizations" table.
3. Click "Commissioner" in the "Groups" table.
4. Activate the authorizations "Change recipe data records", "Change system parameters"
and "Change process parameters" in the "Authorizations" table.
5. Click "Programmer" in the "Groups" table.
6. Activate the "Change recipe data records" authorization in the "Authorizations" table.
Result
Example: Creating users and assigning them to a user group
Task
In the following example you create the users and assign user groups to them. The users are
sorted alphabetically immediately after the name has been entered.
Procedure
1. Open the "Users" work area.
2. Double-click "Add" in the "Users" table.
Visualizing processes (Basic)
10.5 Configuring user administration
STEP 7 Basic V12.0
System Manual, 01/2013, 2853
3. Enter "Miller" as the user name.
4. Click the button in the "Password" column. The dialog box for entering the password is
displayed.
5. Enter "miller" as the password.
6. To confirm the password enter it a second time in the lower field.
7. Close the dialog box by using the icon.
8. Activate the "Programmer" user group in the "Groups" table.
Interim result
Procedure
1. Double-click "Add" in the "Users" table.
2. Enter "Smith" as the user name.
3. Click the button in the "Password" column. The dialog box for entering the password is
displayed.
4. Enter "smith" as the password.
5. To confirm the password enter it a second time in the lower field.
6. Close the dialog box by using the icon.
7. Activate the "Commissioner" user group in the "Groups" table.
8. Repeat steps 2 to 6 for the user "Foreman."
9. Activate the "Operators" user group in the "Groups" table.
Visualizing processes (Basic)
10.5 Configuring user administration
STEP 7 Basic V12.0
2854 System Manual, 01/2013,
Result
Visualizing processes (Basic)
10.5 Configuring user administration
STEP 7 Basic V12.0
System Manual, 01/2013, 2855
10.6 Working with system functions
10.6.1 Basics
10.6.1.1 System functions
Introduction
System functions are functions supplied by WinCC. They are predefined and cannot be
changed. You can use system functions to implement many tasks in Runtime even without
having any programming knowledge, for example:
Calculations, e.g. increasing a tag value by a specific or variable amount.
Logging functions, e.g. starting a process value log.
Settings, e.g. changing the PLC or setting a bit in the PLC.
Alarms, e.g after a different user logs on.
Usage
You use system functions in a function list. When configuring a function list, you select the
system functions from a selection list that is sorted by categories:
Each system function in WinCC is logically linked with an object and an event. As soon as the
event occurs, the system function is triggered.
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
2856 System Manual, 01/2013,
Language dependency
The names of the system functions are dependent on the set project language. The
functionality can then be recognized immediately by the project planner.
Availability
You only configure system functions within a function list which are supported by the selected
HMI device. If you use a project for several HMI devices, the system functions that are not
supported by an HMI device are marked in color.
Events
The object and the selected function determine which events can be defined as triggers for
executing a system function.
For example, the "Change value", "Low limit violated" and "Upper limit exceeded" events are
associated with the "Tag" object. The "Loaded" and "Cleared" events are associated with the
"Screen" object.
10.6.1.2 Use of system functions
Introduction
A function list is processed when a configured event occurs in runtime. The operator can trigger
an event, for example, by pressing a function key on the HMI device. The system could also
trigger an event if a process value falls below a specified limit, for example.
Applications
You can configure system functions on all the objects that are able to react to an event. You
can use system functions directly in function lists and thereby control the sequence.
Function list
The system functions will be processed one line at a time in a function list. To avoid wait
times, system functions in WinCC Runtime with a longer running time are executed
simultaneously. For instance, a subsequent system function can already be performed even
though the previous system function has not yet been completed.
An example for the configuration of a function list can be found under "Changing the operating
mode on the HMI device with the current display".
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
System Manual, 01/2013, 2857
10.6.2 Working with function lists
10.6.2.1 Basic of the functions list
Introduction
When the configured event occurs, several system functions can be performed with the
function list.
Principle
The function list is configured for an event of an object, e.g. a screen object or a tag. The events
which are available depend on the selected object and the HMI device.
Events occur only when the project is in Runtime. Events include:
Value changes of a tag
Pressing of a button
Activation of Runtime
You can configure exactly one function list for each event.
Note
The choice of configurable system functions in a function list depends on the HMI device
chosen.
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
2858 System Manual, 01/2013,
10.6.2.2 Properties of a function list
Status information
During configuration the project data is tested in the background.
With the following causes the function list is not executed in Runtime and the incorrect entries
are marked red:
At least one system function is not completely supplied with parameters.
At least one system function is contained which is not supported by the selected HMI device,
for example, by changing the device type.
Executing system functions
System functions in a function list are executed in runtime sequentially from top to bottom. To
avoid wait times, system functions with a longer running time (such as file operations) are
processed simultaneously. For instance, a subsequent system function can already be
performed even though the previous system function has not yet been completed.
Use a script with loops, conditional statements and abort conditions to program non-sequential
and conditional procedures.
Note
Availability for specific devices
User-defined functions are not available on Basic Panels.
10.6.2.3 Configuring a function list
Introduction
You can configure a function list by selecting system functions from a drop-down list. The
system functions are arranged in the drop-down list according to categories.
Requirement
Object has at least one configurable event.
Procedure
Proceed as follows to configure a function list:
1. Open the editor in WinCC in which the object is located.
2. Select the object.
3. Click "Properties > Events" in the Inspector window. Select the event for which you want
to configure the function list.
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
System Manual, 01/2013, 2859
4. Select the "<No Function>" entry in the drop-down list of the Inspector window.
5. Select the desired system function.
6. You can also enter the name of the system function.
The system function is entered in the function list.
7. If the system function has parameters, specify the values for the parameters.
8. If you want to add other system functions or functions to the function list, then repeat steps
four to seven.
Result
The function list is configured. In addition, to the configured event, the status of the function
list is displayed in the Inspector window. When the configured event occurs in Runtime, the
function list is completed from top to bottom.
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
2860 System Manual, 01/2013,
10.6.2.4 Editing a function list
Introduction
A function list can be edited as follows:
Changing the order of execution for system functions
Removing a system function
For additional information, refer to "Configuring a function list".
Requirement
The function list is configured.
Changing the order of a system function
1. Select the desired system function in the function list.
2. Then click the appropriate direction arrow in the inspector window until the system function
or customized function is in the desired position.
Changing the order of several system functions
1. Hold down the <Shift> key.
2. Click the relevant system functions, working in succession.
3. Move the selection to the desired position by drag&drop.
Removing a system function
1. Select the desired system function in the function list.
2. Select "Delete" from the shortcut menu.
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
System Manual, 01/2013, 2861
10.6.2.5 Executing a function list in Runtime
Principle
A function list is executed from top to bottom in Runtime. A distinction is made between
synchronous and asynchronous execution, so that no waiting periods ensue during execution.
The distinction is made by the system by evaluating the different runtimes of the system
functions. User-defined functions are always executed synchronously independent of the
runtime. If a system function returns an error status, the execution of the function list is
cancelled.
Synchronous execution
During synchronous execution, the system functions in a function list are executed one after
the other. The previous system function must be finished before the next system function can
be executed.
Asynchronous execution
System functions that perform file operations such as saving and reading have a longer runtime
than system functions that, for example, set a tag value.
Therefore, system functions with longer runtimes are executed asynchronously. For example,
while a system function is writing a recipe data record to a storage medium, the next system
function is already being executed. Due to the parallel execution of system functions, waiting
periods at the HMI device are avoided.
10.6.3 Example
10.6.3.1 Changing the operating mode on the HMI device with the current display
Scheduled task
In this example, you use the "SetDeviceMode" system function to switch between the "online"
and "offline" modes on the HMI device. You also display the current set operating mode on
the HMI device.
Requirements
A screen has been created.
Settings
For this example you require a HMI-tag and a text list with the following settings:
HMI tag:
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
2862 System Manual, 01/2013,
Name PLC connection Type
OperatingMode No Bool
Text list:
Name Contains Values
ShowOperatingMode Bit (0/1) 1: Operating mode: "Online"
0: Operating mode: "Offline"
Procedure
1. Create the "OperatingMode" HMI-tag indicated above.
2. Create the "ShowOperatingMode" text list indicated above.
3. Open the screen and insert a button for which you configure the operating mode change
to "online".
4. Click "Properties> Events" in the Inspector window. Select the "Press" event.
5. Configure the "SetDeviceMode" system function for the "Press" event. The system function
is found in the selection list under "Settings".
6. For the "Mode" parameter, select the "Online" entry.
7. Configure the system function "SetBit" on the event "Press". The system function is found
in the selection list under "Bit processing".
8. Select the HMI-tag "Operating mode" from the selection list for the parameter "Tag".
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
System Manual, 01/2013, 2863
9. Add a button in the process screen for which you configure the operating mode change to
"offline".
10.Repeat steps four to seven. For the "Mode" parameter, select the "Offline" entry. Configure
the system function "ResetBit" in place of the system function "SetBit."
Interim result
You can toggle the operating mode of the HMI device with the two buttons in Runtime.
You want to display the current set operating mode in an output field on the HMI device.
Procedure
1. Create a "Symbolic I/O field" in the process image. Click "Properties > Properties" in the
Inspector window.
2. Make the following settings in the "General" group:
Select "Output" as the "Mode".
Select the text list "Show operating mode" as "Text list".
Select "Operating mode" as "Tag".
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
2864 System Manual, 01/2013,
Result
When you change the operating mode with the buttons, the currently set operating mode on
the HMI device is always shown.
10.6.4 Reference
10.6.4.1 Function list
Device-based dependency of system functions
Availability of system functions
The following table shows the availability of system functions and user-defined functions on
the HMI devices.
Technical data subject to change.
Overview
KP300
Basic
PN
KTP400
Basic PN
KTP 600
Basic DP
KTP 600
Basic PN
KTP
1000
Basic DP
KTP
1000
Basic PN
TP 1500
Basic
PN
User-defined functions No No No No No No No
Logoff (Page 2868) Yes Yes Yes Yes Yes Yes Yes
AdjustContrast (Page 2868) Yes Yes No Yes
1)
Yes Yes Yes
ActivateScreen (Page 2869) Yes Yes Yes Yes Yes Yes Yes
ActivateScreenByNumber
(Page 2870)
Yes Yes Yes Yes Yes Yes Yes
ActivateCleanScreen (Page 2871) No Yes Yes Yes Yes Yes Yes
ActivatePreviousScreen (Page 2872) Yes Yes Yes Yes Yes Yes Yes
UpdateTag (Page 2873) Yes Yes Yes Yes Yes Yes Yes
Logon (Page 2873) Yes Yes Yes Yes Yes Yes Yes
EditAlarm (Page 2874) Yes Yes Yes Yes Yes Yes No
ScreenObjectCursorDown
(Page 2875)
Yes Yes Yes Yes Yes Yes Yes
ScreenObjectCursorUp (Page 2875) Yes Yes Yes Yes Yes Yes Yes
ScreenObjectPageDown (Page 2876) Yes Yes Yes Yes Yes Yes Yes
ScreenObjectPageUp (Page 2876) Yes Yes Yes Yes Yes Yes Yes
IncreaseFocusedValue (Page 2877) Yes Yes Yes Yes Yes Yes No
IncreaseTag (Page 2878) Yes Yes Yes Yes Yes Yes Yes
GoToHome (Page 2878) Yes Yes Yes Yes Yes Yes No
GoToEnd (Page 2879) Yes Yes Yes Yes Yes Yes No
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
System Manual, 01/2013, 2865
KP300
Basic
PN
KTP400
Basic PN
KTP 600
Basic DP
KTP 600
Basic PN
KTP
1000
Basic DP
KTP
1000
Basic PN
TP 1500
Basic
PN
InvertBit (Page 2880) Yes Yes Yes Yes Yes Yes Yes
InvertBitInTag (Page 2881) Yes Yes Yes Yes Yes Yes Yes
InvertLinearScaling (Page 2882) Yes Yes Yes Yes Yes Yes Yes
CalibrateTouchScreen (Page 2883) Yes Yes Yes Yes Yes Yes Yes
TrendViewScrollForward (Page 2884) Yes Yes Yes Yes Yes Yes Yes
TrendViewScrollBack (Page 2885) Yes Yes Yes Yes Yes Yes Yes
TrendViewExtend (Page 2885) Yes Yes Yes Yes Yes Yes Yes
TrendViewCompress (Page 2886) Yes Yes Yes Yes Yes Yes Yes
TrendViewRulerRight (Page 2887) Yes Yes Yes Yes Yes Yes Yes
TrendViewRulerLeft (Page 2886) Yes Yes Yes Yes Yes Yes Yes
TrendViewSetRulerMode
(Page 2887)
Yes Yes Yes Yes Yes Yes Yes
TrendViewStartStop (Page 2888) Yes Yes Yes Yes Yes Yes Yes
TrendViewBackToBeginning
(Page 2888)
Yes Yes Yes Yes Yes Yes Yes
GetUserName (Page 2889) Yes Yes Yes Yes Yes Yes Yes
GetGroupNumber (Page 2890) Yes Yes Yes Yes Yes Yes Yes
GetPassword (Page 2890) Yes Yes Yes Yes Yes Yes Yes
LinearScaling (Page 2892) Yes Yes Yes Yes Yes Yes Yes
ClearAlarmBuffer (Page 2893) Yes Yes Yes Yes Yes Yes Yes
ClearAlarmBufferProTool
(Page 2894)
Yes Yes Yes Yes Yes Yes Yes
AlarmViewEditAlarm (Page 2895) Yes Yes Yes Yes Yes Yes Yes
AlarmViewAcknowledgeAlarm
(Page 2896)
Yes Yes Yes Yes Yes Yes Yes
AlarmViewShowOperatorNotes
(Page 2896)
Yes Yes Yes Yes Yes Yes Yes
AcknowledgeAlarm (Page 2897) Yes Yes Yes Yes Yes Yes Yes
RecipeViewNewDataRecord
(Page 2898)
Yes Yes Yes Yes Yes Yes Yes
RecipeViewGetDataRecordFromPLC
(Page 2898)
Yes Yes Yes Yes Yes Yes Yes
RecipeViewClearDataRecord
(Page 2898)
Yes Yes Yes Yes Yes Yes Yes
RecipeViewMenu (Page 2899) Yes Yes Yes Yes Yes Yes Yes
RecipeViewOpen (Page 2899) Yes Yes Yes Yes Yes Yes Yes
RecipeViewSetDataRecordToPLC
(Page 2900)
Yes Yes Yes Yes Yes Yes Yes
RecipeViewSaveDataRecord
(Page 2901)
Yes Yes Yes Yes Yes Yes Yes
RecipeViewSaveAsDataRecord
(Page 2901)
Yes Yes Yes Yes Yes Yes Yes
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
2866 System Manual, 01/2013,
KP300
Basic
PN
KTP400
Basic PN
KTP 600
Basic DP
KTP 600
Basic PN
KTP
1000
Basic DP
KTP
1000
Basic PN
TP 1500
Basic
PN
RecipeViewRenameDataRecord
(Page 2901)
Yes Yes Yes Yes Yes Yes Yes
RecipeViewShowOperatorNotes
(Page 2902)
Yes Yes Yes Yes Yes Yes Yes
RecipeViewBack (Page 2902) Yes Yes Yes Yes Yes Yes Yes
ResetBit (Page 2903) Yes Yes Yes Yes Yes Yes Yes
ResetBitInTag (Page 2904) Yes Yes Yes Yes Yes Yes Yes
PressButton (Page 2905) Yes Yes Yes Yes Yes Yes No
ReleaseButton (Page 2906) Yes Yes Yes Yes Yes Yes No
ShiftAndMask (Page 2907) Yes Yes Yes Yes Yes Yes Yes
PageDown (Page 2909) Yes Yes Yes Yes Yes Yes No
PageUp (Page 2908) Yes Yes Yes Yes Yes Yes No
SetDeviceMode (Page 2909) Yes Yes Yes Yes Yes Yes Yes
SetBit (Page 2910) Yes Yes Yes Yes Yes Yes Yes
SetBitInTag (Page 2911) Yes Yes Yes Yes Yes Yes Yes
SetBitWhileKeyPressed (Page 2913) Yes Yes Yes Yes Yes Yes Yes
SetColorBackgroundLighting
(Page 2914)
Yes No No No No No No
SetLanguage (Page 2916) Yes Yes Yes Yes Yes Yes Yes
SetTag (Page 2917) Yes Yes Yes Yes Yes Yes Yes
SetConnectionMode (Page 2918) Yes Yes Yes Yes Yes Yes Yes
SimulateSystemKey (Page 2919) Yes Yes Yes Yes Yes Yes No
SimulateTag (Page 2920) Yes Yes Yes Yes Yes Yes Yes
StopRuntime (Page 2921) Yes Yes Yes Yes Yes Yes Yes
TraceUserChange (Page 2922) Yes Yes Yes Yes Yes Yes Yes
DecreaseFocusedValue (Page 2923) Yes Yes Yes Yes Yes Yes No
DecreaseTag (Page 2923) Yes Yes Yes Yes Yes Yes Yes
ChangeConnection (Page 2924) Yes Yes Yes Yes Yes Yes Yes
ShowLogonDialog (Page 2926) Yes Yes Yes Yes Yes Yes Yes
ShowOperatorNotes (Page 2926) Yes Yes Yes Yes Yes Yes Yes
ShowAlarmWindow (Page 2927) Yes Yes Yes Yes Yes Yes Yes
1)
For KTP600 Basic mono PN only.
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
System Manual, 01/2013, 2867
System functions
Logoff
Description
Logs off the current user on the HMI device.
Use in the function list
Logoff
Use in user-defined functions
Logoff
Can be used if the configured device supports user-defined functions. For additional
information, refer to "Device dependency".
Parameter
--
See also
Device-based dependency of system functions (Page 2865)
Logon (Page 2873)
AdjustContrast
Description
Changes the contrast of the display one level on the HMI device.
Use in the function list
AdjustContrast (Adjust)
Use in user-defined functions
-
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
2868 System Manual, 01/2013,
Parameters
Adjust
Specifies how the contrast is changed:
0 (hmiDecrease) = Decrease: Decreases the contrast one level.
1 (hmiIncrease) = Increase: Increases the contrast one level.
Application example
Objective
One button each for increasing and decreasing the screen contrast is desired.
Notes on configuring
Configure two buttons and configure the "AdjustContrast" system function on the "Press" event.
The parameters "Increase" and "Decrease" are allocated.
Procedure on HMI device
When one of the two buttons is pressed in runtime, the contrast is increased or decreased one
level.
See also
Device-based dependency of system functions (Page 2865)
Logoff (Page 2868)
ActivateScreen
Description
Performs a screen change to the given screen.
Use the "ActivateScreenByNumber" system function to change from the root screen to the
permanent window or vice versa.
Use in the function list
ActivateScreen (Screen name, Object number)
Use in user-defined functions
ActivateScreen (Screen_name, Object_number)
Can be used if the configured device supports user-defined functions. For additional
information, refer to "Device dependency".
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
System Manual, 01/2013, 2869
Parameters
Screen name
Name of the screen to which you change.
Object number
The operator control element which receives the focus in the given screen after the screen
change. The number of the operator control element is to be determined using the tabulator
sequence during configuration.
When "0" is specified:
If the focus is in the permanent window when the system function is called up, the
permanent window maintains the focus.
If the focus is in the root screen when the system function is called up, the first operator
control element in the given screen receives the focus.
Note
If the "Reach margin" event is assigned to the "ActivateScreen" system function, only the
value "0" is valid for the "Object number" parameter. The active object is not defined by
the object number, but rather by the X position it had prior to the screen change.
Example
The ActivateScreen function is used in the following program code to activate the "Screen_2"
screen when you click a button.
{
// User defined code
// i.e. when pressing a button
ActivateScreen ("Screen_2", 0);
...
}
See also
Device-based dependency of system functions (Page 2865)
ActivateScreenByNumber (Page 2870)
ActivateScreenByNumber
Description
Performs a screen change to a screen depending on a tag value.
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
2870 System Manual, 01/2013,
The screen is identified by its screen number.
Use in the function list
ActivateScreenByNumber (Screen number, Object number)
Use in user-defined functions
ActivateScreenByNumber (Screen_number, Object_number)
Can be used if the configured device supports user-defined functions. For additional
information, refer to "Device dependency".
Parameter
Screen number
Tag which contains the screen number of the destination screen.
When a change from the root screen to the permanent window is desired, "0" or "-1" is specified:
0 = Change from root screen to permanent window
-1 = Change from permanent window to root screen
Object number
The number of the screen object which receives the focus in the given screen after the screen
change. The number of the operator control element is to be determined using the tabulator
sequence during configuration.
When "0" is specified:
If the focus is in the permanent window when the system function is called up, the
permanent window maintains the focus.
If the focus is in the root screen when the system function is called up, the first operator
control element in the given screen receives the focus.
See also
Device-based dependency of system functions (Page 2865)
ActivateScreen (Page 2869)
ActivateCleanScreen
Description
Activates the clean screen on the HMI device. The display of the HMI device is disabled for
the given time period.
When the display of the HMI device is deactivated, it can be cleaned without triggering touch
functions by mistake.
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
System Manual, 01/2013, 2871
Use in the function list
ActivateCleanScreen (Time period)
Use in user-defined functions
--
Parameters
Time period
Time period for which the display is disabled. The time remaining is displayed as a progress
bar.
Value range in seconds from 10 through 300.
Note
The system function ActivateCleanScreen cannot be simulated.
See also
Logoff (Page 2868)
ActivatePreviousScreen
Description
Performs a screen change to the screen which was activated before the current screen. The
screen change is not performed if no screen was activated beforehand.
The last 10 screens that were called up are saved. A system alarm is output when you change
to a screen which is no longer saved.
Note
If you want to use the system function, the screen to which you change has to be used in the
navigation structure.
Use in the function list
ActivatePreviousScreen
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
2872 System Manual, 01/2013,
Use in user-defined functions
ActivatePreviousScreen
Can be used if the configured device supports user-defined functions. For additional
information, refer to "Device dependency".
Parameter
--
See also
Device-based dependency of system functions (Page 2865)
UpdateTag
Description
Reads the current value of the tag with the specified Update ID from the PLC.
Use in the function list
UpdateTag (Update ID)
Use in user-defined functions
-
Parameters
Update ID
Update ID assigned to the tag that will be updated.
See also
Logoff (Page 2868)
Logon
Description
Logs on the current user on the HMI device.
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
System Manual, 01/2013, 2873
Use in the function list
Logon (Password, User name)
Use in user-defined functions
Logon (Password, User_name)
Can be used if the configured device supports user-defined functions. For additional
information, refer to "Device dependency".
Parameter
Password
The tag from which the password for the user logging on is read.
If the user is logged on, the password in the tag is deleted.
User name
The tag from which the user name for the user logging on is read.
See also
Device-based dependency of system functions (Page 2865)
Logoff (Page 2868)
EditAlarm
Description
Triggers the "Edit" event for all selected alarms.
If the alarms to be edited have not yet been acknowledged, the acknowledgment takes place
automatically when this system function is called up.
This system function can only be used for function keys.
Use in the function list
EditAlarm
Use in user-defined functions
EditAlarm
Can be used if the configured device supports user-defined functions. For additional
information, refer to "Device dependency".
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
2874 System Manual, 01/2013,
Parameter
--
See also
Device-based dependency of system functions (Page 2865)
ScreenObjectCursorUp
Description
Results in a line-by-line, upward cursor movement in the specified screen object.
The system function can be used for the following screen objects:
User view
Alarm view
Recipe view
Use in the function list
ScreenObjectCursorUp (Screen object)
Use in user-defined functions
-
Parameters
Screen object
Name of the screen object in which the key function is triggered.
ScreenObjectCursorDown
Description
Results in a line-by-line, downward cursor movement in the specified screen object.
The system function can be used for the following screen objects:
User view
Alarm view
Recipe view
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
System Manual, 01/2013, 2875
Use in the function list
ScreenObjectCursorDown (Screen object)
Use in user-defined functions
-
Parameters
Screen object
Name of the screen object in which the key function is triggered.
ScreenObjectPageUp
Description
Results in a page-by-page, upward cursor movement in the specified screen object.
The system function can be used for the following screen objects:
User view
Alarm view
Recipe view
Use in the function list
ScreenObjectPageUp (Screen object)
Use in user-defined functions
-
Parameters
Screen object
Name of the screen object in which the key function is triggered.
ScreenObjectPageDown
Description
Results in a page-by-page, downward cursor movement in the specified screen object.
The system function can be used for the following screen objects:
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
2876 System Manual, 01/2013,
User view
Alarm view
Recipe view
Use in the function list
ScreenObjectPageDown (Screen object)
Use in user-defined functions
-
Parameters
Screen object
Name of the screen object in which the key function is triggered.
IncreaseFocusedValue
Description
Adds the given value to the value of the tag which is connected to the input field (drop-down
list, graphic selection list, slider bar) which has the current focus.
This system function can only be used for function keys.
Use in the function list
IncreaseFocusedValue (Value)
Use in user-defined functions
-
Parameters
Value
The value which is added to the tag value.
See also
Device-based dependency of system functions (Page 2865)
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
System Manual, 01/2013, 2877
IncreaseTag
Description
Adds the given value to the value of the tags.
X = X + a
Note
The system function uses the same tag as input and output values. When this system function
is used to convert a value, help tags must be used. You can use the "SetTag" system function
to assign the tag value to the auxiliary tags.
If you configure the system function on the events of an alarm and the tag is not being used
in the current screen, it is not ensured that the actual value of the tags is being used in the
PLC. You can improve the situation by setting the "Cyclic continuous" acquisition mode.
Use in the function list
IncreaseTag (Tag, Value)
Use in user-defined functions
IncreaseTag (Tag, Value)
Can be used if the configured device supports user-defined functions. For additional
information, refer to "Device dependency".
Parameter
Tag
The tag to which the given value is added.
Value
The value which is added.
See also
Device-based dependency of system functions (Page 2865)
SetTag (Page 2917)
GoToHome
Description
Executes the key function <Home> on the HMI device.
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
2878 System Manual, 01/2013,
This system function is used when the HMI device does not have this functionality by default.
The system function can only be used for the following function keys.
Use in the function list
GoToHome
Use in user-defined functions
GoToHome
Can be used if the configured device supports user-defined functions. For additional
information, refer to "Device dependency".
Parameter
--
See also
Device-based dependency of system functions (Page 2865)
GoToEnd
Description
Executes the key function <End> on the HMI device.
This system function is used when the HMI device does not have this functionality by default.
The system function can only be used for the following function keys.
Use in the function list
GoToEnd
Use in user-defined functions
GoToEnd
Can be used if the configured device supports user-defined functions. For additional
information, refer to "Device dependency".
Parameter
--
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
System Manual, 01/2013, 2879
See also
Device-based dependency of system functions (Page 2865)
InvertBit
Description
Inverts the value of the given tag of the "Bool" type:
If the tag has the value of 1 (TRUE), it will be set to 0 (FALSE).
If the tag has the value of 0 (FALSE), it will be set to 1 (TRUE).
Use in the function list
InvertBit (Tag)
Use in user-defined functions
InvertBit (Tag)
Can be used if the configured device supports user-defined functions. For additional
information, refer to "Device dependency".
Parameters
Tag
The tag whose bit is set.
Example
The following program code inverts the value of the boolean tag b_value and outputs the result
along with the original b_saved value.
{
BOOL b_value = 0;
BOOL b_saved = b_value;
//Invert variable
invertBit(b_value);
//print current and saved value
printf ("Current value: %d\r\n, Saved value: %d\r\n",b_value, b_saved);
...
}
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
2880 System Manual, 01/2013,
See also
Device-based dependency of system functions (Page 2865)
InvertBitInTag (Page 2881)
InvertBitInTag
Description
Inverts a bit in the given tag:
If the bit in the tag has the value of 1 (TRUE), it will be set to 0 (FALSE).
If the bit in the tag has the value of 0 (FALSE), it will be set to 1 (TRUE).
After changing the given bit, the system function transfers the entire tag back to the PLC. It is
not checked whether other bits in the tags have changed in the meantime. Operator and PLC
have read-only access to the indicated tag until it is transferred back to the PLC.
Note
If the PLC supports BOOL tags, do not use this system function. Use the "InvertBit" system
function instead.
Use in the function list
InvertBitInTag (Tag, Bit)
Use in user-defined functions
InvertBitInTag (Tag, Bit)
Can be used if the configured device supports user-defined functions. For additional
information, refer to "Device dependency".
Parameters
Tag
The tag in which the given bit is set.
Bit
The number of the bit that is set.
When this system function is used in a user-defined function, the bits in a tag are counted from
right to left. The counting begins with 0.
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
System Manual, 01/2013, 2881
Example
The following program code inverts a bit at the specified bitposition in the bvalue tag and
outputs the result along with the original bsaved value.
{
BYTE bvalue;
BYTE bsaved = bvalue;
BYTE bitposition = 2;
//Invert bit in bitposition
InvertBitInTag (bvalue, bitposition);
//print current and saved value
printf ("Current value: %d\r\n, Saved value: %d\r\n",bvalue, bsaved);
...
}
See also
Device-based dependency of system functions (Page 2865)
InvertBit (Page 2880)
InvertLinearScaling
Description
Assigns a value to the tag X, which is calculated from the value of the given tag Y using the
linear function X = (Y - b) / a.
The tags X and Y must not be identical. This system function is the inverse of the
"LinearScaling" system function.
Note
The tags X and Y must not be identical. If a tag is to be converted into itself, a auxiliary tag
must be used.
The "SetTag" system function can be used to assign the value of the tags to be converted to
the auxiliary tags.
Use in the function list
InvertLinearScaling (X, Y, b, a)
Use in user-defined functions
InverseLinearScaling (X, Y, b, a)
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
2882 System Manual, 01/2013,
Can be used if the configured device supports user-defined functions. For additional
information, refer to "Device dependency".
Parameters
X
The tag which is assigned the value calculated from the linear equation.
Y
The tag that contains the value used for calculation.
b
The value which is subtracted.
a
The value through which is divided.
Example
The following program code assigns a value to the varX tag by means of the
InverseLinearScaling function.
{
BYTE varX;
BYTE Yvalue = 10;
BYTE bvalue = 3;
BYTE avalue = 4;
//Inverse linear scaling
InverseLinearScaling (varX, Yvalue, bvalue, avalue);
printf ("varX = %d\r\n, varX);
...
}
The saved return value can be processed in the following code.
See also
Device-based dependency of system functions (Page 2865)
LinearScaling (Page 2892)
CalibrateTouchScreen
Description
Calls a program for calibrating the touch screen.
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
System Manual, 01/2013, 2883
During the calibration process, there is a prompt to touch five positions on the screen display.
Touch the screen display within 30 seconds, to confirm the calibration process. If the calibration
is not completed within this time span, the calibration settings are discarded. The user prompt
is in English.
Use this system function the first time you start the HMI device.
Use in the function list
CalibrateTouchScreen
Use in user-defined functions
CalibrateTouchScreen
Can be used if the configured device supports user-defined functions. For additional
information, refer to "Device dependency".
Parameter
--
Note
The CalibrateTouchScreen system function cannot be simulated.
See also
Device-based dependency of system functions (Page 2865)
TrendViewScrollForward
Description
Scrolls forward one display width in the Trend view.
Use in the function list
TrendViewScrollForward (Screen object)
Use in user-defined functions
-
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
2884 System Manual, 01/2013,
Parameters
Screen object
Name of the trend view in which is scrolled forward.
TrendViewScrollBack
Description
Scrolls back one display width to the left in the trend view.
Use in the function list
TrendViewScrollBack (Screen object)
Use in user-defined functions
-
Parameters
Screen object
Name of the trend view in which is scrolled back.
TrendViewExtend
Description
Reduces the time period which is displayed in the trend view.
Use in the function list
TrendViewExtend (Screen object)
Use in user-defined functions
-
Parameters
Screen object
Name of the trend view in which the displayed time period is reduced.
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
System Manual, 01/2013, 2885
TrendViewCompress
Description
Increases the time period which is displayed in the trend view.
Use in the function list
TrendViewCompress (Screen object)
Use in user-defined functions
-
Parameters
Screen object
Name of the trend view in which the displayed time period is increased.
TrendViewRulerLeft
Description
Moves the read-line backwards (to the left) in the trend view.
Note
In order to be able to move the read-line, the read-line must have been switched on. This is
done using the "TrendViewSetRulerMode" system function.
Use in the function list
TrendViewRulerLeft (Screen object)
Use in user-defined functions
-
Parameters
Screen object
Name of the trend view in which the read-line is moved backwards.
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
2886 System Manual, 01/2013,
See also
TrendViewSetRulerMode (Page 2887)
TrendViewRulerRight
Description
Moves the read-line forwards (to the right) in the trend view.
Note
In order to be able to move the read-line, the read-line must have been switched on. This is
done using the "TrendViewSetRulerMode" system function.
Use in the function list
TrendViewRulerRight (Screen object)
Use in user-defined functions
-
Parameters
Screen object
Name of the trend view in which the read-line is moved forward.
See also
TrendViewSetRulerMode (Page 2887)
TrendViewSetRulerMode
Description
Hides or shows the read-line in the trend view. The read-line displays the Y value belonging
to the X value.
Note
To ensure that the ruler is displayed, you have to activate the setting "Show ruler" in the trend
view properties.
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
System Manual, 01/2013, 2887
Use in the function list
TrendViewSetRulerMode (Screen object)
Use in user-defined functions
-
Parameters
Screen object
Name of the trend view in which the read-line is hidden or shown.
See also
TrendViewRulerLeft (Page 2886)
TrendViewRulerRight (Page 2887)
TrendViewStartStop
Description
Stops the trend recording or continues the trend recording in the trend view.
Use in the function list
TrendViewStartStop (Screen object)
Use in user-defined functions
-
Parameters
Screen object
Name of the trend view in which the recording of the trend is started or stopped.
TrendViewBackToBeginning
Description
Scrolls back to the beginning of the display range in the trend view.
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
2888 System Manual, 01/2013,
Use in the function list
TrendViewBackToBeginning (Screen object)
Use in user-defined functions
-
Parameters
Screen object
Name of the trend view in which you scroll to the beginning of the display range.
GetUserName
Description
Writes the user name of the user currently logged on to the HMI device in the given tag.
If the given tag has a control connection, the user name is also available in the PLC connection.
This system function makes it possible, for example, to implement a user-dependent release
of certain functionalities.
Use in the function list
GetUserName (Tag)
Use in user-defined functions
GetUserName (Tag)
Can be used if the configured device supports user-defined functions. For additional
information, refer to "Device dependency".
Parameter
Tag
The tag to which the user name is written.
See also
Device-based dependency of system functions (Page 2865)
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
System Manual, 01/2013, 2889
GetGroupNumber
Description
Reads the number of the group to which the user logged on to the HMI device belongs, and
writes it to the given tag.
Use in the function list
GetGroupNumber (Tag)
Use in user-defined functions
GetGroupNumber (Tag)
Can be used if the configured device supports user-defined functions. For additional
information, refer to "Device dependency".
Parameter
Tag
The tag to which the number of the group is written.
See also
Device-based dependency of system functions (Page 2865)
GetPassword
Description
Writes the password of the user currently logged on to the HMI device in the given tag.
Note
Make sure that the value of the given tag is not displayed in another place in the project.
Note
The passwords of SIMATIC Logon users cannot be read.
Use in the function list
GetPassword (Tag)
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
2890 System Manual, 01/2013,
Use in user-defined functions
GetPassword (Tag)
Can be used if the configured device supports user-defined functions. For additional
information, refer to "Device dependency".
Parameter
Tag
The tag to which the password is written.
See also
Device-based dependency of system functions (Page 2865)
ReadPLCMode
Description
Evaluates the current state of the connected PLC.
The system function "ReadPLCMode" can only be configured for the following PLCs:
SIMATIC S7 1200
SIMATIC S7 1500
Use in the function list
ReadPLCMode (connection, mode)
Use in user-defined functions
GetPLCMode (Connection, Mode)
Parameter
Connection
Connection of PLC and HMI device.
Mode
Evaluates the state of the connected PLC.
For the evaluation, select the tag "@DiagnosticsIndicatorTag".
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
System Manual, 01/2013, 2891
LinearScaling
Description
Assigns a value to the tag Y, which is calculated from the value of the given tag X using the
linear function Y= (a *X) + b.
The inverse of this function is the "InvertLinearScaling" system function.
Note
The tags X and Y must not be identical. If a tag is to be converted into itself, a auxiliary tag
must be used.
The "SetTag" system function can be used to assign the value of the tags to be converted to
the auxiliary tags.
Use in the function list
LinearScaling (Y, a, X, b)
Use in user-defined functions
LinearScaling (Y, a, X, b)
Can be used if the configured device supports user-defined functions. For additional
information, refer to "Device dependency".
Parameters
Y
The tag which is assigned the value calculated from the linear equation.
a
The value with which is multiplied.
X
The tag that contains the value used for calculation.
b
The value that is added.
Example
The following program code uses the LinearScaling function to assign a value to the Yvar tag.
{
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
2892 System Manual, 01/2013,
BYTE Yvar;
BYTE Xvalue = 10;
BYTE bvalue = 3;
BYTE avalue = 4;
// linear scaling
LinearScaling ( Yvar, avalue, Xvalue, bvalue);
printf ("Yvar = %d\r\n, Yvar);
...
}
The saved return value can be processed in the following code.
See also
Device-based dependency of system functions (Page 2865)
InvertLinearScaling (Page 2882)
ClearAlarmBuffer
Description
Deletes alarms from the alarm buffer on the HMI device.
Note
Alarms which have not yet been acknowledged are also deleted.
Use in the function list
ClearAlarmBuffer (Alarm class number)
Use in user-defined functions
ClearAlarmBuffer (Alarm_class_number)
Can be used if the configured device supports user-defined functions. For additional
information, refer to "Device dependency".
Parameter
Alarm class number
Determines which alarms are to be deleted from the alarm buffer:
0 (hmiAll) = All alarms/events
1 (hmiAlarms) = Alarms of alarm class "Errors"
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
System Manual, 01/2013, 2893
2 (hmiEvents) = Alarms of alarm class "Warnings"
3 (hmiSystem) = Alarms of alarm class "System"
4 (hmiS7Diagnosis) = Alarms of alarm class "Diagnosis Events"
Note
Device dependency
Alarms of alarm class "Diagnosis Events" are not available on Basic Panels.
See also
Device-based dependency of system functions (Page 2865)
ClearAlarmBufferProTool
Description
The system function exists to ensure compatibility.
It has the same functionality as the "ClearAlarmBuffer" system function, but uses the old
ProTool numbering.
Use in the function list
ClearAlarmBufferProTool (Alarm class number)
Use in user-defined functions
ClearAlarmBufferProtoolLegacy (Alarm_class_number)
Can be used if the configured device supports user-defined functions. For additional
information, refer to "Device dependency".
Parameter
Alarm class number
Alarm class number whose messages are to be deleted:
-1 (hmiAllProtoolLegacy) = All alarms/events
0 (hmiAlarmsProtoolLegacy) = Alarms of alarm class "Errors"
1 (hmiEventsProtoolLegacy) = Alarms of alarm class "Warnings"
2 (hmiSystemProtoolLegacy) = Alarms of alarm class "System"
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
2894 System Manual, 01/2013,
3 (hmiS7DiagnosisProtoolLegacy) = Alarms of alarm class "Diagnosis Events"
Note
Device dependency
Alarms of alarm class "Diagnosis Events" are not available on Basic Panels.
See also
Device-based dependency of system functions (Page 2865)
ClearAlarmBuffer (Page 2893)
AlarmViewEditAlarm
Description
Triggers the event "Edit" for all alarms selected in the given alarm view.
This system function is used when the integrated button of the ActiveX control should not be
used.
A system function can in turn be configured on the "Edit" event. For example, it is possible to
change to the process screen in which the alarm appeared.
Note
If the alarms to be edited have not yet been acknowledged, the acknowledgment takes place
automatically when this system function is called up.
Use in the function list
AlarmViewEditAlarm (Screen object)
Use in user-defined functions
-
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
System Manual, 01/2013, 2895
Parameters
Screen object
Name of the alarm view in which the event is triggered.
Note
The HMI devices listed below do not support this system function for the "screen" object: OP
73, OP 77A, TP 177A.
AlarmViewAcknowledgeAlarm
Description
Acknowledges the alarms selected in the given alarm view.
This system function is used when the integrated button of the ActiveX control should not be
used.
Use in the function list
AlarmViewAcknowledgeAlarm (Screen object)
Use in user-defined functions
-
Parameters
Screen object
Name of the alarm view in which the event is triggered.
Note
The HMI devices listed below do not support this system function for the "screen" object: OP
73, OP 77A, TP 177A.
AlarmViewShowOperatorNotes
Description
Displays the configured tooltip of the alarm selected in the given alarm view.
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
2896 System Manual, 01/2013,
Use in the function list
AlarmViewShowOperatorNotes (Screen object)
Use in user-defined functions
-
Parameters
Screen object
Name of the alarm view in which the event is triggered.
Note
The HMI devices listed below do not support this system function for the "screen" object: OP
73, OP 77A, TP 177A.
AcknowledgeAlarm
Description
Acknowledges all selected alarms.
This system function is used when the HMI device does not have an ACK key or when the
integrated key of the alarm view should not be used.
This system function can only be used for function keys.
Use in the function list
AcknowledgeAlarm
Use in user-defined functions
AcknowledgeAlarm
Can be used if the configured device supports user-defined functions. For additional
information, refer to "Device dependency".
Parameter
--
See also
Device-based dependency of system functions (Page 2865)
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
System Manual, 01/2013, 2897
RecipeViewNewDataRecord
Description
Creates a new data record in the given recipe view.
Use in the function list
RecipeViewNewDataRecord (Screen object)
Use in user-defined functions
-
Parameters
Screen object
Name of the recipe view in which the new recipe data record is created.
RecipeViewGetDataRecordFromPLC
Description
Transfers the data record that is currently loaded in the PLC to the HMI device and displays it
in the recipe view.
Use in the function list
RecipeViewGetDataRecordFromPLC (Screen object)
Use in user-defined functions
-
Parameters
Screen object
Name of the recipe view in which the recipe data record from the PLC is displayed.
RecipeViewClearDataRecord
Description
Deletes the data record which is currently displayed in the recipe view.
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
2898 System Manual, 01/2013,
Use in the function list
RecipeViewClearDataRecord (Screen object)
Use in user-defined functions
-
Parameters
Screen object
Name of the recipe view in which the displayed recipe data record is deleted.
RecipeViewMenu
Description
Opens the menu of the specified simple recipe view.
Only use this system function at a simple recipe view.
Use in the function list
RecipeViewMenu (Screen object)
Use in user-defined functions
-
Parameters
Screen object
Name of the recipe view in which the menu is to be opened.
RecipeViewOpen
Description
Displays the data record values in the given recipe view or changes to the next selection field.
The system function has no effect if the selection field for the recipe data record values is
displayed on the HMI device.
Operation sequence of the selection lists in runtime:
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
System Manual, 01/2013, 2899
Recipe name
Data record name
RecipeDataRecordValues
This system function is used when a simple recipe view has been configured. In the simple
recipe view, only one selection list is displayed at a time on the HMI device. Use the
"RecipeViewBack" system function to display the previous selection list.
Use in the function list
RecipeViewOpen (Screen object)
Use in user-defined functions
-
Parameters
Screen object
Name of the recipe view in which the command is triggered.
See also
RecipeViewBack (Page 2902)
RecipeViewSetDataRecordToPLC
Description
Transfers the recipe data record which is currently displayed in the recipe view to the PLC.
Use in the function list
RecipeViewSetDataRecordToPLC (Screen object)
Use in user-defined functions
-
Parameters
Screen object
Name of the recipe view from which the recipe data record is transferred to the connected PLC.
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
2900 System Manual, 01/2013,
RecipeViewSaveDataRecord
Description
Saves the recipe data record which is currently displayed in the recipe view.
Use in the function list
RecipeViewSaveDataRecord (Screen object)
Use in user-defined functions
-
Parameters
Screen object
Name of the recipe view in which the recipe data record is saved.
RecipeViewSaveAsDataRecord
Description
Saves the data record currently being displayed in the recipe view under a new name.
Use in the function list
RecipeViewSaveAsDataRecord (Screen object)
Use in user-defined functions
-
Parameters
Screen object
Saves the data record currently being displayed in the recipe view under a new name and/or
new number.
RecipeViewRenameDataRecord
Description
Renames the selected data record in the given recipe view.
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
System Manual, 01/2013, 2901
Only use this system function at a simple recipe view.
Use in the function list
RecipeViewRenameDataRecord (Screen object)
Use in user-defined functions
-
Parameters
Screen object
Name of the recipe view in which the recipe data record is renamed.
RecipeViewShowOperatorNotes
Description
Displays the configured tooltip of the specified recipe view.
Use in the function list
RecipeViewShowOperatorNotes (Screen object)
Use in user-defined functions
-
Parameters
Screen object
Name of the recipe view whose configured tooltip is displayed.
RecipeViewBack
Description
Returns to the previous selection list in the given recipe view.
The system function has no effect if the selection field for the recipe is displayed on the HMI
device. Operation sequence of the selection lists in runtime:
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
2902 System Manual, 01/2013,
Recipe name
Data record name
RecipeDataRecordValues
This system function is used when a simple recipe view has been configured. In the simple
recipe view, only one selection list is displayed at a time on the HMI device. Use the
"RecipeViewOpen" system function to display the recipe data record values or the next
selection field.
Use in the function list
RecipeViewBack (Screen object)
Use in user-defined functions
-
Parameters
Screen object
Name of the recipe view in which the command is triggered.
ResetBit
Description
Sets the value of a "Bool" type tag to 0 (FALSE).
Use in the function list
ResetBit (Tag)
Use in user-defined functions
ResetBit (Tag)
Can be used if the configured device supports user-defined functions. For additional
information, refer to "Device dependency".
Parameters
Tag
The BOOL type tag which is set to 0 (FALSE).
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
System Manual, 01/2013, 2903
Example
The following program code resets the value of the boolean tag b_value to 0 by means of the
ResetBit function and outputs the result along with the original b_saved value.
{
BOOL b_value = 1;
BOOL b_saved = b_value;
//Reset bit
ResetBit (b_value);
//print current and saved value
printf ("Current value: %d\r\n, Saved value: %d\r\n",b_value, b_saved);
...
}
See also
Device-based dependency of system functions (Page 2865)
ResetBitInTag (Page 2904)
ResetBitInTag
Description
Sets a bit in the specified tag to 0 (FALSE).
After changing the given bit, the system function transfers the entire tag back to the PLC. It is
not checked whether other bits in the tags have changed in the meantime. Operator and PLC
have read-only access to the indicated tag until it is transferred back to the PLC.
Note
If the PLC supports BOOL tags, do not use this system function. Use the "ResetBit" system
function instead.
Use in the function list
ResetBitInTag (Tag, Bit)
Use in user-defined functions
ResetBitInTag (Tag, Bit)
Can be used if the configured device supports user-defined functions. For additional
information, refer to "Device dependency".
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
2904 System Manual, 01/2013,
Parameters
Tag
The tag in which a bit is set to 0 (FALSE).
Bit
The number of the bit that is set to 0 (FALSE).
When this system function is used in a user-defined function, the bits in the specified tag will
be counted from right to left independent of the PLC used. The counting begins with 0.
Example
The following program code sets a bit at the specified bitposition in the bvalue tag to 0 and
outputs the result along with the original bsaved value.
{
BYTE bvalue;
BYTE bsaved = bvalue;
BYTE bitposition = 2;
//Reset bit in bitposition
ResetBitInTag (bvalue, bitposition);
//print current and saved value
printf ("Current value: %d\r\n, Saved value: %d\r\n",bvalue, bsaved);
...
}
See also
Device-based dependency of system functions (Page 2865)
ResetBit (Page 2903)
PressButton
Description
The system function can only be configured on the function keys of an HMI device and triggers
the "Press key" event at the specified screen object.
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
System Manual, 01/2013, 2905
Use this system function when you want to operate a button in a screen with a function key of
the HMI device, for example.
Note
The "PressButton" and "ReleaseButton" system functions must always be configured
together. If you configure the "PressButton" system function on the "Press key" event for a
function key, the "ReleaseButton" system function is configured on the "Release" event for
the same function key.
Use in the function list
PressButton (Screen object)
Use in user-defined functions
-
Parameters
Screen object
Name of the screen object on which the event is triggered.
ReleaseButton
Description
The system function can only be configured on the function keys of an HMI device and triggers
the "Release button" event at the specified screen object.
Use this system function when you want to operate a button in a screen with a function key of
the HMI device, for example.
Note
The "PressButton" and "ReleaseButton" system functions must always be configured
together. If you configure the "PressButton" system function on the "Press key" event for a
function key, then the "ReleaseButton" system function is configured on the "Release key"
event for the same function key.
Use in the function list
ReleaseButton (Screen object)
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
2906 System Manual, 01/2013,
Use in user-defined functions
-
Parameters
Screen object
Name of the screen object on which the event is triggered.
ShiftAndMask
Description
This system function converts the input bit pattern of the source tags into an output bit pattern
of the target tags. This involves bit shifting and masking.
Note
If the source and target tag have a different number of bits, using the system function in the
target tag can result in a violation of the value range.
Use in the function list
ShiftAndMask (Source tag, Target tag, Bits to shift, Bits to mask)
Use in user-defined functions
ShiftAndMask (Source_tag, Target_tag, Bits_to_shift, Bits_to_mask)
Can be used if the configured device supports user-defined functions. For additional
information, refer to "Device dependency".
Parameter
Source tag
The tag includes the input bit pattern. Integer-type tags, e.g. "Byte", "Char", "Int", "UInt", "Long"
and "ULong" are permitted.
Example: The actual value 72 is set at the 16-bit integer source tag: 0000000001001000.
Target tag
The output bit pattern is saved in the tag. Integer type tags, e.g. "Byte", "Char", "Int", "UInt",
"Long" and "ULong" are permitted.
Example: The shifted input bit pattern is multiplied by the bit mask, with bit-by-bit logical AND
operation: 0000000000001001. The resultant decimal value "8" is saved to the target tag.
Please note the following:
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
System Manual, 01/2013, 2907
The source and target tags have the same number of bits.
The number of bits to shift is less than the number of bits in the source tag and target tag.
Bits to mask does not have more bits than the source tag and the target tag.
Bits to shift
Number of bits by which the input bit pattern is shifted right. A negative value shifts the input
bit pattern to the left.
Example: "Bits to shift" has the value "+3". The input bit pattern is shifted right by three bits
when the system function is called: 0000000000001001.
Bits to the left are padded with "0". Three bits are truncated on the right. The new decimal
value is "9".
Note
The left bit is "1" in a source tag of the data type with negative signed integer. This sign bit
is padded with "0" when the bits are shifted right. The sign changes to "+".
Bits to mask
An integer serves as bit mask. The bit pattern is used to multiply the shifted input bit pattern.
Example: Integer "2478" with the bit pattern "0000100110101110".
You can enter the bit mask in three different ways:
Hexadecimal: First enter the prefix "0h" or "0H", followed by an optional space for better
readability. Then group the bit pattern in blocks of four (0000)(1001)(1010)(1110) and set
each block in hexadecimal code: (0)(9)(A)(E). Only the characters 0-9, A-F, a-f are allowed:
"0h 09AE".
Binary: First enter the prefix "0b" or "0B", followed by an optional space for better readability.
Then group the binary bit pattern into blocks of four 0000 1001 1010 1110 with spaces in
between as a check. Only the characters "0" or "1" are allowed: "0b 0000 1001 1010 1110".
Decimal: Enter the value "2478" directly, without a prefix.
See also
Device-based dependency of system functions (Page 2865)
PageUp
Description
Executes the key function <PageUp> on the HMI device.
This system function can only be used for function keys and tasks with a time trigger.
Use in the function list
PageUp
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
2908 System Manual, 01/2013,
Use in user-defined functions
PageUp
Can be used if the configured device supports user-defined functions. For additional
information, refer to "Device dependency".
Parameter
-
See also
Device-based dependency of system functions (Page 2865)
PageDown
Description
Executes the key function <Pagedown> on the HMI device.
This system function can only be used for function keys.
Use in the function list
PageDown
Use in user-defined functions
PageDown
Can be used if the configured device supports user-defined functions. For additional
information, refer to "Device dependency".
Parameter
-
See also
Device-based dependency of system functions (Page 2865)
SetDeviceMode
Description
Toggles the operating mode on the HMI device. The following types of operation are possible:
"Online", "Offline" and "Load".
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
System Manual, 01/2013, 2909
Use in the function list
SetDeviceMode (Operating mode)
Use in user-defined functions
SetDeviceMode (Operating_mode)
Can be used if the configured device supports user-defined functions. For additional
information, refer to "Device dependency".
Parameter
Operating mode
Determines the operating mode of the HMI device:
0 (hmiOnline) = Online: The connection to the PLC is established.
1 (hmiOffline) = Offline: The connection to the PLC is disconnected.
2 (hmiTransfer) = load: A project can be transferred from the configuration computer to the
HMI device.
Note
If you use a PC as an HMI device, the runtime software will be exited when you change
operating mode after "Load".
See also
Device-based dependency of system functions (Page 2865)
SetConnectionMode (Page 2918)
SetBit
Description
Sets the value of a "Bool" type tag to 1 (TRUE).
Use in the function list
SetBit (Tag)
Use in user-defined functions
SetBit (Tag)
Can be used if the configured device supports user-defined functions. For additional
information, refer to "Device dependency".
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
2910 System Manual, 01/2013,
Parameters
Tag
The BOOL type tag which is set to 1 (TRUE).
Example
The following program code sets the value of the boolean tag b_value to 1 by means of the
SetBit function and outputs the result along with the original b_saved value.
{
BOOL b_value = 0;
BOOL b_saved = b_value;
//Set bit
SetBit (b_value);
//print current and saved value
printf ("Current value: %d\r\n, Saved value: %d\r\n",b_value, b_saved);
...
}
See also
Device-based dependency of system functions (Page 2865)
SetBitInTag
Description
Sets a bit in the given tag to 1 (TRUE).
After changing the given bit, the system function transfers the entire tag back to the PLC. It is
not checked whether other bits in the tags have changed in the meantime. Operator and PLC
have read-only access to the indicated tag until it is transferred back to the PLC.
Note
If the PLC supports BOOL tags, do not use this system function. Use the "SetBit" system
function instead.
Use in the function list
SetBitInTag (Tag, Bit)
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
System Manual, 01/2013, 2911
Use in user-defined functions
SetBitInTag(Tag, Bit)
Can be used if the configured device supports user-defined functions. For additional
information, refer to "Device dependency".
Parameters
Tag
The tag in which a bit is set to 1 (TRUE).
Bit
The number of the bit that is set to 1 (TRUE).
When this system function is used in a user-defined function, the bits in the specified tag will
be counted from right to left independent of the PLC used. The counting begins with 0.
Note
The guaranteed update of the tags used with actual process values is absolutely conditional
in terms of reliable functionality. You should therefore configure the tag in an I/O field or assign
the system function to a screen object, such as a button.
If you have configured a short event such as the activation of an alarm for the system function
you can only access the actual process values by setting the tag for continuous reading.
Example
The following program code sets a bit to 1 at the specified bitposition in the bvalue tag and
outputs the result along with the original bsaved value.
{
BYTE bvalue;
BYTE bsaved = bvalue;
BYTE bitposition = 2;
//Reset bit in bitposition
SetBitInTag (bvalue, bitposition);
//print current and saved value
printf ("Current value: %d\r\n, Saved value: %d\r\n",bvalue, bsaved);
...
}
See also
Device-based dependency of system functions (Page 2865)
SetBit (Page 2910)
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
2912 System Manual, 01/2013,
SetBitWhileKeyPressed
Description
Sets the bit of the given tag to 1 (TRUE) as long as the user keeps the configured key pressed.
After changing the given bit, the system function transfers the entire tag back to the PLC. It is
not checked whether other bits in the tags have changed in the meantime. Operator and PLC
have read-only access to the indicated tag until it is transferred back to the PLC. You should
only access tags of the BOOL type with this system function to avoid problems with overlapping
access to the same tag.
Note
All functions on the event "Release" are performed immediately by means of a screen change
configured for a key, even if the key is kept pressed.
If the "SetBitWhileKeyPressed" system function is configured for a function key, the bit will
be reset immediately following a screen change. This action is necessary since the key
assignments change after the screen change.
If the PLC supports BOOL tags, do not use this system function. Use the "SetBit" system
function instead.
Use in the function list
SetBitWhileKeyPressed (Tag, Bit)
Use in user-defined functions
-
Parameters
Tag
The tag in which a bit is temporarily set to 1 (TRUE). Use only tags of the type BOOL, as far
as allowed by the PLC.
Bit
The number of the bit that is temporarily set to 1 (TRUE).
Note
The guaranteed update of the tags used with actual process values is absolutely conditional
in terms of reliable functionality. You should therefore configure the tag in an IO field, or assign
the function to a screen element such as a button.
If you configured a short event such as the activation of an alarm for the function you can
only access the actual process values by setting the tag for continuous reading.
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
System Manual, 01/2013, 2913
See also
SetBit (Page 2910)
Device-based dependency of system functions (Page 2865)
SetColorBackgroundLighting
Description
Defines the background lighting of the button.
Note
The configuration that was set at Switch off is reestablished when restarting the HMI device.
Use in the function list
SetBacklightcolour (Value)
Use in user-defined functions
-
Parameters
Value
Defines the background lighting of the button:
0 (hmiWhite) = White: No color
1 (hmiGreen) = Green: Green color
2 (hmiYellow) = Yellow: Yellow color
3 (hmiRed) = Red: Red color
SetPLCDateTime
Description
Changes the data and the time of the linked PLC
The system function "ReadPLCDateTime" can only be configured for the following PLCs:
SIMATIC S7 1200
SIMATIC S7 1500
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
2914 System Manual, 01/2013,
Use in the function list
ReadPLCDateTime (connection, time)
Use in user-defined functions
GetPLCDateTime (Connection, Time)
Parameters
Connection
Connection of PLC and HMI device.
Time
Transfers the date and the time of the HMI device to the PLC. The PLC applies the date and
the time of the HMI device.
SetPLCMode
Description
Switches the operating mode of the PLC to one of the following states:
RUN
STOP
The system function "SetPLCMode" can only be configured for the following PLCs:
SIMATIC S7 1200
SIMATIC S7 1500
Use in the function list
SetPLCMode (connection, mode)
Use in user-defined functions
SetPLCMode (Connection, Mode)
Parameters
Connection
Connection of PLC and HMI device.
Mode
Specifies the operating mode of the PLC:
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
System Manual, 01/2013, 2915
RUN = the PLC is switched to the RUN state. The PLC program is executed.
STOP = the PLC is switched to the STOP state. The PLC program is interrupted.
SetLanguage
Description
Toggles the language on the HMI device. All configured text and system events are displayed
on the HMI device in the newly set language.
Use in the function list
SetLanguage (Language)
Use in user-defined functions
SetLanguage (Language)
Can be used if the configured device supports user-defined functions. For additional
information, refer to "Device dependency".
Parameter
Language
Determines which language is set on the HMI device. The following specifications are possible:
-1 (hmiToggle) = Toggle: Changes to the next language. The sequence is determined
during configuration in the "Project languages" editor.
Number you have defined under "Languages and fonts" in the "Runtime Settings" editor.
Changes to the language with the given number.
Language you have defined under "Languages and fonts" in the "Runtime Settings" editor.
Language abbreviation in accordance with the VBScript5 reference: This changes to the
language corresponding to the specified language code, e.g. "de-DE" for German
(Germany) or "en-US" for English (United States).
An overview of the language abbreviations is available in the basic information of VBScript
under the topic "Area diagram-ID (LCID) Diagram".
See also
Device-based dependency of system functions (Page 2865)
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
2916 System Manual, 01/2013,
SetTag
Description
Assigns a new value to the given tag.
Note
This system function can be used to assign strings and numbers, depending on the type of
tag.
Use in the function list
SetTag (Tag, Value)
Use in user-defined functions
SetTag (Tag, Value)
Can be used if the configured device supports user-defined functions. For additional
information, refer to "Device dependency".
Parameters
Tag
The tag to which the given value is assigned.
Value
The value which the given tag is assigned.
Note
The "SetTag" system function is only executed after a connection has been established.
Example
The following program code uses the SetTag function to set the value of the gs_tag_bit tag to
TRUE and saves the return value to the ok tag.
{
BOOL ok;
BOOL bvalue;
//Set the tag to true
ok = SetTag("gs_tag_bit", TRUE);
//error handling
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
System Manual, 01/2013, 2917
if(ok)
{
// succeeded
printf ( "Function has run through.\r\n" );
bvalue = GetTagBit("gs_tag_bit");
printf ("Value of gs_tag_bit: %d\r\n", bvalue);
}
else
{
// failed
printf ( "Error - function failed." );
}
...
}
The saved return value can be processed in the following code.
See also
Device-based dependency of system functions (Page 2865)
IncreaseTag (Page 2878)
SetConnectionMode
Description
Connects or disconnects the given connection.
Note
A connection to the PLC cannot be established until the operating mode ONLINE has been
set on the HMI device. Use the "SetDeviceMode" system function for this purpose.
Use in the function list
SetConnectionMode (Mode, Connection)
Use in user-defined functions
SetConnectionMode (Mode, Connection)
Can be used if the configured device supports user-defined functions. For additional
information, refer to "Device dependency".
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
2918 System Manual, 01/2013,
Parameter
Mode
Determines whether a connection to the PLC is established or disconnected:
0 (hmiOnline) = Online: Connection is established.
1 (hmiOffline) = Offline: Connection is disconnected.
Connection
The PLC to which the HMI device is connected. You specify the name of the PLC in the
connection editor.
Multiple use of the system function in a user-defined function
If you use the "SetConnectionMode" system function for different connections, it may be
possible that not all system functions are executed correctly. Proceed as follows to prevent
this situation:
1. Create a "BOOL" type tag with the start value "0".
2. Configure the "SetConnectionMode" system function on the "Value change" event of the
HMI tags. If you want to disconnect three connections, for example, you must configure the
system function three times.
3. In the user-defined function, apply the "InvertBit" system function to the HMI tag.
Application example
Two typical application examples for this system function are as follows:
Test
As long as no PLC is connected to the HMI device, no error messages will be output during
the test on the HMI device. If the HMI device is connected to a PLC, the connection to the
PLC can be established by pressing a key.
Commissioning
Several PLCs are to be configured for a system. At first, all PLCs except one are configured
"Offline". After commissioning of the first PLC, the connection to each of the other PLCs is
established by pressing a key. In this way, the other PLCs are started up one after another.
See also
Device-based dependency of system functions (Page 2865)
SetDeviceMode (Page 2909)
SimulateSystemKey
Description
Simulates the behavior of a System Key. Use this system function if a system key, such as
the "ACK" key, "Input" key or the number pad is not available on the HMI device.
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
System Manual, 01/2013, 2919
Use in the function list
SimulateSystemKey (System key)
Use in user-defined functions
-
Parameters
System key
System Key, the behavior for which is to be simulated.
System key "+/-"
With the SimulateSystemKey system function, the system key "+/-" is only supported for the
following HMI devices:
KP300 Basic
KP400 Basic
KTP400 Basic mono PN
KTP600 Basic mono PN
KTP600 Basic color PN
KTP600 Basic color DP
KTP1000 Basic PN
KTP1000 Basic DP
Use the system keys "+" and "-" separately for all other HMI devices.
SimulateTag
Description
Simulates the behavior of tags and dynamic objects such as text lists, without having the HMI
device connected to a PLC. You can, for example, configure the system function to the
"Loaded" event of a screen.
This system function is used, for example, to demonstrate the functionality of a project.
Only tags of the data type Integer can be used for simulation. Tags of the data types Integer
and Double Integer, however, can be used with OP 73, OP 77A, TP 177A.
Note
If you use the system function "SimulateTag" with a short cycle time on a Basic Panel, the
HMI device may be overloaded.
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
2920 System Manual, 01/2013,
Use in the function list
SimulateTag (Tag, Cycle, Maximum value, Minimum value, Value)
Use in user-defined functions
-
Parameter
Tag
The tag whose value is changed.
Cycle
The factor by which the basic cycle of 200 milliseconds is multiplied. The cycle defines when
the tag value is changed by the specified value. Possible cycles between 1 and 32767.
Maximum value
The maximum value that the tag can assume during simulation. The maximum value must be
greater than the minimum value but less than / equal to 32767.
Minimum value
The minimum value that the tag can assume during simulation. The minimum value must be
greater than the maximum value but less than / equal to -32768.
Value
The value by which the tag value is changed during each cycle. Possible values between
-32768 and 32767.
A positive value increases the tag value. When the maximum value is reached, the tag
value is set to the minimum value after the next update cycle.
A negative value reduces the tag value. When the minimum value is reached, the tag value
is set to the maximum value after the next update cycle.
StopRuntime
Description
Exits the runtime software and thereby the project running on the HMI device.
Use in the function list
StopRuntime (Mode)
Use in user-defined functions
StopRuntime (Mode)
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
System Manual, 01/2013, 2921
Can be used if the configured device supports user-defined functions. For additional
information, refer to "Device dependency".
Parameters
Mode
Determines whether the operating system is shut down after exiting runtime.
0 (hmiStopRuntime) = Runtime: Operating system is not shut down
1 (hmiStopRuntimeAndOperatingSystem) = Runtime and operating system: The operating
system is shut down (not possible with WinCE)
Example
The following program code shuts down Runtime and the operating system.
{
//Stop runtime and shutdown
StopRuntime (hmiStopRuntimeAndOperationSystem);
}
The saved return value can be processed in the following code.
See also
Device-based dependency of system functions (Page 2865)
TraceUserChange
Description
Outputs a system event that shows which user is currently logged in on the HMI device.
This system function can only be used in the Scheduler.
Use in the function list
TraceUserChange
Use in user-defined functions
-
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
2922 System Manual, 01/2013,
Parameters
--
DecreaseFocusedValue
Description
Subtracts the specified value from the value of the tag which is connected to the screen object
and currently has the focus.
This system function can only be used for function keys.
Use in the function list
DecreaseFocusedValue (Value)
Use in user-defined functions
-
Parameters
Value
The value which is subtracted from the tag value.
DecreaseTag
Description
Subtracts the given value from the tag value.
X = X - a
Note
The system function uses the same tag as input and output values. When this system function
is used to convert a value, auxiliary tags must be used. The auxiliary tags are assigned to
the tag value with the "SetTag" system function.
If you configure the system function on the events of an alarm and the tag is not being used
in the current screen, it is not ensured that the actual value of the tags is being used in the
PLC. You can improve the situation by setting the "Cyclic continuous" acquisition mode.
Use in the function list
DecreaseTag (Tag, Value)
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
System Manual, 01/2013, 2923
Use in user-defined functions
DecreaseTag (Tag, Value)
Can be used if the configured device supports user-defined functions. For additional
information, refer to "Device dependency".
Parameter
Tag
The tag from which the given value is subtracted.
Value
The value which is subtracted.
See also
Device-based dependency of system functions (Page 2865)
ChangeConnection
Description
Disconnects the connection to the currently used PLC in use and establishes a connection to
a PLC with another address. The newly connected PLC must belong to the same device class
(S7-1200, S7-300, ...etc). With S7-1200, the use of the function is also only permitted for
absolute addressing.
Note
When changing to another address, ensure that the address is not already being used by
another HMI device.
The follows address types are supported:
IP address
MPI address
The follows PLC types are supported:
SIMATIC S7 1200
SIMATIC S7 300/400
SIMATIC S7-NC
SIMOTION
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
2924 System Manual, 01/2013,
Use in the function list
ChangeConnection (Connection, Address, Slot, Rack)
Use in user-defined functions
ChangeConnection (Connection, Address, Slot, Rack)
Can be used if the configured device supports user-defined functions. For additional
information, refer to "Device dependency".
Parameter
Connection
Name of the connection that is disconnected. The name is set during configuration, for
example, in the "Connections" editor.
Address
MPI/PROFIBUS or IP address of the PLC to which the connection will be established.
Note
Set the address by means of a tag. The objects list displays the tags of all data types. Select
only tags of the following data types:
Ethernet connection: "String" data type
MPI connection: "Int" data type
Slot
Slot of the PLC to which the connection will be established.
Rack
Rack of the PLC to which the connection will be established.
Application example
You want to operate one HMI device on several machines. Configure the necessary PLCs in
the project, to which you want to change by pressing a key. When changing the PLC, the
connection to the PLC in use is disconnected. Then the connection to the new PLC with other
address parameters is reestablished. To access the values of the new PLC, configure the
same tags for the PLC used.
The PLC which you have indicated when creating the project will be used as default.
1. Enter the name and address of the PLC in the "Connections" editor.
2. Configure a button in the process screen.
3. Configure the "ChangeConnection" system function on the "Press" event.
4. Enter the name of the connection and address of the PLC as parameters.
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
System Manual, 01/2013, 2925
See also
Device-based dependency of system functions (Page 2865)
ShowLogonDialog
Description
Opens a dialog on the HMI device with which the user can log on to the HMI device.
Use in the function list
ShowLogonDialog
Use in user-defined functions
-
Parameters
--
ShowOperatorNotes
Application
Displays the tooltip configured for the selected object.
If the system function is configured on a function key, the tooltip for the screen object that
currently has the focus is displayed. If a tooltip is configured for the screen itself, you can switch
to this text by pressing <Enter> or by double-clicking on the help window.
If the system function is configured on a button, only the tooltip for the current screen is
displayed. If a tooltip is configured on the button itself, initially only the tooltip for the button is
displayed. You can press <Enter> or double-click on the help window to switch to the tooltip
for the current screen.
Note
No other screen object can be used while the help window is open. To use the screen object,
close the help window.
Closing the help window
You can close the help window in the following ways:
Using the keys:
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
2926 System Manual, 01/2013,
By pressing the <HELP> key again
By pressing the <ESC> key
Using the touch screen:
By pressing the button
Use in the function list
ShowOperatorNotes (Layout)
Use in user-defined functions
ShowOperatorNotes (Display_mode)
Can be used if the configured device supports user-defined functions. For additional
information, refer to "Device dependency".
Parameter
Layout
Determines whether the configured tooltip is hidden or shown:
0 (hmiOff) = Off: Configured tooltip is hidden
1 (hmiOn) = On: Configured tooltip is shown
-1 (hmiToggle) = Toggle: Toggles between the two modes
See also
Device-based dependency of system functions (Page 2865)
ShowAlarmWindow
Description
Hides or shows the alarm window on the HMI device.
Use in the function list
ShowAlarmWindow (Object name, Layout)
Use in user-defined functions
ShowAlarmWindow (Object_name, Display_mode)
Can be used if the configured device supports user-defined functions. For additional
information, refer to "Device dependency".
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
System Manual, 01/2013, 2927
Parameter
Object name
Name of the alarm view which is hidden or shown.
Layout
Determines whether the alarm window is hidden or shown:
0 (hmiOff) = Off: Alarm view is hidden
1 (hmiOn) = On: Alarm view is shown
-1 (hmiToggle) = Toggle: Toggles between the two modes
See also
Device-based dependency of system functions (Page 2865)
10.6.4.2 Events
Overview
Editors
Introduction
The following table shows which events occur in which editor.
Technical data subject to change.
Icon Editor
Screens
HMI alarms
HMI tags
Scheduler
1 Cleared (Page 2933) X -- -- --
2 Activate (Page 2934) -- -- -- --
3 Change (Page 2934) -- -- -- --
4 Loaded (Page 2934) X -- -- --
5 Execute (Page 2935) -- -- -- X
6 Selection changed (Page 2935) -- -- -- --
7 In the event of high limit violation (Page 2935) -- -- X --
8 In the event of low limit violation (Page 2935) -- -- X --
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
2928 System Manual, 01/2013,
9 When dialog is opened (Page 2936) -- -- -- X
10 When dialog is closed (Page 2936) -- -- -- X
11 User change (Page 2936) -- -- -- X
12 Screen change (Page 2936) -- -- -- X
13 Deactivate (Page 2937) -- -- -- X
14 Double-click (Page 2937) -- -- -- --
15 Press (Page 2938) -- -- -- --
16 On Finish Input (Page 2938) -- -- -- --
17 Press ESC twice (Page 2938) -- -- -- --
18 Outgoing (Page 2939) -- X -- --
19 Incoming (Page 2939) -- X -- --
20 Click (Page 2939) -- -- -- --
21 Click when flashing (Page 2940) -- -- -- --
22 Loop-in alarm (Page 2940) -- X -- --
23 Release (Page 2940) -- -- -- --
24 Alarm buffer overflow (Page 2941) -- -- -- X
25 Acknowledge (Page 2941) -- X -- --
26 Reach margin (Page 2941) -- -- -- --
27 Runtime Stop (Page 2942) -- -- -- X
28 Press key (Page 2942) -- -- -- --
29 Release key (Page 2942) -- -- -- --
30 Overflow (Page 2943) -- -- -- --
31 Switch OFF (Page 2943) -- -- -- --
32 Switch ON (Page 2943) -- -- -- --
33 Low free storage space (Page 2943) -- -- -- --
34 Free space critically low (Page 2944) -- -- -- --
35 Value change (Page 2944) -- -- X --
36 Time expired (Page 2944) -- -- -- --
Basic objects
Introduction
The following table shows which events occur on which objects.
Technical data subject to change.
Icon Object
Line
Ellipse
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
System Manual, 01/2013, 2929
Icon Object
Circle
Rectangle
Text field
Graphic view
1 Cleared (Page 2933) -- -- -- -- -- --
2 Activate (Page 2934) -- -- -- -- -- --
3 Change (Page 2934) -- -- -- -- -- --
4 Loaded (Page 2934) -- -- -- -- -- --
5 Execute (Page 2935) -- -- -- -- -- --
6 Selection changed (Page 2935) -- -- -- -- -- --
7 In the event of high limit violation (Page 2935) -- -- -- -- -- --
8 In the event of low limit violation (Page 2935) -- -- -- -- -- --
9 When dialog is opened (Page 2936) -- -- -- -- -- --
10 When dialog is closed (Page 2936) -- -- -- -- -- --
11 User change (Page 2936) -- -- -- -- -- --
12 Screen change (Page 2936) -- -- -- -- -- --
13 Deactivate (Page 2937) -- -- -- -- -- --
14 Double-click (Page 2937) -- -- -- -- -- --
15 Press (Page 2938) -- -- -- -- -- --
16 On Finish Input (Page 2938) -- -- -- -- -- --
17 Press ESC twice (Page 2938) -- -- -- -- -- --
18 Outgoing (Page 2939) -- -- -- -- -- --
19 Incoming (Page 2939) -- -- -- -- -- --
20 Click (Page 2939) -- -- -- -- -- --
21 Click when flashing (Page 2940) -- -- -- -- -- --
22 Loop-in alarm (Page 2940) -- -- -- -- -- --
23 Release (Page 2940) -- -- -- -- -- --
24 Alarm buffer overflow (Page 2941) -- -- -- -- -- --
25 Acknowledge (Page 2941) -- -- -- -- -- --
26 Reach margin (Page 2941) -- -- -- -- -- --
27 Runtime Stop (Page 2942) -- -- -- -- -- --
28 Press key (Page 2942) -- -- -- -- -- --
29 Release key (Page 2942) -- -- -- -- -- --
30 Overflow (Page 2943) -- -- -- -- -- --
31 Switch OFF (Page 2943) -- -- -- -- -- --
32 Switch ON (Page 2943) -- -- -- -- -- --
33 Low free storage space (Page 2943) -- -- -- -- -- --
34 Free space critically low (Page 2944) -- -- -- -- -- --
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
2930 System Manual, 01/2013,
35 Value change (Page 2944) -- -- -- -- -- --
36 Time expired (Page 2944) -- -- -- -- -- --
Elements
Introduction
The following table shows which events occur on which objects.
Technical data subject to change.
Icon Object
IO field
Button
Symbolic IO field
Graphic IO field
Date/time field
Bar
Switch
1 Cleared (Page 2933) -- -- -- -- -- -- --
2 Activate (Page 2934) X X X X -- -- X
3 Change (Page 2934) -- X X -- -- -- X
4 Loaded (Page 2934) -- -- -- -- -- -- --
5 Execute (Page 2935) -- -- -- -- -- -- --
6 Selection changed (Page 2935) -- -- -- -- -- -- --
7 In the event of high limit violation (Page 2935) -- -- -- -- -- -- --
8 In the event of low limit violation (Page 2935) -- -- -- -- -- -- --
9 When dialog is opened (Page 2936) -- -- -- -- -- -- --
10 When dialog is closed (Page 2936) -- -- -- -- -- -- --
11 User change (Page 2936) -- -- -- -- -- -- --
12 Screen change (Page 2936) -- -- -- -- -- -- --
13 Deactivate (Page 2937) X X X X -- -- X
14 Double-click (Page 2937) -- -- -- -- -- -- --
15 Press (Page 2938) -- X -- -- -- -- --
16 On Finish Input (Page 2938) -- -- -- -- -- -- --
17 Press ESC twice (Page 2938) -- -- -- -- -- -- --
18 Outgoing (Page 2939) -- -- -- -- -- -- --
19 Incoming (Page 2939) -- -- -- -- -- -- --
20 Click (Page 2939) -- X -- -- -- -- --
21 Click when flashing (Page 2940) -- -- -- -- -- -- --
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
System Manual, 01/2013, 2931
22 Loop-in alarm (Page 2940) -- -- -- -- -- -- --
23 Release (Page 2940) -- X -- -- -- -- --
24 Alarm buffer overflow (Page 2941) -- -- -- -- -- -- --
25 Acknowledge (Page 2941) -- -- -- -- -- -- --
26 Reach margin (Page 2941) -- -- -- -- -- -- --
27 Runtime Stop (Page 2942) -- -- -- -- -- -- --
28 Press key (Page 2942) -- -- -- -- -- -- --
29 Release key (Page 2942) -- -- -- -- -- -- --
30 Overflow (Page 2943) -- -- -- -- -- -- --
31 Switch OFF (Page 2943) -- -- -- -- -- -- X
32 Switch ON (Page 2943) -- -- -- -- -- -- X
33 Low free storage space (Page 2943) -- -- -- -- -- -- --
34 Free space critically low (Page 2944) -- -- -- -- -- -- --
35 Value change (Page 2944) -- -- -- -- -- -- --
36 Time expired (Page 2944) -- -- -- -- -- -- --
Controls
Introduction
The following table shows which events occur on which objects.
Technical data subject to change.
Icon Object
Alarm view/alarm window
Alarm indicator
Trend view
User view
Recipe view
Auxiliary indicator
1 Cleared (Page 2933) -- -- -- -- -- --
2 Activate (Page 2934) X -- X X -- --
3 Change (Page 2934) -- -- -- -- -- --
4 Loaded (Page 2934) -- -- -- -- -- --
5 Execute (Page 2935) -- -- -- -- -- --
6 Selection changed (Page 2935) -- -- -- -- -- --
7 In the event of high limit violation (Page 2935) -- -- -- -- -- --
8 In the event of low limit violation (Page 2935) -- -- -- -- -- --
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
2932 System Manual, 01/2013,
9 When dialog is opened (Page 2936) -- -- -- -- -- --
10 When dialog is closed (Page 2936) -- -- -- -- -- --
11 User change (Page 2936) -- -- -- -- -- --
12 Screen change (Page 2936) -- -- -- -- -- --
13 Deactivate (Page 2937) X -- X X -- --
14 Double-click (Page 2937) -- -- -- -- -- --
15 Press (Page 2938) -- -- -- -- -- --
16 On Finish Input (Page 2938) -- -- -- -- -- --
17 Press ESC twice (Page 2938) -- -- -- -- -- --
18 Outgoing (Page 2939) -- -- -- -- -- --
19 Incoming (Page 2939)
20 Click (Page 2939) -- X -- -- -- --
21 Click when flashing (Page 2940) -- X -- -- -- --
22 Loop-in alarm (Page 2940) -- -- -- -- -- --
23 Release (Page 2940) -- -- -- -- -- --
24 Alarm buffer overflow (Page 2941) -- -- -- -- -- --
25 Acknowledge (Page 2941) -- -- -- -- -- --
26 Reach margin (Page 2941) -- -- -- -- -- --
27 Runtime Stop (Page 2942) -- -- -- -- -- --
28 Press key (Page 2942) -- -- -- -- -- --
29 Release key (Page 2942) -- -- -- -- -- --
30 Overflow (Page 2943) -- -- -- -- -- --
31 Switch OFF (Page 2943) -- -- -- -- -- --
32 Switch ON (Page 2943) -- -- -- -- -- --
33 Low free storage space (Page 2943) -- -- -- -- -- --
34 Free space critically low (Page 2944) -- -- -- -- -- --
35 Value change (Page 2944) -- -- -- -- -- --
36 Time expired (Page 2944) -- -- -- -- -- --
Events
Cleared
Description
Occurs when the active screen on the HMI device is cleared.
Note
Please note that the availability of the event is dependent upon the HMI device and object
type.
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
System Manual, 01/2013, 2933
Activate
Description
Occurs when the user selects a display or operating object using the configured tab
sequence.
Note
Note that the availability of the event depends on the HMI device and object type.
Note
If the user e.g. clicks a button with the mouse, the "Click" event is triggered. Users wishing
to trigger the "Enable" event must select the button using the tab key.
The "Enable" event is only used to detect whether an object was selected. The event does not
trigger a password prompt.
For this reason, do not use the "Enable" event if you want to configure access protection on
the function call of the object.
Change
Description
Occurs if the status of a display and operator control object changes.
The status of an object changes if, for example, the user presses the key.
Note
Note that the availability of the event depends on the HMI device and object type.
Loaded
Description
Occurs when all configured display and operating objects are loaded in the active screen after
a screen change.
Note
Please note that the availability of the event is dependent upon the HMI device and object
type.
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
2934 System Manual, 01/2013,
Note
Enable a screen change to ensure that the connection with the control is established after
switch-on.
Execute
Description
Occurs when the scheduled task has been executed.
Selection changed
Description
Occurs when the user changes the selection.
Note
Please note that the availability of the event is dependent upon the HMI device and object
type.
In the event of high limit violation
Description
Occurs when the high limit of a tag is exceeded.
Note
Note that the availability of the event depends on the HMI device and object type.
In the event of low limit violation
Description
Occurs when the low limit of a tag is undershot.
Note
Note that the availability of the event depends on the HMI device and object type.
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
System Manual, 01/2013, 2935
When dialog is opened
Description
The event is triggered when a modal dialog opens.
Note
Please note that the availability of the event depends on the HMI device and object type.
When dialog is closed
Description
The event is triggered when a modal dialog closes.
Note
Please note that the availability of the event depends on the HMI device and object type.
User change
Description
Occurs when a user logs off at an HMI device or another user logs on at the HMI device.
Note
Please note that the availability of the event is dependent upon the HMI device and object
type.
Screen change
Description
Occurs when all configured display and operating objects are loaded in the screen after a
screen change.
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
2936 System Manual, 01/2013,
Use the "Loaded" event if you want to perform other system functions during a screen change
to a certain screen.
Note
Please note that the availability of the event is dependent upon the HMI device and object
type.
Deactivate
Description
Occurs when the user takes the focus from a display and operating object.
A screen object can be disabled using the configured tab order or by performing another action
with the mouse.
Note
Please note that the availability of the event is dependent upon the HMI device and object
type.
Note
System functions or user-defined functions on the "Deactivate" event of a screen are not
executed when a screen is being closed.
The "Deactivate" event is only used to detect whether an object was deselected. The event
does not trigger a password prompt.
For this reason, do not use the "Deactivate" event if you want to configure access protection
on the function call of the object.
Double-click
Description
Occurs when the user double-clicks on an object from the symbol library.
Note
Please note that the availability of the event is dependent upon the HMI device and object
type.
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
System Manual, 01/2013, 2937
Press
Description
Occurs when the user clicks on a button with the left mouse button, presses <RETURN> or
<SPACE>.
Also occurs when the user right-clicks on an object of the symbol library.
Note
Please note that the availability of the event is dependent upon the HMI device and object
type.
On Finish Input
Description
Triggered when you confirm input at an I/O field by pressing ENTER, or by mouse click, or by
touch screen operation.
The "On Finish Input" event is also started if the value of a tag does not change, for example,
if a value is exceeded, or if a user cancels the dialog to acknowledge a tag (Audit option
package) that has to be acknowledged.
The event is not triggered, on the other hand, by user logon or by input fields configured with
an authorization.
Note
Note that the availability of the event depends on the HMI device and object type.
Press ESC twice
Description
Occurs when the user presses the <ESC> key twice at the HMI device.
Note
Note that the availability of the event depends on the HMI device and object type.
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
2938 System Manual, 01/2013,
Outgoing
Description
Occurs when an alarm is deactivated.
Note
Please note that the availability of the event depends on the HMI device and object type.
Incoming
Description
Occurs when an alarm is triggered and displayed in the alarm view.
Note
Please note that the availability of the event depends on the HMI device and object type.
Click
Description
Occurs if the user clicks a display and operating object with the mouse or touches the touch
display with a finger.
In case you click the incorrect object, prevent processing of configured function list as follows:
Move the mouse pointer away from the object while keeping the mouse button pressed.
Release the mouse button as soon as the mouse pointer leaves the object. The function
list will then not be processed.
On touch displays, the display must be touched with the finger until a reaction occurs, e.g.,
a screen change.
Note
Please note that the availability of the event is dependent upon the HMI device and object
type.
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
System Manual, 01/2013, 2939
Click when flashing
Description
Occurs when the user clicks a flashing alarm indicator with the mouse or touches it with a
finger.
Note
Note that the availability of the event depends on the HMI device and object type.
Loop-in alarm
Description
Occurs as soon as the user selects an alarm in the alarm view and then clicks on the "Loop-
In-Alarm" button or double clicks on the alarm.
For the "Loop-In-Alarm" event, you configure system functions, such as a change to the screen
in which the alarm occurred.
You cannot configure local scripts for the "Loop-In-Alarm" event in Runtime Professional.
Note
Please note that the availability of the event is dependent upon the HMI device and object
type.
Release
Description
Occurs when the user releases a button.
This even does not occur, as long as the button remains pressed.
Note
Please note that the availability of the event is dependent upon the HMI device and object
type.
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
2940 System Manual, 01/2013,
Alarm buffer overflow
Description
Occurs when the configured size of the alarm buffer is reached.
Note
Please note that the availability of the event is dependent upon the HMI device and object
type.
Acknowledge
Description
Occurs when the user acknowledges an alarm.
Note
Please note that the availability of the event is dependent upon the HMI device and object
type.
Reach margin
Description
Occurs when the user reaches the beginning or the end of a scrollable area.
Note
Note that the availability of the event depends on the HMI device and object type.
Note
A user-defined function must not be configured for the "Boundary reached" event.
Configurable objects
The event can only be configured on the <Up> and <Down> keys, or on the keys on which
you have configured the "ScreenObjectPageUp" or "ScreenObjectPageDown" system
functions.
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
System Manual, 01/2013, 2941
Runtime Stop
Description
Occurs when the user exits the Runtime software on the HMI device.
Note
Please note that the availability of the event is dependent upon the HMI device and object
type.
Note
A user-defined function must not be configured for the "Runtime stop" event.
Press key
Description
Occurs when the user presses a function key.
Note
Please note that the availability of the event is dependent upon the HMI device and object
type.
Release key
Description
Occurs when the user releases a function key.
Note
Note that the availability of the event depends on the HMI device and object type.
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
2942 System Manual, 01/2013,
Overflow
Description
Occurs when the configured size of the log is reached. You use the log type "Trigger event".
Note
Please note that the availability of the event is dependent upon the HMI device and object
type.
Switch OFF
Description
Occurs when the user moves the display and operating object "Switch" to the OFF position.
Note
Note that the availability of the event depends on the HMI device and object type.
Switch ON
Description
Occurs when the user moves the display and operating object "Switch" to the ON position.
Note
Note that the availability of the event depends on the HMI device and object type.
Low free storage space
Description
This event is triggered if the storage space available on the medium to which the Audit Trail
is less than the configured minimum.
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
System Manual, 01/2013, 2943
Free space critically low
Description
This event is triggered if the storage medium to which an Audit Trail is saved provides
insufficient storage space due to hardware restrictions.
Value change
Description
Occurs when the value of an object or the value of an array element changes.
The value change of a tag is triggered by the PLC or by the user, e.g. when a new value is
entered.
Note
Please note that the availability of the event is dependent upon the HMI device and object
type.
Time expired
Description
Occurs when the time configured in the scheduler expires.
Note
Please note that the availability of the event is dependent upon the HMI device and object
type.
Visualizing processes (Basic)
10.6 Working with system functions
STEP 7 Basic V12.0
2944 System Manual, 01/2013,
10.7 Planning tasks
10.7.1 Field of application of the Scheduler
Definition
You can use the Scheduler to configure tasks to run independent of the screen in the
background. You create tasks by linking system functions or scripts to a trigger. The linked
functions will be called when the triggering event occurs.
Example of an application
The Scheduler is used to execute event-controlled tasks automatically. For example, you use
a task to automate the following:
Regular swap out of log data
Printout of an alarm report when an alarm buffer overflow occurs
Printout of a report at shift end
Monitoring a tag
Monitoring of a user change
Note
The availability of the listed examples is determined by the HMI device.
See also
Working with tasks and triggers (Page 2946)
Example: Update user following change of user (Page 2951)
Work area of the "Scheduler" editor (Page 2947)
Visualizing processes (Basic)
10.7 Planning tasks
STEP 7 Basic V12.0
System Manual, 01/2013, 2945
10.7.2 Working with tasks and triggers
Introduction
A task consists of a trigger and a task type.
Starting a task
Controlled by a trigger, the Scheduler starts the task linked to the trigger.
See also
Field of application of the Scheduler (Page 2945)
Visualizing processes (Basic)
10.7 Planning tasks
STEP 7 Basic V12.0
2946 System Manual, 01/2013,
10.7.3 Basics
10.7.3.1 Work area of the "Scheduler" editor
Introduction
Double-click on "Scheduler" to open it in the project view. The work area shows the scheduled
tasks, which consist of the trigger and the task type, for example, the function list.
Structure
The work area consists of the table of jobs.
The table of tasks shows specified tasks with their properties, such as triggers. You select a
task type and a trigger. You assign a name and a comment to the task. The description provides
a written summary of the task including the timing for the task.
Visualizing processes (Basic)
10.7 Planning tasks
STEP 7 Basic V12.0
System Manual, 01/2013, 2947
Inspector window
The "Properties" tab of the Inspector window is split into two parts.
The "Job" area lists the name of the job and the job type. The "Starting time" area shows the
trigger. The area is different depending on the trigger selected.
In the "Events" tab use the function list with system functions that will be executed in the task.
Note
You can obtain more detailed information about the elements of the user interface using the
tooltips. To do so, move the mouse pointer to the relevant object or press <F1> if the object
has already been selected.
See also
Field of application of the Scheduler (Page 2945)
Planning tasks with event triggers (Page 2949)
Triggers (Page 2948)
Function list (Page 2948)
10.7.3.2 Function list
Function list
A trigger starts the function list. The function list is executed line by line. Each line contains a
system function. You can configure exactly one function list for each task.
Note
The choice of configurable system functions in a function list depends on the selected trigger
and the HMI device.
See also
Work area of the "Scheduler" editor (Page 2947)
10.7.3.3 Triggers
Introduction
A trigger is linked to a task and forms the triggering event which will call this task. The task is
executed when the trigger occurs.
Visualizing processes (Basic)
10.7 Planning tasks
STEP 7 Basic V12.0
2948 System Manual, 01/2013,
Event trigger
When a task is linked to a system event, the task will be triggered by the event. System events
include, for example, Runtime stop, screen change, user change, etc.
Each system event can only be configured once for each HMI device.
Deactivating job
If you do not need a certain job temporarily, deactivate the job in the Engineering System. You
also use the trigger "Deactivated" to make a previously configured system event available once
again.
Example: Task "A" is planned with the system event "Shutdown". This system event is then
no longer available for another task "B". Select "Disabled" as the trigger for task "A" to make
the "Runtime stop" system event available again.
Note
The available triggers depend on the HMI device.
See also
Work area of the "Scheduler" editor (Page 2947)
10.7.3.4 Planning tasks with event triggers
Introduction
You plan a task that generates a screen change when the user changes.
Requirements
The "Scheduler" work area is open.
You have created the "Start" screen.
Procedure
1. Click "Add..." in the table of the task area.
2. Enter "Screen change at user change" as the "Name."
3. Select "User change" as the "Trigger."
4. In the Inspector window, select "Properties > Events".
Visualizing processes (Basic)
10.7 Planning tasks
STEP 7 Basic V12.0
System Manual, 01/2013, 2949
5. Select the "Screen/ActivateScreen" system function in the function list.
6. Select the "Start" screen in the screen name field.
Result
The task is executed with the "User change" event. When a new user logs on successfully,
the "Start" screen is called up.
See also
Work area of the "Scheduler" editor (Page 2947)
Visualizing processes (Basic)
10.7 Planning tasks
STEP 7 Basic V12.0
2950 System Manual, 01/2013,
10.7.4 Examples
10.7.4.1 Example: Update user following change of user
Task
Configure an I/O field which displays the logged on user. Configure a task which updates the
I/O field when the logged on user changes.
Requirements
A "CurrentUser" tag of the "String" type is created.
A screen has been created and opened.
An I/O field is created in the screen.
Procedure
1. Click on the "I/O field" object.
2. In the Inspector window, select "Properties > Properties > General":
Select "String" as the "Display format."
Select "CurrentUser" as the "Variable."
Select "Output" as the mode.
3. Change to the work area of the Scheduler.
4. Click "Add..." in the table of the task area.
5. Enter "CurrentUser" as the "Name".
6. Select "User change" as the "Trigger."
7. In the Inspector window, select "Properties > Events".
Visualizing processes (Basic)
10.7 Planning tasks
STEP 7 Basic V12.0
System Manual, 01/2013, 2951
8. Select the system function "ReadUserName" from the "User Management" group in the
function list.
9. Select "CurrentUser" as the "Variable."
Result
When a new user logs on successfully, the "ReadUserName" function is called up. The
"CurrentUser" tag is updated and displayed in the I/O field of the newly logged on user.
If a user does not log on successfully, the logged on user is logged off. The I/O field continues
to display the user previously logged on until a new user logs on successfully.
See also
Field of application of the Scheduler (Page 2945)
Visualizing processes (Basic)
10.7 Planning tasks
STEP 7 Basic V12.0
2952 System Manual, 01/2013,
10.8 Communicating with PLCs
10.8.1 Basics of communication
10.8.1.1 Communication between devices
Communication
The data exchange between two devices is known as communication. The devices can be
interconnected directly or via a network. The interconnected devices in communication are
referred to as communication partners.
HMl device 1
HMl device 2
PLC
Data transferred between the communication partners may serve different purposes:
Display processes
Operate processes
Output alarms
Archive process values and alarms
Document process values and alarms
Administer process parameters and machine parameters
Communication partners
Communication between the following devices is described in more detail in this section:
PLC
The PLC controls a process by means of a user program.
HMI device
You use the HMI device to operate and monitor the process.
Visualizing processes (Basic)
10.8 Communicating with PLCs
STEP 7 Basic V12.0
System Manual, 01/2013, 2953
Basic information for all communication
The basis for all types of communication is a network configuration. In a network configuration,
you specify the connection that exists between the configured devices.
With the network configuration, you also ensure the necessary prerequisites for
communication, in other words:
Every device in a network is assigned a unique address.
The devices carry out communication with consistent transmission characteristics.
Automation system
The following characteristics describe an automation system:
The PLC and HMI device are interconnected
The network between the PLC and HMI device is configured
Communication between HMI devices
The HTTP protocol is available for communication between HMI devices.
For more detailed information, refer to the documentation on the SIMATIC HMI HTTP protocol.
Communication via a uniform and vendor-neutral interface
With OPC (Openess Productivity Collaboration), WinCC has a uniform and manufacturer-
neutral software interface. This interface enables standardized data exchange between
industrial, office, and manufacturing applications.
For more detailed information, refer to the documentation for OPC.
10.8.1.2 Devices and networks in the automation system
Introduction
To set up an automation system, you must configure, parameterize, and interconnect the
individual devices.
You insert PLCs and HMI devices into the project in the same way. Likewise, you configure
the two devices in the same way.
Automation system setup:
1. Insert PLC into the project.
2. Insert HMI device into the project.
3. Network the devices together.
4. Interconnect the devices.
Visualizing processes (Basic)
10.8 Communicating with PLCs
STEP 7 Basic V12.0
2954 System Manual, 01/2013,
Inserting devices
If you have created a project, you can add a device in the portal view or project view.
Visualizing processes (Basic)
10.8 Communicating with PLCs
STEP 7 Basic V12.0
System Manual, 01/2013, 2955
Portal view
Project view
Visualizing processes (Basic)
10.8 Communicating with PLCs
STEP 7 Basic V12.0
2956 System Manual, 01/2013,
Visualizing processes (Basic)
10.8 Communicating with PLCs
STEP 7 Basic V12.0
System Manual, 01/2013, 2957
Networking devices
You can network the interfaces of the communication-capable devices conveniently in the
"Devices & Networks" editor. In the networking step, you configure the physical device
connections.
The tabular network overview supplements the graphical network view with the following
additional functions:
You obtain detailed information on the structure and parameter settings of the devices.
Using the "Subnet" column, you can connect communication-capable components to
subnets that have been created.
Visualizing processes (Basic)
10.8 Communicating with PLCs
STEP 7 Basic V12.0
2958 System Manual, 01/2013,
Connecting devices
After you network the devices together, you configure the connection. You configure the "HMI
connection" connection type for communication with the HMI device.
10.8.1.3 Data exchange using tags
Communication using tags
Process values are forwarded in runtime using tags. Process values are data which is stored
in the memory of one of the connected automation systems. They represent the status of a
plant in the form of temperatures, fill levels or switching states, for example. Define external
tags for processing the process values in WinCC.
WinCC works with two types of tag:
External tags
Internal tags
Working with tags
See the chapter "Working with tags (Page 2699)" for further information about configuring tags.
Visualizing processes (Basic)
10.8 Communicating with PLCs
STEP 7 Basic V12.0
System Manual, 01/2013, 2959
10.8.1.4 Data exchange using area pointers
Communication using area pointers
Area pointers are parameter fields. WinCC receives information from these parameter fields
in Runtime during the course of the project. This information contains data on the location and
size of data areas in the PLC.
During communication, the PLC and the HMI device alternately access these data areas for
read and write operations.
Based on the evaluation of data stored in the data areas, the PLC and HMI device initiate
mutually defined actions.
The area pointers are managed centrally in the "Connections" editor. Area pointers are used
to exchange data from specific user data areas.
You use the following area pointers in WinCC:
Data record
Date/time
Coordination
Job mailbox
Date/time PLC
Project ID
Screen number
The availability of the various area pointers is determined by the HMI device used.
10.8.1.5 Communication drivers
Communication drivers
A communication driver is a software component that establishes a connection between a PLC
and an HMI device. The communication driver thus enables the assignment of process values
to HMI tags.
The interface as well as the profile and transmission speed can be chosen, depending on the
HMI device used and the connected communication partner.
Visualizing processes (Basic)
10.8 Communicating with PLCs
STEP 7 Basic V12.0
2960 System Manual, 01/2013,
10.8.2 Editors for communication
10.8.2.1 Overview of hardware and network editor
Function of the hardware and network editor
The hardware and network editor opens when you double-click on the "Devices and Networks"
entry in the project tree.
The hardware and network editor is the development environment for networking, configuring
and assigning parameters to devices and modules.
Structure of the hardware and network editor
The hardware and network editor consists of the following components: