Simatic: Easy Book
Simatic: Easy Book
Simatic: Easy Book
Getting started 3
1
Preface
Welcome to the world of S7-1200. The SIMATIC S7-1200 compact controller is the modular,
space-saving controller for small automation systems that require either simple or advanced
functionality for logic, HMI and networking. The compact design, low cost, and powerful
features make the S7-1200 a perfect solution for controlling small applications.
As part of the SIMATIC commitment to "totally integrated automation" (TIA), the S7-1200
product family and the TIA Portal programming software give you the flexibility you need to
solve your automation needs.
The S7-1200 helps to make the most challenging tasks easy!
The SIMATIC S7-1200 controller solution, designed for the "compact" controller class, is
comprised of the SIMATIC S7-1200 controller and SIMATIC HMI Basic panels that can both
be programmed with the TIA Portal engineering software. The ability to program both
devices using the same engineering software significantly reduces development costs. The
TIA Portal includes STEP 7 for S7-1200 programming and WinCC for designing Basic panel
projects.
For additional information, refer to the S7-1200 Programmable Controller System Manual.
For information about UL and FM certification, CE labeling, C-Tick and other standards, refer
to the Technical specifications (Page 361).
2
Preface
Security information
Siemens provides products and solutions with industrial security functions that support the
secure operation of plants, solutions, machines, equipment and/or networks. They are
important components in a holistic industrial security concept. With this in mind, Siemens’
products and solutions undergo continuous development. Siemens recommends strongly
that you regularly check for product updates.
For the secure operation of Siemens products and solutions, it is necessary to take suitable
preventive action (e.g. cell protection concept) and integrate each component into a holistic,
state-of-the-art industrial security concept. Third-party products that may be in use should
also be considered. You can find more information about industrial security on the Internet
(http://www.siemens.com/industrialsecurity).
To stay informed about product updates as they occur, sign up for a product-specific
newsletter. You can find more information on the Internet
(http://support.automation.siemens.com).
4
Preface
5
Table of contents
Preface ................................................................................................................................................... 3
1 Introducing the powerful and flexible S7-1200 ....................................................................................... 15
1.1 Introducing the S7-1200 PLC .................................................................................................15
1.2 Expansion capability of the CPU ............................................................................................18
1.3 S7-1200 modules ....................................................................................................................19
1.4 Basic HMI panels ....................................................................................................................20
1.5 Mounting dimensions and clearance requirements ................................................................21
1.6 New features ...........................................................................................................................26
2 STEP 7 makes the work easy ............................................................................................................... 29
2.1 Easy to insert instructions into your user program .................................................................30
2.2 Easy access to your favorite instructions from a toolbar ........................................................30
2.3 Easy to add inputs or outputs to LAD and FBD instructions...................................................31
2.4 Expandable instructions ..........................................................................................................31
2.5 Easy to change the operating mode of the CPU ....................................................................32
2.6 Easy to modify the appearance and configuration of STEP 7 ................................................32
2.7 Project and global libraries for easy access ...........................................................................33
2.8 Easy to select a version of an instruction ...............................................................................33
2.9 Easy to drag and drop between editors ..................................................................................34
2.10 Changing the call type for a DB ..............................................................................................35
2.11 Temporarily disconnecting devices from a network ................................................................36
2.12 Easy to virtually "unplug" modules without losing the configuration .......................................37
3 Getting started ...................................................................................................................................... 39
3.1 Create a project ......................................................................................................................39
3.2 Create tags for the I/O of the CPU ..........................................................................................40
3.3 Create a simple network in your user program .......................................................................42
3.4 Use the PLC tags in the tag table for addressing the instructions ..........................................44
3.5 Add a "box" instruction ............................................................................................................45
3.6 Use the CALCULATE instruction for a complex mathematical equation ................................46
3.7 Add an HMI device to the project ............................................................................................48
3.8 Create a network connection between the CPU and HMI device ..........................................49
3.9 Create an HMI connection to share tags ................................................................................49
6
Table of contents
9
Table of contents
10
Introducing the powerful and flexible S7-1200 1
1.1 Introducing the S7-1200 PLC
The S7-1200 controller provides the flexibility and power to control a wide variety of devices
in support of your automation needs. The compact design, flexible configuration, and
powerful instruction set combine to make the S7-1200 a perfect solution for controlling a
wide variety of applications.
The CPU combines a microprocessor, an integrated power supply, input and output circuits,
built-in PROFINET, high-speed motion control I/O, and on-board analog inputs in a compact
housing to create a powerful controller. After you download your program, the CPU contains
the logic required to monitor and control the devices in your application. The CPU monitors
the inputs and changes the outputs according to the logic of your user program, which can
include Boolean logic, counting, timing, complex math operations, and communications with
other intelligent devices.
The CPU provides a PROFINET port for communication over a PROFINET network.
Additional modules are available for communicating over PROFIBUS, GPRS, RS485,
RS232, IEC, DNP3, and WDC networks.
① Power connector
② Memory card slot under top
door
③ Removable user wiring con-
nectors (behind the doors)
④ Status LEDs for the on-
board I/O
⑤ PROFINET connector (on
the bottom of the CPU)
Several security features help protect access to both the CPU and the control program:
● Every CPU provides password protection (Page 87) that allows you to configure access
to the CPU functions.
● You can use "know-how protection" (Page 89) to hide the code within a specific block.
● You can use copy protection (Page 90) to bind your program to a specific memory card or
CPU.
11
Introducing the powerful and flexible S7-1200
1.1 Introducing the S7-1200 PLC
Feature CPU 1211C CPU 1212C CPU 1214C CPU 1215C CPU 1217C
Physical size (mm) 90 x 100 x 75 110 x 100 x 75 130 x 100 x 75 150 x 100 x 75
User memory Work 50 Kbytes 75 Kbytes 100 Kbytes 125 Kbytes 150 Kbytes
Load 1 Mbyte 4 Mbytes
Retentive 10 Kbytes
Local on-board I/O Digital 6 inputs/4 out- 8 inputs/6 out- 14 inputs/10 output
puts puts
Analog 2 inputs 2 inputs/2 output
Process image size Inputs (I) 1024 bytes
Outputs (Q) 1024 bytes
Bit memory (M) 4096 bytes 8192 bytes
Signal module (SM) expansion None 2 8
Signal board (SB), Battery board 1
(BB), or communication board
(CB)
Communication module (CM) 3
(left-side expansion)
High-speed coun- Total Up to 6 configured to use any built-in or SB inputs
ters 1 MHz - Ib.2 to Ib.5
100/180 Ia.0 to Ia.5
kHz
30/120 kHz -- Ia.6 to Ia.7 Ia.6 to Ib.5 Ia.6 to Ib.1
200 kHz3
Pulse outputs2 Total Up to 4 configured to use any built-in or SB outputs
1 MHz -- Qa.0 to Qa.3
100 kHz Qa.0 to Qa.3 Qa.4 to Qb.1
20 kHz -- Qa.4 to Qa.5 Qa.4 to Qb. --
Memory card SIMATIC Memory card (optional)
Real time clock retention time 20 days, typ./12 day min. at 40 degrees C (maintenance-free Super Capacitor)
PROFINET 1 2
Ethernet communication port
Real math execution speed 2.3 μs/instruction
Boolean execution speed 0.08 μs/instruction
1 The slower speed is applicable when the HSC is configured for quadrature mode of operation.
2 For CPU models with relay outputs, you must install a digital signal (SB) to use the pulse outputs.
3 Up to 200 kHz are available with the SB 1221 DI x 24 VDC 200 kHz and SB 1221 DI 4 x 5 VDC 200 kHz.
The different CPU models provide a diversity of features and capabilities that help you create
effective solutions for your varied applications. For detailed information about a specific
CPU, see the technical specifications (Page 361).
12
Introducing the powerful and flexible S7-1200
1.1 Introducing the S7-1200 PLC
Element Description
Blocks Type OB, FB, FC, DB
Size 50 Kbytes (CPU 1211C)
75 Kbytes (CPU 1212C)
100 Kbytes (CPU 1214C)
125 Kbytes (CPU 1215C)
150 Kbytes (CPU 1217C)
Quantity Up to 1024 blocks total (OBs + FBs + FCs + DBs)
Nesting depth 16 from the program cycle or startup OB;
6 from any interrupt event OB
Monitoring Status of 2 code blocks can be monitored simultaneously
OBs Program cycle Multiple
Startup Multiple
Time-delay interrupts 4 (1 per event)
Cyclic interrupts 4 (1 per event)
Hardware interrupts 50 (1 per event)
Time error interrupts 1
Diagnostic error interrupts 1
Pull or plug of modules 1
Rack or station failure 1
Time of day Multiple
Status 1
Update 1
Profile 1
Timers Type IEC
Quantity Limited only by memory size
Storage Structure in DB, 16 bytes per timer
Counters Type IEC
Quantity Limited only by memory size
Storage Structure in DB, size dependent upon count type
• SInt, USInt: 3 bytes
• Int, UInt: 6 bytes
• DInt, UDInt: 12 bytes
13
Introducing the powerful and flexible S7-1200
1.2 Expansion capability of the CPU
14
Introducing the powerful and flexible S7-1200
1.3 S7-1200 modules
① Status LEDs
② Bus connector slide tab
③ Removable user wiring connector
Communication modules (CMs) and
communications processors (CPs) add
communication options to the CPU, such
as for PROFIBUS or RS232/RS485 con-
nectivity (for PtP, Modbus or USS), or the
AS-i master.
A CP provides capabilities for other types
of communication, such as connecting to
the CPU over a GPRS, IEC, DNP3, or
WDC network.
• The CPU supports up to three CMs or
CPs
15
Introducing the powerful and flexible S7-1200
1.4 Basic HMI panels
16
Introducing the powerful and flexible S7-1200
1.5 Mounting dimensions and clearance requirements
17
Introducing the powerful and flexible S7-1200
1.5 Mounting dimensions and clearance requirements
1 Before installing the TS (TeleService) Adapter IE Advanced or IE Basic, you must first connect the
TS Adapter and a TS module. The total width ("width A") is 60 mm.
Each CPU, SM, CM, and CP supports mounting on either a DIN rail or on a panel. Use the
DIN rail clips on the module to secure the device on the rail. These clips also snap into an
extended position to provide screw mounting positions to mount the unit directly on a panel.
The interior dimension of the hole for the DIN clips on the device is 4.3 mm.
18
Introducing the powerful and flexible S7-1200
1.5 Mounting dimensions and clearance requirements
A 25 mm thermal zone must be provided above and below the unit for free air circulation.
The S7-1200 equipment is designed to be easy to install. You can install an S7-1200 either
on a panel or on a standard rail, and you can orient the S7-1200 either horizontally or
vertically. The small size of the S7-1200 allows you to make efficient use of space.
The S7-1200 fail-safe CPUs do not support PROFIBUS or PROFINET distributed fail-safe
I/O.
Electrical equipment standards classify the SIMATIC S7-1200 system as Open Equipment.
You must install the S7-1200 in a housing, cabinet, or electric control room. You should limit
entry to the housing, cabinet, or electric control room to authorized personnel.
The installation should provide a dry environment for the S7-1200. SELV/PELV circuits are
considered to provide protection against electric shock in dry locations.
The installation should provide mechanical and environmental protection that is approved for
open equipment in your particular location category according to applicable electrical and
building codes.
Conductive contamination due to dust, moisture, and airborne pollution can cause
operational and electrical faults in the PLC.
If you locate the PLC in an area where conductive contamination may be present, the PLC
must be protected by an enclosure with appropriate protection rating. IP54 is one rating that
is generally used for electronic equipment enclosures in dirty environments and may be
appropriate for your application.
WARNING
Improper installation of the S7-1200 can result in electrical faults or unexpected operation
of machinery.
Electrical faults or unexpected machine operation can result in death, severe personal
injury, and/or property damage.
All instructions for installation and maintenance of a proper operating environment must be
followed to ensure the equipment operates safely.
Separate the S7-1200 devices from heat, high voltage, and electrical noise
As a general rule for laying out the devices of your system, always separate the devices that
generate high voltage and high electrical noise from the low-voltage, logic-type devices such
as the S7-1200.
When configuring the layout of the S7-1200 inside your panel, consider the heat-generating
devices and locate the electronic-type devices in the cooler areas of your cabinet. Reducing
the exposure to a high-temperature environment will extend the operating life of any
electronic device.
Consider also the routing of the wiring for the devices in the panel. Avoid placing low-voltage
signal wires and communications cables in the same tray with AC power wiring and high-
energy, rapidly-switched DC wiring.
19
Introducing the powerful and flexible S7-1200
1.5 Mounting dimensions and clearance requirements
CAUTION
For vertical mounting, the maximum allowable ambient temperature is reduced by 10
degrees C.
Orient a vertically mounted S7-1200 system as shown in the following figure.
Ensure that the S7-1200 system is mounted correctly.
When planning your layout for the S7-1200 system, allow enough clearance for the wiring
and communications cable connections.
20
Introducing the powerful and flexible S7-1200
1.5 Mounting dimensions and clearance requirements
WARNING
Installation or removal of S7-1200 or related equipment with the power applied could cause
electric shock or unexpected operation of equipment.
Failure to disable all power to the S7-1200 and related equipment during installation or
removal procedures could result in death, severe personal injury and/or property damage
due to electric shock or unexpected equipment operation.
Always follow appropriate safety precautions and ensure that power to the S7-1200 is
disabled before attempting to install or remove S7-1200 CPUs or related equipment.
Always ensure that whenever you replace or install an S7-1200 device you use the correct
module or equivalent device.
WARNING
Incorrect installation of an S7-1200 module may cause the program in the S7-1200 to
function unpredictably.
Failure to replace an S7-1200 device with the same model, orientation, or order could result
in death, severe personal injury and/or property damage due to unexpected equipment
operation.
Replace an S7-1200 device with the same model, and be sure to orient and position it
correctly.
21
Introducing the powerful and flexible S7-1200
1.6 New features
22
Introducing the powerful and flexible S7-1200
1.6 New features
23
Introducing the powerful and flexible S7-1200
1.6 New features
24
STEP 7 makes the work easy 2
STEP 7 provides a user-friendly environment to develop controller logic, configure HMI
visualization, and setup network communication. To help increase your productivity, STEP 7
provides two different views of the project: a task-oriented set of portals that are organized
on the functionality of the tools (Portal view), or a project-oriented view of the elements within
the project (Project view). Choose which view helps you work most efficiently. With a single
click, you can toggle between the Portal view and the Project view.
Portal view
① Portals for the different tasks
② Tasks for the selected portal
③ Selection panel for the selected
action
④ Changes to the Project view
Project view
① Menus and toolbar
② Project navigator
③ Work area
④ Task cards
⑤ Inspector window
⑥ Changes to the Portal view
⑦ Editor bar
With all of these components in one place, you have easy access to every aspect of your
project. For example, the inspector window shows the properties and information for the
object that you have selected in the work area. As you select different objects, the inspector
window displays the properties that you can configure. The inspector window includes tabs
that allow you to see diagnostic information and other messages.
By showing all of the editors that are open, the editor bar helps you work more quickly and
efficiently. To toggle between the open editors, simply click the different editor. You can also
arrange two editors to appear together, arranged either vertically or horizontally. This feature
allows you to drag and drop between editors.
25
STEP 7 makes the work easy
2.1 Easy to insert instructions into your user program
STEP 7 provides task cards that contain the instructions for your
program. The instructions are grouped according to function.
To create your program, you drag instructions from the task card
onto a network.
STEP 7 provides a "Favorites" toolbar to give you quick access to the instructions that you
frequently use. Simply click the icon for the instruction to insert it into your network!
(For the "Favorites" in the instruction tree, double-
click the icon.)
26
STEP 7 makes the work easy
2.3 Easy to add inputs or outputs to LAD and FBD instructions
● To add an input or output, click the "Create" icon or right-click on an input stub for one of
the existing IN or OUT parameters and select the "Insert input" command.
● To remove an input or output, right-click on the stub for one of the existing IN or OUT
parameters (when there are more than the original two inputs) and select the "Delete"
command.
Some of the more complex instructions are expandable, displaying only the key inputs and
outputs. To display all the inputs and outputs, click the arrow at the bottom of the instruction.
27
STEP 7 makes the work easy
2.5 Easy to change the operating mode of the CPU
Use the "Start CPU" and "Stop CPU" toolbar buttons to change the operating
mode of the CPU.
When you configure the CPU in the device configuration, you configure the start-up behavior
in the properties of the CPU (Page 80).
The "Online and diagnostics" portal also provides an operator panel for changing the
operating mode of the online CPU. To use the CPU operator panel, you must be connected
online to the CPU. The "Online tools" task card displays an operator panel that shows the
operating mode of the online CPU. The operator panel also allows you to change the
operating mode of the online CPU.
Use the button on the operator panel to change the operating mode
(STOP or RUN). The operator panel also provides an MRES button for
resetting the memory.
The color of the RUN/STOP indicator shows the current operating mode of the CPU. Yellow
indicates STOP mode, and green indicates RUN mode.
From the device configuration in STEP 7 you can also configure the default operating mode
on power up of the CPU.
28
STEP 7 makes the work easy
2.7 Project and global libraries for easy access
You can create your own global library to store the objects you want to make available for
other projects to use. When you create a new global library, you save this library to a
location on your computer or network.
29
STEP 7 makes the work easy
2.9 Easy to drag and drop between editors
To toggle between the editors that have been opened, click the icons in the editor bar.
30
STEP 7 makes the work easy
2.10 Changing the call type for a DB
31
STEP 7 makes the work easy
2.11 Temporarily disconnecting devices from a network
STEP 7 reconfigures the network connections, but does not remove the disconnected device
from the project. While the network connection is deleted, the interface addresses are not
changed.
When you download the new network connections, the CPU must be set to STOP mode.
To reconnect the device, simply create a new network connection to the port of the device.
32
STEP 7 makes the work easy
2.12 Easy to virtually "unplug" modules without losing the configuration
33
STEP 7 makes the work easy
2.12 Easy to virtually "unplug" modules without losing the configuration
34
Getting started 3
3.1 Create a project
Working with STEP 7 is easy! See how quickly you can get started with creating a project.
35
Getting started
3.2 Create tags for the I/O of the CPU
In the tool bar, click the "Split editor space horizontally" button.
Zoom the device configuration to over 200% so that the I/O points of the CPU are legible and
selectable. Drag the inputs and outputs from the CPU to the tag table:
1. Select I0.0 and drag it to the first row of the tag table.
2. Change the tag name from "I0.0" to "Start".
3. Drag I0.1 to the tag table and change the name to "Stop".
4. Drag Q0.0 (on the bottom of the CPU) to the tag table and change the name to
"Running".
36
Getting started
3.2 Create tags for the I/O of the CPU
With the tags entered into the PLC tag table, the tags are available to your user program.
37
Getting started
3.3 Create a simple network in your user program
Use the buttons on the "Favorites" to insert contacts and coils onto the network.
38
Getting started
3.3 Create a simple network in your user program
To save the project, click the "Save project" button in the toolbar. Notice that you do not have
to finish editing the rung before saving. You can now associate the tag names with these
instructions.
39
Getting started
3.4 Use the PLC tags in the tag table for addressing the instructions
3.4 Use the PLC tags in the tag table for addressing the instructions
Using the tag table, you can quickly enter the PLC tags for the addresses of the contacts and
coils.
40
Getting started
3.5 Add a "box" instruction
41
Getting started
3.6 Use the CALCULATE instruction for a complex mathematical equation
The Calculate instruction (Page 111) lets you create a math function that operates on multi-
ple input parameters to produce the result, according to the equation that you define.
In the Basic instruction tree, expand the Math functions folder.
Double-click the Calculate instruction to insert the instruction
into your user program.
Click the "???" and select the data types for the input and output pa-
rameters. (The input and output parameters must all be the same data
type.)
For this example, select the "Real" data type.
42
Getting started
3.6 Use the CALCULATE instruction for a complex mathematical equation
For this example, enter the following equation for scaling a raw analog value. (The "In" and
"Out" designations correspond to the parameters of the Calculate instruction.)
Out value = ((Out high - Out low) / (In high - In low)) * (In value - In low) + Out low
Out = ((in4 - in5) / (in2 - in3)) * (in1 - in3) + in5
Where: Out value (Out) Scaled output value
In value (in1) Analog input value
In high (in2) Upper limit for the scaled input value
In low (in3) Lower limit for the scaled input value
Out high (in4) Upper limit for the scaled output value
Out low (in5) Lower limit for the scaled output value
In the "Edit Calculate" box, enter the equation with the parameter names:
OUT = ((in4 - in5) / (in2 - in3)) * (in1 - in3) + in5
43
Getting started
3.7 Add an HMI device to the project
If you do not run the HMI wizard, the TIA Portal creates a simple default HMI screen. You
can add additional screens or objects on screens later.
44
Getting started
3.8 Create a network connection between the CPU and HMI device
3.8 Create a network connection between the CPU and HMI device
45
Getting started
3.10 Create an HMI screen
To add an element, simply drag and drop one of the elements onto the screen. Use the
properties for the element (in the Inspector window) to configure the appearance and
behavior of the element.
You can also create elements on your screen by dragging and dropping PLC tags either
from the Project tree or the program editor to the HMI screen. The PLC tag becomes an
element on the screen. You can then use the properties to change the parameters for this
element.
46
Getting started
3.11 Select a PLC tag for the HMI element
You can also drag and drop PLC tags from the Project tree to the HMI screen. Display the
PLC tags in the "Details" view of the project tree and then drag the tag to the HMI screen.
47
Getting started
3.11 Select a PLC tag for the HMI element
48
PLC concepts made easy 4
4.1 Tasks performed every scan cycle
Each scan cycle includes writing the outputs, reading the inputs, executing the user program
instructions, and performing system maintenance or background processing.
● The CPU reads the physical inputs just prior to the execution of the user program and
stores the input values in the process image input area. This ensures that these values
remain consistent throughout the execution of the user instructions.
● The CPU executes the logic of the user instructions and updates the output values in the
process image output area instead of writing to the actual physical outputs.
● After executing the user program, the CPU writes the resulting outputs from the process
image output area to the physical outputs.
49
PLC concepts made easy
4.2 Operating modes of the CPU
This process provides consistent logic through the execution of the user instructions for a
given cycle and prevents the flickering of physical output points that might change state
multiple times in the process image output area.
STARTUP RUN
A Clears the I (image) memory area ① Writes Q memory to the physical outputs
B Initializes the Q output (image) memory ② Copies the state of the physical inputs to I
area with either zero, the last value, or memory
the substitute value, as configured, and
zeroes PB, PN, and AS-i outputs
C Initializes non-retentive M memory and ③ Executes the program cycle OBs
data blocks to their initial value and
enables configured cyclic interrupt and
time of day events.
Executes the startup OBs.
D Copies the state of the physical inputs to ④ Performs self-test diagnostics
I memory
E Stores any interrupt events into the ⑤ Processes interrupts and communications
queue to be processed after entering during any part of the scan cycle
RUN mode
F Enables the writing of Q memory to the
physical outputs
You can change the default behavior for a module by removing it from this automatic update
of I/O. You can also immediately read and write digital and analog I/O values to the modules
when an instruction executes. Immediate reads of physical inputs do not update the process
image input area. Immediate writes to physical outputs update both the process image
output area and the physical output point.
50
PLC concepts made easy
4.2 Operating modes of the CPU
NOTICE
Warm restart mode configuration
The CPU can enter STOP mode due to repairable faults, such as failure of a replaceable
signal module, or temporary faults, such as power line disturbance or erratic power up
event.
If the CPU has been configured to "Warm restart mode prior to POWER OFF", it will not
return to RUN mode when the fault is repaired or removed until it receives a new command
from STEP 7 to go to RUN. Without a new command, the STOP mode is retained as the
mode prior to POWER OFF.
CPUs that are intended to operate independently of a STEP 7 connection should typically
be configured to "Warm restart - RUN" so that the CPU can be returned to RUN mode by a
power cycle following the removal of fault conditions.
The CPU does not provide a physical switch for changing the operat-
ing mode. To change the operating mode of the CPU, STEP 7 pro-
vides the following tools:
• "Stop" and "Run" buttons on the STEP 7 toolbar
• CPU operator panel in the online tools
51
PLC concepts made easy
4.3 Execution of the user program
You can also include a STP instruction in your program to change the CPU to STOP mode.
This allows you to stop the execution of your program based on the program logic. The Web
server (Page 254) also provides a page for changing the operating mode.
52
PLC concepts made easy
4.3 Execution of the user program
The system guarantees that the scan cycle will be completed in a time period called the
maximum cycle time; otherwise a time error event is generated.
● Each scan cycle begins by retrieving the current values of the digital and analog outputs
from the process image and then writing them to the physical outputs of the CPU, SB,
and SM modules configured for automatic I/O update (default configuration). When a
physical output is accessed by an instruction, both the output process image and the
physical output itself are updated.
● The scan cycle continues by reading the current values of the digital and analog inputs
from the CPU, SB, and SMs configured for automatic I/O update (default configuration),
and then writing these values to the process image. When a physical input is accessed
by an instruction, the value of the physical input is accessed by the instruction, but the
input process image is not updated.
● After reading the inputs, the user program is executed from the first instruction through
the end instruction. This includes all the program cycle OBs plus all their associated FCs
and FBs. The program cycle OBs are executed in order according to the OB number with
the lowest OB number executing first.
Communications processing occurs periodically throughout the scan, possibly interrupting
user program execution.
Self-diagnostic checks include periodic checks of the system and the I/O module status
checks.
Interrupts can occur during any part of the scan cycle, and are event-driven. When an event
occurs, the CPU interrupts the scan cycle and calls the OB that was configured to process
that event. After the OB finishes processing the event, the CPU resumes execution of the
user program at the point of interruption.
53
PLC concepts made easy
4.3 Execution of the user program
54
PLC concepts made easy
4.3 Execution of the user program
Note
If you configure the OB execution mode to be non-interruptible, then a time error OB cannot
interrupt OBs other than program cycle OBs. Prior to V4.0 of the S7-1200 CPU, a time error
OB could interrupt any executing OB. From V4.0 forward, you must configure OB execution
to be interruptible if you want a time error OB (or any other higher priority OB) to be able to
interrupt executing OBs that are not program cycle OBs.
Table 4- 1 OB events
Refer to the topic "Exchanging a V3.0 CPU for a V4.1 CPU (Page 433)" for more details.
In addition, the CPU recognizes other events that do not have associated OBs. The following
table describes these events and the corresponding CPU actions:
Interrupt latency
The interrupt event latency (the time from notification of the CPU that an event has occurred
until the CPU begins execution of the first instruction in the OB that services the event) is
approximately 175 µsec, provided that a program cycle OB is the only event service routine
active at the time of the interrupt event.
56
PLC concepts made easy
4.4 Memory areas, addressing and data types
Use the optional SIMATIC memory card as a program card, as a transfer card, for collecting
data log files, or to perform a firmware update.
● Use the transfer card to copy your project to multiple CPUs without using STEP 7. The
transfer card copies a stored project from the card to the memory of the CPU. You must
remove the transfer card after copying the program to the CPU.
● The program card takes the place of CPU memory; all of your CPU functions are
controlled by the program card. Inserting the program card erases all of the internal load
memory of the CPU (including the user program and any forced I/O). The CPU then
executes the user program from the program card.
● You can also use the program card for collecting data log files (Page 122). The program
card provides more memory than the internal memory of the CPU. The Web server
function (Page 253) of the CPU allows you to download the data log files to a computer.
● You can also use a memory card to perform a firmware update. Refer to the S7-1200
Programmable Controller System Manual for instructions.
Note
The program card must remain in the CPU. If you remove the program card, the CPU goes
to STOP mode.
57
PLC concepts made easy
4.4 Memory areas, addressing and data types
58
PLC concepts made easy
4.4 Memory areas, addressing and data types
Although not available as data types, the following BCD (binary coded decimal) numeric
formats are supported by the conversion instructions.
● BCD16 is a 16-bit value (-999 to 999).
● BCD32 is a 32-bit value (-9999999 to 9999999).
59
PLC concepts made easy
4.4 Memory areas, addressing and data types
Each different memory location has a unique address. Your user program uses these
addresses to access the information in the memory location. The absolute address consists
of the following elements:
● Memory area (such as I, Q, or M)
● Size of the data to be accessed (such as "B" for Byte or "W" for Word)
● Address of the data (such as Byte 3 or Word 3)
When accessing a bit in the address for a Boolean value, you do not enter a mnemonic for
the size. You enter only the memory area, the byte location, and the bit location for the data
(such as I0.0, Q0.1, or M3.4).
In the example, the memory area and byte address (M = bit memory area, and 3 = Byte 3)
are followed by a period (".") to separate the bit address (bit 4).
61
PLC concepts made easy
4.4 Memory areas, addressing and data types
The figure shows an example of a CPU 1214C with two SMs and one SB. In this example,
you could change the address of the DI8 module to 2 instead of 8. The tool assists you by
changing address ranges that are the wrong size or conflict with other addresses.
62
PLC concepts made easy
4.4 Memory areas, addressing and data types
Note
Valid data types that can be accessed by slice are Byte, Char, Conn_Any, Date, DInt,
DWord, Event_Any, Event_Att, Hw_Any, Hw_Device, HW_Interface, Hw_Io, Hw_Pwm,
Hw_SubModule, Int, OB_Any, OB_Att, OB_Cyclic, OB_Delay, OB_WHINT, OB_PCYCLE,
OB_STARTUP, OB_TIMEERROR, OB_Tod, Port, Rtm, SInt, Time, Time_Of_Day, UDInt,
UInt, USInt, and Word. PLC Tags of type Real can be accessed by slice, but data block tags
of type Real cannot.
63
PLC concepts made easy
4.4 Memory areas, addressing and data types
Examples
In the PLC tag table, "DW" is a declared tag of type DWORD. The examples show bit, byte,
and word slice access:
Declaration
To overlay a parameter, declare an additional parameter directly after the parameter that is
to be overlaid and select the data type "AT". The editor creates the overlay, and you can
then choose the data type, struct, or array that you wish to use for the overlay.
Example
This example shows the input parameters of a standard-access FB. The byte tag B1 is
overlaid with an array of Booleans:
64
PLC concepts made easy
4.4 Memory areas, addressing and data types
Another example is a DWord tag overlaid with a Struct, which includes a Word, Byte, and
two Booleans:
The Offset column of the block interface shows the location of the overlaid data types
relative to the original tag.
You can addresss the overlay types directly in the program logic:
out1 := #DW1_Struct.B1;
Rules
● Overlaying of tags is only possible in FB and FC blocks with standard (not optimized)
access.
● You can overlay parameters for all block types and all declaration sections.
● You can use an overlaid parameter like any other block parameter.
● You cannot overlay parameters of type VARIANT.
● The size of the overlaying parameter must be less than or equal to the size of the overlaid
parameter.
● You must declare the overlaying variable immediately after the variable that it overlays
and select the keyword "AT" as the initial data type selection.
65
PLC concepts made easy
4.5 Pulse outputs
Note
Do not exceed the maximum pulse frequency.
The maximum pulse frequency of the pulse output generators is 1 MHz for the CPU 1217C
and 100 kHz for CPUs 1211C, 1212C, 1214C, and 1215C; 20 kHz (for a standard SB); or
200 kHz (for a high-speed SB).
The four pulse generators have default I/O assignments; however, they can be configured to
any digital output on the CPU or SB. Pulse generators on the CPU cannot be assigned to
distributed I/O.
When configuring the basic motion instructions, be aware that STEP 7 does not alert you if
you configure an axis with a maximum speed or frequency that exceeds this hardware
limitation. This could cause problems with your application, so always ensure that you do not
exceed the maximum pulse frequency of the hardware.
You can use onboard CPU outputs, or you can use the optional signal board outputs. The
output point numbers are shown in the following table (assuming the default output
configuration). If you have changed the output point numbering, then the output point
numbers will be those you assigned. Note that PWM requires only one output, while PTO
can optionally use two outputs per channel. If an output is not required for a pulse function, it
is available for other uses.
66
PLC concepts made easy
4.5 Pulse outputs
The four pulse generators have default I/O assignments; however, they can be configured to
any digital output on the CPU or SB. Pulse generators on the CPU cannot be assigned to
SMs or to distributed I/O.
67
PLC concepts made easy
4.5 Pulse outputs
68
Easy to create the device configuration 5
You create the device configuration for your PLC by adding a CPU and additional modules to
your project.
69
Easy to create the device configuration
5.1 Uploading the configuration of a connected CPU
4. From the Online menu of STEP 7, select the "Upload device as new station (hardware
and software)" menu command.
STEP 7 uploads both the hardware configuration and the program blocks.
70
Easy to create the device configuration
5.1 Uploading the configuration of a connected CPU
From the device configuration editor, you select the option for detecting the configuration of
the connected device.
After you select the CPU from the online dialog and click the Load button, STEP 7 uploads
the hardware configuration from the CPU, including any modules (SM, SB, or CM). You can
then configure the parameters for the CPU and the modules (Page 80).
71
Easy to create the device configuration
5.2 Adding a CPU to the configuration
Note
The CPU does not have a pre-configured IP address. You must manually assign an IP
address for the CPU during the device configuration. If your CPU is connected to a router on
the network, you also enter the IP address for a router.
72
Easy to create the device configuration
5.3 Changing a device
Note
Device exchange: replacing a V3.0 CPU with a V4.1 CPU
You can open a STEP 7 V12 project in STEP 7 V13 and replace V3.0 CPUs with V4.1
CPUs. You cannot replace CPUs that are from versions prior to V3.0. When you replace a
V3.0 CPU with a V4.1 CPU, consider the differences (Page 433) in features and behavior
between the two versions, and actions you must take.
If you have a project for a CPU version older than V3.0, you must first upgrade the CPU to
V3.0 and then upgrade it to V4.1.
73
Easy to create the device configuration
5.4 Adding modules to the configuration
SB, BB
or CB
CM or
CP
74
Easy to create the device configuration
5.5 Configuration control
With the "configuration control" feature (Page 79), you can add signal modules and signal
boards to your device configuration that might not correspond to the actual hardware for a
specific application, but that will be used in related applications that share a common user
program, CPU model, and perhaps some of the configured modules.
75
Easy to create the device configuration
5.6 Configuring the operation of the CPU and modules
76
Easy to create the device configuration
5.6 Configuring the operation of the CPU and modules
Use the CPU properties to configure how the CPU starts up after a power cycle.
• In STOP mode
• In RUN mode
• In the previous
mode (prior to the
power cycle)
The CPU performs a warm restart before going to RUN mode. Warm restart resets all non-
retentive memory to the default start values, but the CPU retains the current values stored in
the retentive memory.
Note
The CPU always performs a restart after a download
Whenever you download an element of your project (such as a program block, data block, or
hardware configuration), the CPU performs a restart on the next transition to RUN mode. In
addition to clearing the inputs, initializing the outputs and initializing the non-retentive
memory, the restart also initializes the retentive memory areas.
After the restart that follows a download, all subsequent STOP-to-RUN transitions perform a
warm restart (that does not initialize the retentive memory).
77
Easy to create the device configuration
5.6 Configuring the operation of the CPU and modules
CAUTION
Risks with overwriting the system memory or clock memory bits
Overwriting the system memory or clock memory bits can corrupt the data in these
functions and cause your user program to operate incorrectly, which can cause damage to
equipment and injury to personnel.
Because both the clock memory and system memory are unreserved in M memory,
instructions or communications can write to these locations and corrupt the data.
Avoid writing data to these locations to ensure the proper operation of these functions, and
always implement an emergency stop circuit for your process or machine.
78
Easy to create the device configuration
5.6 Configuring the operation of the CPU and modules
System memory configures a byte with bits that turn on (value = 1) for a specific event.
7 6 5 4 3 2 1 0
Reserved Always off Always on Diagnostic status indica- First scan indicator
Value 0 Value 0 Value 1 tor
• 1: First scan after
• 1: Change startup
• 0: No change • 0: Not first scan
Clock memory configures a byte that cycles the individual bits on and off at fixed intervals.
Each clock bit generates a square wave pulse on the corresponding M memory bit. These
bits can be used as control bits, especially when combined with edge instructions, to trigger
actions in the user code on a cyclic basis.
Bit number 7 6 5 4 3 2 1 0
Tag name
Period (s) 2.0 1.6 1.0 0.8 0.5 0.4 0.2 0.1
Frequency (Hz) 0.5 0.625 1 1.25 2 2.5 5 10
Because clock memory runs asynchronously to the CPU cycle, the status of the clock memory can
change several times during a long cycle.
79
Easy to create the device configuration
5.6 Configuring the operation of the CPU and modules
● Analog I/O: Configure the parameters for individual inputs (such as voltage / current,
range and smoothing) and also enable underflow or overflow diagnostics. Configure the
parameters for individual analog outputs and enable diagnostics, such as short-circuit (for
voltage outputs) or overflow values.
● I/O addresses: Configure the start address for the set of inputs and outputs of the
module.
● Transmit and receive message: Configure options related to transmitting and receiving
data (such as the message-start and message-end parameters)
You can also change these configuration parameters with your user program.
80
Easy to create the device configuration
5.7 Configuring the IP address of the CPU
Note
The IP address for the CPU must be compatible with the IP address and subnet mask for
the programming device. Consult your network specialist for a suitable IP address and
subnet mask for your CPU.
81
Easy to create the device configuration
5.7 Configuring the IP address of the CPU
82
Easy to create the device configuration
5.8 Protecting access to the CPU or code block is easy
Passwords are case-sensitive. To configure the protection level and passwords, follow these
steps:
1. In the "Device configuration", select the CPU.
2. In the inspector window, select the "Properties" tab.
3. Select the "Protection" property to select the protection level and to enter passwords.
83
Easy to create the device configuration
5.8 Protecting access to the CPU or code block is easy
When you download this configuration to the CPU, the user has HMI access and can access
HMI functions without a password. To read data, the user must enter the configured
password for "Read access" or the password for "Full access (no protection)". To write data,
the user must enter the configured password for "Full access (no protection)".
WARNING
Unauthorized access to a protected CPU
Users with CPU full access privileges have privileges to read and write PLC variables.
Regardless of the access level for the CPU, Web server users can have privileges to read
and write PLC variables. Unauthorized access to the CPU or changing PLC variables to
invalid values could disrupt process operation and could result in death, severe personal
injury and/or property damage.
Authorized users can perform operating mode changes, writes to PLC data, and firmware
updates. Siemens recommends that you observe the following security practices:
• Password protect CPU access levels and Web server user IDs (Page 254) with strong
passwords. Strong passwords are at least ten characters in length, mix letters, numbers,
and special characters, are not words that can be found in a dictionary, and are not
names or identifiers that can be derived from personal information. Keep the password
secret and change it frequently.
• Enable access to the Web server only with the HTTPS protocol.
• Do not extend the default minimum privileges of the Web server "Everybody" user.
• Perform error-checking and range-checking on your variables in your program logic
because Web page users can change PLC variables to invalid values.
Connection mechanisms
To access remote connection partners with PUT/GET instructions, the user must also have
permission.
By default, the "Permit access with PUT/GET communication" option is not enabled. In this
case, read and write access to CPU data is only possible for communication connections
that require configuration or programming both for the local CPU and for the communication
partner. Access through BSEND/BRCV instructions is possible, for example.
Connections for which the local CPU is only a server (meaning that no
configuration/programming of the communication with the communication partner exists at
the local CPU), are therefore not possible during operation of the CPU, for example:
● PUT/GET, FETCH/WRITE or FTP access through communication modules
● PUT/GET access from other S7 CPUs
● HMI access through PUT/GET communication
84
Easy to create the device configuration
5.8 Protecting access to the CPU or code block is easy
If you want to allow access to CPU data from the client side, that is, you do not want to
restrict the communication services of the CPU, follow these steps:
1. Configure the protection access level to be any level other than "No access (complete
protection)".
2. Select the "Permit access with PUT/GET communication" check box.
When you download this configuration to the CPU, the CPU permits PUT/GET
communication from remote partners
85
Easy to create the device configuration
5.8 Protecting access to the CPU or code block is easy
86
Easy to create the device configuration
5.8 Protecting access to the CPU or code block is easy
Use the "Properties" task card of the code block to bind the block to a specific CPU or
memory card.
1. After opening the code block, select "Protection".
2. From the drop-down list under "Copy protection" task, select the type of copy protection
that you want to use.
3. For binding to the serial number of a CPU or memory card, select either to insert the
serial number when downloading, or enter the serial number for the memory card or
CPU.
Note
The serial number is case-sensitive.
For dynamic binding with mandatory password, define the password that you must use to
download or copy the block.
When you subsequently download a block with dynamic binding, you must enter the
password to be able to download the block. Note that the copy protection password and
the know-how protection (Page 89) password are two separate passwords.
87
Easy to create the device configuration
5.8 Protecting access to the CPU or code block is easy
88
Programming made easy 6
6.1 Easy to design your user program
When you create a user program for the automation tasks, you insert the instructions for the
program into code blocks (OB, FB, or FC).
By designing FBs and FCs to perform generic tasks, you create modular code blocks. You
then structure your user program by having other code blocks call these reusable modules.
The calling block passes device-specific parameters to the called block. When a code block
calls another code block, the CPU executes the program code in the called block. After
execution of the called block is complete, the CPU resumes the execution of the calling
block. Processing continues with execution of the instruction that follows after the block call.
89
Programming made easy
6.1 Easy to design your user program
You can also assign an OB to an interrupting event. When the event occurs, the CPU
executes the program code in the associated OB. After the execution of the OB is complete,
the CPU resumes the execution at the point in the user program when the interrupting event
occurred, which could be any point in the scan.
You can nest the block calls for a more modular structure. In the following example, the
nesting depth is 3: the program cycle OB plus 3 layers of calls to code blocks.
① Start of cycle
② Nesting depth
By creating generic code blocks that can be reused within the user program, you can simplify
the design and implementation of the user program.
● You can create reusable blocks of code for standard tasks, such as for controlling a pump
or a motor. You can also store these generic code blocks in a library that can be used by
different applications or solutions.
● When you structure the user program into modular components that relate to functional
tasks, the design of your program can be easier to understand and to manage. The
modular components not only help to standardize the program design but can also help
to make updating or modifying the program code quicker and easier.
● Creating modular components simplifies the debugging of your program. By structuring
the complete program as a set of modular program segments, you can test the
functionality of each code block as it is developed.
● Utilizing a modular design that relates to specific functional tasks can reduce the time
required for the commissioning of the completed application.
90
Programming made easy
6.1 Easy to design your user program
The CPU determines the order for handling interrupt events by priority. You can assign
multiple interrupt events to the same priority class. For more information, refer to the topics
on organization blocks (Page 57) and execution of the user program (Page 56).
91
Programming made easy
6.1 Easy to design your user program
Note
Note that you can assign a process image part number to an OB that corresponds to PIP0,
PIP1, PIP2, PIP3, or PIP4. If you enter a number for the process image part number, the
CPU creates that process image partition. See the topic "Execution of the user program
(Page 56)" for an explanation of the process image partitions.
92
Programming made easy
6.1 Easy to design your user program
6.1.2 FBs and FCs make programming the modular tasks easy
A function (FC) is like a subroutine. An FC is a code block that typically performs a specific
operation on a set of input values. The FC stores the results of this operation in memory
locations. Use FCs to perform the following tasks:
● To perform standard and reusable operations, such as for mathematical calculations
● To perform functional tasks, such as for individual controls using bit logic operations
An FC can also be called several times at different points in a program. This reuse simplifies
the programming of frequently recurring tasks.
Unlike an FB, an FC does not have an associated instance DB. The FC uses its temp
memory (L) for the data used to calculate the operation. The temporary data is not saved. To
store data for use after the execution of the FC has finished, assign the output value to a
global memory location, such as M memory or to a global DB.
A function block (FB) is like a subroutine with memory. An FB is a code block whose calls
can be programmed with block parameters. The FB stores the input (IN), output (OUT), and
in/out (IN_OUT) parameters in variable memory that is located in a data block (DB), or
"instance" DB. The instance DB provides a block of memory that is associated with that
instance (or call) of the FB and stores data after the FB finishes.
You typically use an FB to control the operation for tasks or devices that do not finish their
operation within one scan cycle. To store the operating parameters so that they can be
quickly accessed from one scan to the next, each FB in your user program has one or more
instance DBs. When you call an FB, you also open an instance DB that stores the values of
the block parameters and the static local data for that call or "instance" of the FB. These
values are stored in the instance DB after the FB finishes.
You can assign start values to the parameters in the FB interface. These values are
transferred to the associated instance DB. If you do not assign parameters, the values
currently stored in the instance DB will be used. In some cases, you must assign
parameters.
You can associate different instance DBs with different calls of the FB. The instance DBs
allow you to use one generic FB to control multiple devices. You structure your program by
having one code block make a call to an FB and an instance DB. The CPU then executes
the program code in that FB and stores the block parameters and the static local data in the
instance DB. When the execution of the FB finishes, the CPU returns to the code block that
called the FB. The instance DB retains the values for that instance of the FB. By designing
the FB for generic control tasks, you can reuse the FB for multiple devices by selecting
different instance DBs for different calls of the FB.
The following figure shows an OB that calls one FB three times, using a different data block
for each call. This structure allows one generic FB to control several similar devices, such as
motors, by assigning a different instance data block for each call for the different devices.
93
Programming made easy
6.1 Easy to design your user program
Each instance DB stores the data (such as speed, ramp-up time, and total operating time)
for an individual device. In this example, FB 22 controls three separate devices, with DB 201
storing the operational data for the first device, DB 202 storing the operational data for the
second device, and DB 203 storing the operational data for the third device.
94
Programming made easy
6.1 Easy to design your user program
95
Programming made easy
6.1 Easy to design your user program
You can store objects you want to reuse in libraries. For each project, there is a project
library that is connected to the project. In addition to the project library, you can create any
number of global libraries that can be used over several projects. Since the libraries are
compatible with each other, library elements can be copied and moved from one library to
another.
Libraries are used, for example, to create templates for blocks that you first paste into the
project library and then further develop there. Finally, you copy the blocks from the project
library to a global library. You make the global library available to other colleagues working
on your project. They use the blocks and further adapt them to their individual requirements,
where necessary.
For details about library operations, refer to the STEP 7 online Help library topics.
96
Programming made easy
6.2 Easy-to-use programming languages
1. Open the code block that will call the other block.
2. In the project tree, select the code block to be called.
3. Drag the block to the selected network to create a call to the code block.
Note
Your user program cannot call an OB because OBs are event-driven (Page 58). The CPU
starts the execution of the OB in response to receiving an event.
97
Programming made easy
6.2 Easy-to-use programming languages
To create the logic for complex operations, you can insert branches to create the logic for
parallel circuits. Parallel branches are opened downwards or are connected directly to the
power rail. You terminate the branches upwards.
LAD provides "box" instructions for a variety of functions, such as math, timer, counter, and
move.
STEP 7 does not limit the number of instructions (rows and columns) in a LAD network.
Note
Every LAD network must terminate with a coil or a box instruction.
98
Programming made easy
6.2 Easy-to-use programming languages
In the Interface section of the SCL code block you can declare the following types of
parameters:
● Input, Output, InOut, and Ret_Val: These parameters define the input tags, output tags,
and return value for the code block. The tag name that you enter here is used locally
during the execution of the code block. You typically would not use the global tag name in
the tag table.
● Static (FBs only; the illustration above is for an FC): The code block uses static tags for
storage of static intermediate results in the instance data block. The block retains static
data until overwritten, which can be after several cycles. The names of the blocks, which
this block calls as multi-instance, are also stored in the static local data.
● Temp: These parameters are the temporary tags that are used during the execution of
the code block.
● Constant: These are named constant values for your code block.
100
Programming made easy
6.3 Powerful instructions make programming easy
If you call the SCL code block from another code block, the parameters of the SCL code
block appear as inputs or outputs.
In this example, the tags for "Start" and "On" (from the project tag table) correspond to
"StartStopSwitch" and "RunYesNo" in the declaration table of the SCL program.
If you use a coil with the same address in more than one program location, the result of the
last calculation in the user program determines the status of the value that is written to the
physical output during the updating of the outputs.
Normally Open Normally Closed The Normally Open contact is closed (ON) when
Contact Contact the assigned bit value is equal to 1.
The Normally Closed contact is closed (ON) when
the assigned bit value is equal to 0.
101
Programming made easy
6.3 Powerful instructions make programming easy
The basic structure of a bit logic operation is either AND logic or OR logic. Contacts
connected in series create AND logic networks. Contacts connected in parallel create OR
logic networks.
You can connect contacts to other contacts and create your own combination logic. If the
input bit you specify uses memory identifier I (input) or Q (output), then the bit value is read
from the process-image register. The physical contact signals in your control process are
wired to input terminals on the PLC. The CPU scans the wired input signals and updates the
corresponding state values in the process-image input register.
You can specify an immediate read of a physical input using ":P" following the tag for an
input (such as "Motor_Start:P" or "I3.4:P"). For an immediate read, the bit data values are
read directly from the physical input instead of the process image. An immediate read does
not update the process image.
Note the following output results for power flow through output and inverted output coils:
● If there is power flow through an output coil, then the output bit is set to 1.
● If there is no power flow through an output coil, then the output coil bit is set to 0.
● If there is power flow through an inverted output coil, then the output bit is set to 0.
● If there is no power flow through an inverted output coil, then the output bit is set to 1.
The coil output instruction writes a value for an output bit. If the output bit you specify uses
memory identifier Q, then the CPU turns the output bit in the process-image register on or
off, setting the specified bit equal to power flow status. The output signals for your control
actuators are wired to the output terminals on the PLC. In RUN mode, the CPU system
scans your input signals, processes the input states according to your program logic, and
then reacts by setting new output state values in the process-image output register. After
each program execution cycle, the CPU transfers the new output state reaction stored in the
process-image register to the wired output terminals.
You can specify an immediate write of a physical output using ":P" following the tag for an
output (such as "Motor_On:P" or "Q3.4:P"). For an immediate write, the bit data values are
written to the process image output and directly to the physical output.
Coils are not restricted to the end of a network. You can insert a coil in the middle of a rung
of the LAD network, in between contacts or other instructions.
NOT contact inverter AND box with one inverted AND box with inverted logic input and
(LAD) logic input (FBD) output (FBD)
The LAD NOT contact inverts the logical state of power flow input.
● If there is no power flow into the NOT contact, then there is power flow out.
● If there is power flow into the NOT contact, then there is no power flow out.
102
Programming made easy
6.3 Powerful instructions make programming easy
For FBD programming, you can drag the "Invert RLO" tool from the "Favorites" toolbar or
instruction tree and then drop it on an input or output to create a logic inverter on that box
connector.
● All inputs of an AND box must be TRUE for the output to be TRUE.
● Any input of an OR box must be TRUE for the output to be TRUE.
● An odd number of the inputs of an XOR box must be TRUE for the output to be TRUE.
In FBD programming, the contact networks of LAD are represented by AND (&), OR (>=1),
and EXCLUSIVE OR (x) box networks where you can specify bit values for the box inputs
and outputs. You may also connect to other logic boxes and create your own logic
combinations. After the box is placed in your network, you can drag the "Insert input" tool
from the "Favorites" toolbar or instruction tree and then drop it onto the input side of the box
to add more inputs. You can also right-click on the box input connector and select "Insert
input".
Box inputs and output can be connected to another logic box, or you can enter a bit address
or bit symbol name for an unconnected input. When the box instruction is executed, the
current input states are applied to the binary box logic and, if true, the box output will be true.
103
Programming made easy
6.3 Powerful instructions make programming easy
1 For LAD and FBD: The contact is activated (LAD) or the box output is TRUE (FBD) if the comparison is TRUE,
For additional Comparator operations, refer to the S7-1200 Programmable Controller System
Manual.
The Move operations copy data elements to a new memory address and can convert from
one data type to another. The source data is not changed by the move process.
● MOVE copies a data element stored at a specified address to a new address. To add
another output, click the icon next to the OUT1 parameter.
● MOVE_BLK (interruptible move) and UMOVE_BLK (uninterruptible move) copy a block of
data elements to a new address. The MOVE_BLK and UMOVE_BLK instructions have an
additional COUNT parameter. The COUNT specifies how many data elements are
copied. The number of bytes per element copied depends on the data type assigned to
the IN and OUT parameter tag names in the PLC tag table.
104
Programming made easy
6.3 Powerful instructions make programming easy
1 For LAD and FBD: Click below the box name and select the data types from the drop-down menu. After you select the
(convert from) data type, a list of possible conversions is shown in the (convert to) dropdown list.
2 For SCL: Construct the conversion instruction by identifying the data type for the input parameter (in) and output pa-
rameter (out). For example, DWORD_TO_REAL converts a DWord value to a Real value.
105
Programming made easy
6.3 Powerful instructions make programming easy
out := FLOOR(in); Converts a real number (Real or LReal) to the closest integer smaller
than or equal to the selected real number (IEEE "round to -infinity").
106
Programming made easy
6.3 Powerful instructions make programming easy
out := NORM_X( Normalizes the parameter VALUE inside the value range
min:=_in_, specified by the MIN and MAX parameters:
value:=_in_, OUT = (VALUE - MIN) / (MAX - MIN),
max:=_in_); where ( 0.0 <= OUT <= 1.0 )
1 Equivalent SCL: out := value (max-min) + min;2 Equivalent SCL: out := (value-min)/(max-min);
107
Programming made easy
6.3 Powerful instructions make programming easy
Click the calculator icon to open the dialog and define your math function. You enter your
equation as inputs (such as IN1 and IN2) and operations. When you click "OK" to save the
function, the dialog automatically creates the inputs for the CALCULATE instruction.
The dialog shows an example and a list of possible instructions that you can include based
on the data type of the OUT parameter:
Note
You also must create an input for any constants in your function. The constant value would
then be entered in the associated input for the CALCULATE instruction.
By entering constants as inputs, you can copy the CALCULATE instruction to other locations
in your user program without having to change the function. You then can change the values
or tags of the inputs for the instruction without modifying the function.
When CALCULATE is executed and all the individual operations in the calculation complete
successfully, then the ENO = 1. Otherwise, ENO = 0.
For an example of the CALCULATE instruction, see "Use the CALCULATE instruction for a
complex mathematical equation (Page 46)".
108
Programming made easy
6.3 Powerful instructions make programming easy
109
Programming made easy
6.3 Powerful instructions make programming easy
110
Programming made easy
6.3 Powerful instructions make programming easy
Table 6- 13 Preset timer -(PT)- and Reset timer -(RT)- coil instructions
111
Programming made easy
6.3 Powerful instructions make programming easy
Timer Changes in the PT and IN box parameters and the corresponding coil parameters
TP • Changing PT has no effect while the timer runs.
• Changing IN has no effect while the timer runs.
TON • Changing PT has no effect while the timer runs.
• Changing IN to FALSE, while the timer runs, resets and stops the timer.
TOF • Changing PT has no effect while the timer runs.
• Changing IN to TRUE, while the timer runs, resets and stops the timer.
TONR • Changing PT has no effect while the timer runs, but has an effect when the timer resumes.
• Changing IN to FALSE, while the timer runs, stops the timer but does not reset the timer. Changing IN
back to TRUE will cause the timer to start timing from the accumulated time value.
PT (preset time) and ET (elapsed time) values are stored in the specified IEC_TIMER DB
data as signed double integers that represent milliseconds of time. TIME data uses the T#
identifier and can be entered as a simple time unit (T#200ms or 200) and as compound time
units like T#2s_200ms.
112
Programming made easy
6.3 Powerful instructions make programming easy
Timer programming
The following consequences of timer operation should be considered when planning and
creating your user program:
● You can have multiple updates of a timer in the same scan. The timer is updated each
time the timer instruction (TP, TON, TOF, TONR) is executed and each time the
ELAPSED or Q member of the timer structure is used as a parameter of another
executed instruction. This is an advantage if you want the latest time data (essentially an
immediate read of the timer). However, if you desire to have consistent values throughout
a program scan, then place your timer instruction prior to all other instructions that need
these values, and use tags from the Q and ET outputs of the timer instruction instead of
the ELAPSED and Q members of the timer DB structure.
● You can have scans during which no update of a timer occurs. It is possible to start your
timer in a function, and then cease to call that function again for one or more scans. If no
other instructions are executed which reference the ELAPSED or Q members of the timer
structure, then the timer will not be updated. A new update will not occur until either the
timer instruction is executed again or some other instruction is executed using ELAPSED
or Q from the timer structure as a parameter.
● Although not typical, you can assign the same DB timer structure to multiple timer
instructions. In general, to avoid unexpected interaction, you should only use one timer
instruction (TP, TON, TOF, TONR) per DB timer structure.
Self-resetting timers are useful to trigger actions that need to occur periodically. Typically,
self-resetting timers are created by placing a normally-closed contact which references the
timer bit in front of the timer instruction. This timer network is typically located above one or
more dependent networks that use the timer bit to trigger actions. When the timer expires
(elapsed time reaches preset value), the timer bit is ON for one scan, allowing the dependent
network logic controlled by the timer bit to execute. Upon the next execution of the timer
network, the normally closed contact is OFF, thus resetting the timer and clearing the timer
bit. The next scan, the normally closed contact is ON, thus restarting the timer. When
creating self-resetting timers such as this, do not use the "Q" member of the timer DB
structure as the parameter for the normally-closed contact in front of the timer instruction.
Instead, use the tag connected to the "Q" output of the timer instruction for this purpose. The
reason to avoid accessing the Q member of the timer DB structure is because this causes an
update to the timer and if the timer is updated due to the normally closed contact, then the
contact will reset the timer instruction immediately. The Q output of the timer instruction will
not be ON for the one scan and the dependent networks will not execute.
The -(TP)-, -(TON)-, -(TOF)-, and -(TONR)- timer coils must be the last instruction in a
network. As shown in the timer example, a contact instruction in a subsequent network
evaluates the Q bit in a timer coil's IEC_Timer DB data. Likewise, you must address the
ELAPSED element in the IEC_timer DB data if you want to use the elapsed time value in
your program.
The pulse timer is started on a 0 to 1 transition of the Tag_Input bit value. The timer runs for
the time specified by Tag_Time time value.
113
Programming made easy
6.3 Powerful instructions make programming easy
As long as the timer runs, the state of DB1.MyIEC_Timer.Q=1 and the Tag_Output value=1.
When the Tag_Time value has elapsed, then DB1.MyIEC_Timer.Q=0 and the Tag_Output
value=0.
Note
If the events to be counted occur within the execution rate of the OB, use CTU, CTD, or
CTUD counter instructions. If the events occur faster than the OB execution rate, then use
the HSC.
Each counter uses a structure stored in a data block to maintain counter data. For SCL, you
must first create the DB for the individual counter instruction before you can reference it. For
LAD and FBD, STEP 7 automatically creates the DB when you insert the instruction.
114
Programming made easy
6.3 Powerful instructions make programming easy
The number of counters that you can use in your user program is limited only by the amount
of memory in the CPU. Individual counters use 3 bytes (for SInt or USInt), 6 bytes (for Int or
UInt), or 12 bytes (for DInt or UDInt).
The timing diagram shows the operation of a CTU counter with an unsigned integer count
value (where PV = 3).
● If the value of parameter CV (current count value) is greater than or equal to the value of
parameter PV (preset count value), then the counter output parameter Q = 1.
● If the value of the reset parameter R changes from 0 to 1, then CV is reset to 0.
The timing diagram shows the operation of a CTD counter with an unsigned integer count
value (where PV = 3).
● If the value of parameter CV (current count value) is equal to or less than 0, the counter
output parameter Q = 1.
● If the value of parameter LD changes from 0 to 1, the value at parameter PV (preset
value) is loaded to the counter as the new CV.
115
Programming made easy
6.3 Powerful instructions make programming easy
The timing diagram shows the operation of a CTUD counter with an unsigned integer count
value (where PV = 4).
● If the value of parameter CV (current count value) is equal to or greater than the value of
parameter PV (preset value), then the counter output parameter QU = 1.
● If the value of parameter CV is less than or equal to zero, then the counter output
parameter QD = 1.
● If the value of parameter LD changes from 0 to 1, then the value at parameter PV is
loaded to the counter as the new CV.
● If the value of the reset parameter R changes from 0 to 1, CV is reset to 0.
116
Programming made easy
6.3 Powerful instructions make programming easy
When you insert the CTRL_PWM instruction in your code block, you create the DB for the
instruction from the "Call options" dialog. The CTRL_PWM instruction stores the parameter
information in the DB and controls the data block parameters.
The pulse width will be set to the initial value configured in device configuration when the
CPU first enters the RUN mode. You write values to the word-length output (Q) address that
was specified in device configuration ("Output addresses" / "Start address") as needed to
change the pulse width. Use an instruction (such as Move, Convert, Math, or PID) to write
the specified pulse width to the appropriate word-length output (Q). You must use the valid
range for the output value (percent, thousandths, ten-thousandths, or S7 analog format).
The PWM output can be varied from 0 to full scale, providing a digital output that in many
ways is the same as an analog output. For example, the PWM output can be used to control
the speed of a motor from stop to full speed, or it can be used to control position of a valve
from closed to fully opened.
117
Programming made easy
6.4 Easy to create data logs
118
Programming made easy
6.4 Easy to create data logs
119
Programming made easy
6.5 Easy to monitor and test your user program
Note
The force values are stored in the CPU and not in the watch table.
You cannot force an input (or "I" address). However, you can force a peripheral input. To
force a peripheral input, append a ":P" to the address (for example: "On:P").
STEP 7 also provides the capability of tracing and recording program variables based on
trigger conditions (Page 353).
120
Programming made easy
6.5 Easy to monitor and test your user program
Note
You do not have to close the editor to see the cross-reference information.
You can sort the entries in the cross-reference. The cross-reference list provides an
overview of the use of memory addresses and tags within the user program.
● When creating and changing a program, you retain an overview of the operands, tags
and block calls you have used.
● From the cross-references, you can jump directly to the point of use of operands and
tags.
● During a program test or when troubleshooting, you are notified about which memory
location is being processed by which command in which block, which tag is being used in
which screen, and which block is called by which other block.
Column Description
Object Name of the object that uses the lower-level objects or that is being used by the
lower-level objects
Number Number of uses
Point of use Each location of use, for example, network
Property Special properties of referenced objects, for example, the tag names in multi-
instance declarations
as Shows additional information about the object, such as whether an instance DB is
used as template or as a multiple instance
Access Type of access, whether access to the operand is read access (R) and/or write
access (W)
Address Address of the operand
Type Information on the type and language used to create the object
Path Path of object in project tree
Depending on the installed products, the cross-reference table displays additional or different
columns.
121
Programming made easy
6.5 Easy to monitor and test your user program
122
Programming made easy
6.5 Easy to monitor and test your user program
123
Programming made easy
6.5 Easy to monitor and test your user program
124
Programming made easy
6.6 High-speed counter (HSC)
Note
If the events to be counted occur within the execution rate of the OB, use CTU, CTD, or
CTUD counter instructions. If the events occur faster than the OB execution rate, then use
the HSC.
You configure the parameters for each HSC in the device configuration for the CPU:
counting mode, I/O connections, interrupt assignment, and operation as a high-speed
counter or as a device to measure pulse frequency or period.
Note
The current count value is not available in the CTRL_HSC parameters. The process image
address that stores the current count value is assigned during the hardware configuration of
the high-speed counter. You may use program logic to directly read the count value. The
value returned to your program will be a correct count for the instant in which the counter
was read. The counter will continue to count high-speed events. Therefore, the actual count
value could change before your program completes a process using an old count value.
125
Programming made easy
6.6 High-speed counter (HSC)
Some of the parameters for the HSC can be modified by your user program to provide
program control of the counting process:
● Set the counting direction to a NEW_DIR value
● Set the current count value to a NEW_CV value
● Set the reference value to a NEW_RV value
● Set the period value (for frequency measurement mode) to a NEW_PERIOD value
If the following Boolean flag values are set to 1 when the CTRL_HSC instruction is executed,
the corresponding NEW_xxx value is loaded to the counter. Multiple requests (more than
one flag is set at the same time) are processed in a single execution of the CTRL_HSC
instruction. Setting the following Boolean flag values to 0 results in no change.
● Setting DIR = 1 loads a NEW_DIR value.
● Setting CV = 1 loads a NEW_CV value.
● Setting RV = 1 loads a NEW_RV value
● Setting PERIOD = 1 loads a NEW_PERIOD value.
126
Programming made easy
6.6 High-speed counter (HSC)
Note
CPU and SB input channels (V4 or later firmware) have configurable input filter times
Earlier firmware versions had fixed HSC input channels and fixed filter times that could not
be changed.
V4 or later versions allow you to assign input channels and filter times. The default input filter
setting of 6.4 ms may be too slow for your process signals. You must optimize the digital
input filter times for the HSC inputs for your HSC application.
127
Programming made easy
6.6 High-speed counter (HSC)
128
Programming made easy
6.6 High-speed counter (HSC)
You can use each HSC type with or without a reset input. When you activate the reset input
(with some restrictions, see the following table), the current value is cleared and held clear
until you deactivate the reset input.
● Frequency function: Some HSC modes allow the HSC to be configured (Type of
counting) to report the frequency instead of a current count of pulses. Three different
frequency measuring periods are available: 0.01, 0.1, or 1.0 seconds.
The frequency measuring period determines how often the HSC calculates and reports a
new frequency value. The reported frequency is an average value determined by the total
number of counts in the last measuring period. If the frequency is rapidly changing, the
reported value will be an intermediate between the highest and lowest frequency
occurring during the measuring period. The frequency is always reported in Hertz (pulses
per second) regardless of the frequency measuring period setting.
● Counter modes and inputs: The following table shows the inputs used for the clock,
direction control, and reset functions associated with the HSC.
● Period measurement function: Period measurement is provided over the configured
measurement interval (10ms, 100ms, or 1000ms). The HSC_Period SDT returns period
measurements and provides the period measurements as two values: ElapsedTime and
EdgeCount. HSC inputs ID1000 to ID1020 are not affected by period measurements:
– ElapsedTime is an unsigned double integer value in nanoseconds representing the
time from the first counting event to the last counting event in the measurement
interval. If the EdgeCount = 0, then the ElapsedTime is the time since the last
counting event in a prior interval. ElapsedTime has a range from 0 to 4,294,967,280
ns (0x0000 0000 to 0xFFFF FFF0). Overflow is indicated by the value 4,294,967,295
(0xFFFF FFFF). The values from 0xFFFF FFF1 to 0xFFFF FFFE are reserved.
– EdgeCount is an unsigned double integer value representing the number of counting
events in the measurement interval.
The same input cannot be used for two different functions, but any input not being used
by the present mode of its HSC can be used for another purpose. For example, if HSC1
is in a mode that uses two built-in inputs but does not use the third external reset input
(default assignment at I0.3), then I0.3 can be used for edge interrupts or for HSC 2.
129
Programming made easy
6.6 High-speed counter (HSC)
Note
As shown in the following tables, the default assignments for the optional signals for the
different HSCs overlap. For example, the optional external reset for HSC 1 uses the same
input as one of the inputs for HSC 2. For
For V4 CPUs or later, you can reassign the HSC inputs during the CPU configuration. You
do not have to use the default input assignments.
Always ensure that you have configured your HSCs so that any one input is not being used
by two HSCs.
The following tables show the HSC input default assignments for the on-board I/O of CPUs
and an optional SB. (If the SB model selected has only 2 inputs, only 4.0 and 4.1 inputs are
available.)
HSC input table definitions
● Single-phase: C is Clock input, [d] is direction input (optional), and [R] is external reset
input (optional)
(Reset is available only for "Counting" mode.)
● Two-phase: CU is Clock Up input, CD is Clock Down input, and [R] is external reset
input.(optional)
(Reset is available only for "Counting" mode.)
● AB-phase quadrature: A is the Clock A input, B is the Clock B input, and [R] is external
reset input (optional). (Reset is available only for "Counting" mode.)
131
Programming made easy
6.6 High-speed counter (HSC)
Note
The digital I/O points used by high-speed counter devices are assigned during CPU device
configuration. When digital I/O point addresses are assigned to HSC devices, the values of
the assigned I/O point addresses cannot be modified by the force function in a watch table.
WARNING
Risks with changes to filter time setting for digital input channels
If the filter time for a digital input channel is changed from a previous setting, a new "0"
level input value might need to be presented for up to 20.0 ms accumulated duration before
the filter becomes fully responsive to new inputs. During this time, short "0" pulse events of
duration less than 20.0 ms may not be detected or counted.
This changing of filter times can result in unexpected machine or process operation, which
can cause death or serious injury to personnel, and/or damage to equipment.
To ensure that a new filter time goes immediately into effect, power cycle the CPU.
133
Programming made easy
6.6 High-speed counter (HSC)
After enabling the HSC, configure the other parameters, such as counter function, initial
values, reset options and interrupt events.
For additional information about configuring the HSC, refer to the section on configuring the
CPU (Page 80).
134
Easy to communicate between devices 7
For a direct connection between the pro-
gramming device and a CPU:
• The project must include the CPU.
• The programming device is not part of the
project, but must be running STEP 7.
135
Easy to communicate between devices
7.1 Creating a network connection
Action Result
Select "Network view" to display the
devices to be connected.
136
Easy to communicate between devices
7.2 Communication options
WARNING
If an attacker can physically access your networks, the attacker can possibly read and write
data.
The TIA Portal, the CPU, and HMIs (except HMIs using GET/PUT) use secure
communication that protects against replay and "man-in-the-middle" attacks. Once
communication is enabled, the exchange of signed messages takes place in clear text
which allows an attacker to read data, but protects against unauthorized writing of data.
The TIA Portal, not the communication process, encrypts the data of know-how protected
blocks.
All other forms of communication (I/O exchange through PROFIBUS, PROFINET, AS-i, or
other I/O bus, GET/PUT, T-Block, and communication modules (CM)) have no security
features. You must protect these forms of communication by limiting physical access. If an
attacker can physically access your networks utilizing these forms of communication, the
attacker can possibly read and write data.
For security information and recommendations, please see our "Operational Guidelines for
Industrial Security" (http://www.industry.siemens.com/topics/global/en/industrial-
security/Documents/operational_guidelines_industrial_security_en.pdf) on the Siemens
Service and Support site.
PROFINET
PROFINET is used for exchanging data through the user program with other
communications partners through Ethernet:
● In the S7-1200, PROFINET supports 16 IO devices with a maximum of 256 submodules,
and PROFIBUS allows 3 independent PROFIBUS DP Masters, supporting 32 slaves per
DP master, with a maximum of 512 modules per DP master.
● S7 communication
● User Datagram Protocol (UDP) protocol
● ISO on TCP (RFC 1006)
● Transport Control Protocol (TCP)
PROFINET IO controller
As an IO controller using PROFINET IO, the CPU communicates with up to 16 PN devices
on the local PN network or through a PN/PN coupler (link). Refer to PROFIBUS and
PROFINET International, PI (www.us.profinet.com) for more information.
137
Easy to communicate between devices
7.2 Communication options
PROFIBUS
PROFIBUS is used for exchanging data through the user program with other
communications partners through the PROFIBUS network:
● With CM 1242-5, the CPU operates as a PROFIBUS DP slave.
● With CM 1243-5, the CPU operates as a PROFIBUS DP master class1.
● PROFIBUS DP Slaves, PROFIBUS DP Masters, and AS-i (the 3 left-side communication
modules) and PROFINET are separate communications networks that do not limit each
other.
AS-i
The S7-1200 CM 1243-2 AS-i Master allows the attachment of an AS-i network to an S7-
1200 CPU.
CPU-to-CPU S7 communication
You can create a communication connection to a partner station and use the GET and PUT
instructions to communicate with S7 CPUs.
TeleService communication
In TeleService via GPRS, an engineering station on which STEP 7 is installed communicates
via the GSM network and the Internet with a SIMATIC S7-1200 station with a CP 1242-7.
The connection runs via a telecontrol server that serves as an intermediary and is connected
to the Internet.
IO-Link
The S7-1200 SM 1278 4xIO-Link Master enables IO-Link devices to connect to an S7-1200
CPU.
138
Easy to communicate between devices
7.3 V4.1 asynchronous communication connections
139
Easy to communicate between devices
7.3 V4.1 asynchronous communication connections
Available connections
The CPU supports the following number of maximum simultaneous, asynchronous
communication connections for PROFINET and PROFIBUS. The maximum number of
connection resources allocated to each category are fixed; you cannot change these values.
However, you can configure the 6 "Free available connections" to increase the number of
any category as required by your application.
Based upon the allocated connection resources, the following number of connections per
device are available:
Note
Web server (HTTP) connections: The CPU provides connections for multiple web browsers.
The number of browsers that the CPU can simultaneously support depends upon how many
connections a given web browser requests/utilizes.
Note
The Open User Communications, S7 connection, HMI, programming device, and Web server
(HTTP) communication connections may utilize multiple connection resources based upon
the features currently being used.
141
Easy to communicate between devices
7.4 PROFINET and PROFIBUS instructions
PROFINET instructions
The TSEND_C and TRCV_C instructions make PROFINET communications simpler by
combining the functionality of the TCON and TDISCON instructions with the TSEND or
TRCV instruction.
● TSEND_C establishes a TCP or ISO on TCP communication connection to a partner
station, sends data, and can terminate the connection. After the connection is set up and
established, it is automatically maintained and monitored by the CPU. TSEND_C
combines the functions of the TCON, TDISCON and TSEND instructions into one
instruction.
● TRCV_C establishes a TCP or ISO-on-TCP communication connection to a partner CPU,
receives data, and can terminate the connection. After the connection is set up and
established, it is automatically maintained and monitored by the CPU. The TRCV_C
instruction combines the functions of the TCON, TDISCON, and TRCV instructions into
one instruction.
The TCON, TDISCON, TSEND and TRCV instructions are also supported.
Use the TUSEND and the TURCV instructions to transmit or receive data via UDP. TUSEND
and TURCV (as well as TSEND, TRCV, TCON, TDISCON) function asynchronously, which
means that the processing of the job extends over several instruction calls.
Use the IP_CONF instruction to change the IP configuration parameters from your user
program. IP_CONF works asynchronously. The execution extends over multiple calls.
PROFIBUS instructions
The DPNRM_DG (read diagnostics) instruction reads the current diagnostic data of a DP
slave in the format specified by EN 50 170 Volume 2, PROFIBUS.
142
Easy to communicate between devices
7.5 PROFINET
7.5 PROFINET
Protocol Usage examples Entering data in the Communication instruc- Addressing type
receive area tions
TCP CPU-to-CPU com- Ad hoc mode Only TRCV_C and Assigns port numbers to
munication TRCV (V4.1 and legacy the Local (active) and
Transport of frames instructions) Partner (passive) devic-
Data reception with TSEND_C, TRCV_C, es
specified length TCON, TDISCON,
TSEND, and
TRCV(V4.1 and legacy
instructions)
ISO on TCP CPU-to-CPU com- Ad hoc mode Only TRCV_C and Assigns TSAPs to the
munication TRCV (V4.1 and legacy Local (active) and Part-
Message fragmenta- instructions) ner (passive) devices
tion and re-assembly Protocol-controlled TSEND_C, TRCV_C,
TCON, TDISCON,
TSEND, and TRCV
(V4.1 and legacy in-
structions)
UDP CPU-to-CPU com- User Datagram Protocol TUSEND and TURCV Assigns port numbers to
munication the Local (active) and
User program com- Partner (passive) devic-
munications es, but is not a dedicat-
ed connection
S7 communication CPU-to-CPU com- Data transmission and GET and PUT Assigns TSAPs to the
munication reception with specified Local (active) and Part-
Read/write data length ner (passive) devices
from/to a CPU
PROFINET IO CPU-to-PROFINET Data transmission and Built-in Built-in
IO device communi- reception with specified
cation length
143
Easy to communicate between devices
7.5 PROFINET
Note
If you store the data in an "optimized" DB (symbolic only), you can receive data only in
arrays of Byte, Char, USInt, and SInt data types.
To configure the TRCV_C or TRCV instruction for ad hoc mode, set the ADHOC instruction
input parameter.
If you do not call the TRCV_C or TRCV instruction in ad hoc mode frequently, you could
receive more than one packet in one call. For example: If you were to receive five 100-byte
packets with one call, TCP would deliver these five packets as one 500-byte packet, while
ISO-on-TCP would restructure the packets into five 100-byte packets.
Note
Each TSEND_C, TRCV_C or TCON instruction in your user program creates a new
connection. It is important to use the correct connection ID for each connection.
144
Easy to communicate between devices
7.5 PROFINET
The following example shows the communication between two CPUs that utilize two
separate connections for sending and receiving the data.
● The TSEND_C instruction in CPU_1 links to the TRCV_C in CPU_2 over the first
connection ("connection ID 1" on both CPU_1 and CPU_2).
● The TRCV_C instruction in CPU_1 links to the TSEND_C in CPU_2 over the second
connection ("connection ID 2" on both CPU_1 and CPU_2).
145
Easy to communicate between devices
7.5 PROFINET
The following example shows the communication between two CPUs that utilize 1
connection for both sending and receiving the data.
● Each CPU uses a TCON instruction to configure the connection between the two CPUs.
● The TSEND instruction in CPU_1 links to the TRCV instruction in CPU_2 by using the
connection ID ("connection ID 1") that was configured by the TCON instruction in CPU_1.
The TRCV instruction in CPU_2 links to the TSEND instruction in CPU_1 by using the
connection ID ("connection ID 1") that was configured by the TCON instruction in CPU_2.
● The TSEND instruction in CPU_2 links to the TRCV instruction in CPU_1 by using the
connection ID ("connection ID 1") that was configured by the TCON instruction in CPU_2.
The TRCV instruction in CPU_1 links to the TSEND instruction in CPU_2 by using the
connection ID ("connection ID 1") that was configured by the TCON instruction in CPU_1.
146
Easy to communicate between devices
7.5 PROFINET
As shown in the following example, you can also use individual TSEND and TRCV
instruction to communication over a connection created by a TSEND_C or TRCV_C
instruction. The TSEND and TRCV instructions do not themselves create a new connection,
so must use the DB and connection ID that was created by a TSEND_C, TRCV_C or TCON
instruction.
147
Easy to communicate between devices
7.5 PROFINET
TCON_Param
148
Easy to communicate between devices
7.5 PROFINET
149
Easy to communicate between devices
7.5 PROFINET
Connection paths
After inserting a TSEND_C, TRCV_C or TCON instruction into the user program, the
inspector window displays the properties of the connection whenever you have selected any
part of the instruction. Specify the communication parameters in the "Configuration" tab of
the "Properties" for the communication instruction.
Table 7- 4 Configuring the connection path (using the properties of the instruction)
150
Easy to communicate between devices
7.5 PROFINET
Note
When you configure the connection properties for one CPU, STEP 7 allows you either to
select a specific connection DB in the partner CPU (if one exists), or to create the connection
DB for the partner CPU. The partner CPU must already have been created for the project
and cannot be an "unspecified" CPU.
You must still insert a TSEND_C, TRCV_C or TCON instruction into the user program of the
partner CPU. When you insert the instruction, select the connection DB that was created by
the configuration.
151
Easy to communicate between devices
7.5 PROFINET
Parameter Definition
Address Assigned IP addresses
General End point Name assigned to the partner (receiving) CPU
Interface Name assigned to the interfaces
Subnet Name assigned to the subnets
Interface type S7 communication only: Type of interface
Connection type Type of Ethernet protocol
Connection ID ID number
Connection data Local and Partner CPU data storage location
Establish active connec- Radio button to select Local or Partner CPU as the active connection
tion
Address de- End point S7 communication only: Name assigned to the partner (receiving) CPU
tails Rack/slot S7 communication only: Rack and slot location
Connection resource S7 communication only: Component of the TSAP used when configuring an
S7 connection with an S7-300 or S7-400 CPU
Port (decimal): TCP and UPD: Partner CPU port in decimal format
TSAP and Subnet ID:
1 ISO on TCP (RFC 1006) and S7 communication: Local and partner CPU
TSAPs in ASCII and hexadecimal formats
1 When configuring a connection with an S7-1200 CPU for ISO-on-TCP, use only ASCII characters in the TSAP extension
for the passive communication partners.
Port Numbers
With TCP and UDP protocols, the connection parameter configuration of the Local (active)
connection CPU must specify the remote IP address and port number of the Partner
(passive) connection CPU.
In the "Address Details" section of the Connection Parameters dialog, you define the ports to
be used. The port of a connection in the CPU is entered in the "Local Port" field. The port
assigned for the connection in your partner CPU is entered under the "Partner Port" field.
152
Easy to communicate between devices
7.6 PROFIBUS
7.6 PROFIBUS
A PROFIBUS system uses a bus master to poll slave devices distributed in a multi-drop
fashion on an RS485 serial bus. A PROFIBUS slave is any peripheral device (I/O
transducer, valve, motor drive, or other measuring device) which processes information and
sends its output to the master. The slave forms a passive station on the network since it
does not have bus access rights, and can only acknowledge received messages, or send
response messages to the master upon request. All PROFIBUS slaves have the same
priority, and all network communication originates from the master.
A PROFIBUS master forms an "active station" on the network. PROFIBUS DP defines two
classes of masters. A class 1 master (normally a central programmable controller (PLC) or a
PC running special software) handles the normal communication or exchange of data with
the slaves assigned to it. A class 2 master (usually a configuration device, such as a laptop
or programming console used for commissioning, maintenance, or diagnostics purposes) is
a special device primarily used for commissioning slaves and for diagnostic purposes.
The S7-1200 is connected to a PROFIBUS network as a DP slave with the CM 1242-5
communication module. The CM 1242-5 (DP slave) module can be the communications
partner of DP V0/V1 masters. If you want to configure the module in a third-party system,
there is a GSD file available for the CM 1242-5 (DP slave) on the CD that ships with the
module and on Siemens Automation Customer Support
(http://support.automation.siemens.com/WW/llisapi.dll?func=cslib.csinfo&lang=en&objid=6G
K72425DX300XE0&caller=view) pages on the Internet.
In the figure below, the S7-1200 is a DP slave to an S7-300 controller:
153
Easy to communicate between devices
7.6 PROFIBUS
If a CM 1242-5 and a CM 1243-5 are installed together, an S7-1200 can perform as both a
slave of a higher-level DP master system and a master of a lower-level DP slave system,
simultaneously:
For V4.0, you can configure a maximum of three PROFIBUS CMs per station, in which there
can be any combination of DP master or DP slave CMs. DP masters in a V3.0 or greater
CPU firmware implementation can each control a maximum of 32 slaves.
The configuration data of the PROFIBUS CMs is stored on the local CPU. This allows simple
replacement of these communications modules when necessary.
154
Easy to communicate between devices
7.6 PROFIBUS
Further information
You can find detailed information on the PROFIBUS CMs in the manuals for the devices.
You can find these on the Internet in the pages of Siemens Industrial Automation Customer
Support under the following entry IDs:
● CM 1242-5 (http://support.automation.siemens.com/WW/view/en/49852105)
● CM 1243-5 (http://support.automation.siemens.com/WW/view/en/49851842)
155
Easy to communicate between devices
7.6 PROFIBUS
Table 7- 7 Adding a PROFIBUS CM 1243-5 (DP master) module to the device configuration
Use the hardware catalog to add DP slaves as well. For example, to add an ET200 S DP
slave, in the Hardware Catalog, expand the following containers:
● Distributed I/O
● ET200 S
● Interface modules
● PROFIBUS
Next, select "6ES7 151-1BA02-0AB0" (IM151-1 HF) from the list of part numbers, and add
the ET200 S DP slave as shown in the figure below.
156
Easy to communicate between devices
7.6 PROFIBUS
Table 7- 9 Configuring the CM 1243-5 (DP master) module and ET200 S DP slave PROFIBUS in-
terfaces
① PROFIBUS port
157
Easy to communicate between devices
7.6 PROFIBUS
In the Properties window, select the "PROFIBUS address" configuration entry. STEP 7
displays the PROFIBUS address configuration dialog, which is used to assign the
PROFIBUS address of the device.
Parameter Description
Subnet Name of the Subnet to which the device is connected. Click the "Add new subnet" button to create a
new subnet. "Not connected" is the default. Two connection types are possible:
• The "Not connected" default provides a local connection.
• A subnet is required when your network has two or more devices.
Parameters Address Assigned PROFIBUS address for the device
Highest address The highest PROFIBUS address is based on the active stations on the
PROFIBUS (for example, DP master). Passive DP slaves independently
have PROFIBUS addresses from 1 to 125 even if the highest PROFIBUS
address is set to 15, for example. The highest PROFIBUS address is rele-
vant for token forwarding (forwarding of the send rights), and the token is
only forwarded to active stations. Specifying the highest PROFIBUS ad-
dress optimizes the bus.
Transmission rate Transmission rate of the configured PROFIBUS network: The PROFIBUS
transmission rates range from 9.6 Kbits/sec to 12 Mbits/sec. The transmis-
sion rate setting depends on the properties of the PROFIBUS nodes being
used. The transmission rate should not be greater than the rate supported
by the slowest node.
The transmission rate is normally set for the master on the PROFIBUS
network, with all DP slaves automatically using that same transmission rate
(auto-baud).
158
Easy to communicate between devices
7.7 AS-i
7.7 AS-i
The S7-1200 AS-i master CM 1243-2 allows the attachment of an AS-i network to an S7-
1200 CPU.
The actuator/sensor interface, or AS-i, is a single master network connection system for the
lowest level in automation systems. The CM 1243-2 serves as the AS-i master for the
network. Using a single AS-i cable, sensors and actuators (AS-i slave devices) can be
connected to the CPU through the CM 1243-2. The CM 1243-2 handles all AS-i network
coordination and relays data and status information from the actuators and sensors to the
CPU through the I/O addresses assigned to the CM 1243-2. You can access binary or
analog values depending on the slave type. The AS-i slaves are the input and output
channels of the AS-i system and are only active when called by the CM 1243-2.
In the figure below, the S7-1200 is an AS-i master controlling AS-i I/O module digital/analog
slave devices.
159
Easy to communicate between devices
7.7 AS-i
Use the hardware catalog to add AS-i slaves as well. For example, to add an "I/O module,
compact, digital, input" slave, in the Hardware Catalog, expand the following containers:
● Field devices
● AS-Interface slaves
Next, select "3RG9 001-0AA00" (AS-i SM-U, 4DI) from the list of part numbers, and add the
"I/O module, compact, digital, input" slave as shown in the figure below.
160
Easy to communicate between devices
7.7 AS-i
① AS-i port
161
Easy to communicate between devices
7.7 AS-i
① AS-i slave address 1; Device: AS-i SM-U, 4DI; article number: 3RG9 001-0AA00
② AS-i slave address 2A; Device: AS-i 8WD44, 3DO, A/B; article number: 8WD4 428-0BD
③ AS-i slave address 3; Device: AS-i SM-U, 2DI/2DO; article number: 3RG9 001-0AC00
162
Easy to communicate between devices
7.7 AS-i
Parameter Description
Network Name of the network to which the device is connected
Address(es) Assigned AS-i address for the slave device in range of 1(A or B) to 31(A or B) for a total of up to 62
slave devices
163
Easy to communicate between devices
7.8 S7 communication
7.8 S7 communication
Note
To ensure data consistency, always evaluate when the operation has been completed
(NDR = 1 for GET, or DONE = 1 for PUT) before accessing the data or initiating another
read or write operation.
Note
V4.0 CPU program GET/PUT operation is not automatically enabled
A V3.0 CPU program GET/PUT operation is automatically enabled in a V4.0 CPU.
However, a V4.0 CPU program GET/PUT operation in a V4.0 CPU is not automatically
enabled. You must go the CPU "Device configuration", inspector window "Properties"tab,
"Protection" property to enable GET/PUT access (Page 87).
164
Easy to communicate between devices
7.8 S7 communication
Connection mechanisms
To access remote connection partners with PUT/GET instructions, the user must also have
permission.
By default, the "Permit access with PUT/GET communication" option is not enabled. In this
case, read and write access to CPU data is only possible for communication connections
that require configuration or programming both for the local CPU and for the communication
partner. Access through BSEND/BRCV instructions is possible, for example.
Connections for which the local CPU is only a server (meaning that no
configuration/programming of the communication with the communication partner exists at
the local CPU), are therefore not possible during operation of the CPU, for example:
● PUT/GET, FETCH/WRITE or FTP access through communication modules
● PUT/GET access from other S7 CPUs
● HMI access through PUT/GET communication
If you want to allow access to CPU data from the client side, that is, you do not want to
restrict the communication services of the CPU, you can configure the access protection for
the S7-1200 CPU (Page 87) for this level of security.
Connection types
The connection type that you select creates a communication connection to a partner
station. The connection is set up, established, and automatically monitored.
In the Devices and Networks portal, use the "Network view" to create the network
connections between the devices in your project. First, click the "Connections" tab, and then
select the connection type with the dropdown, just to the right (for example, an S7
connection). Click the green (PROFINET) box on the first device, and drag a line to the
PROFINET box on the second device. Release the mouse button and your PROFINET
connection is joined.
Refer to "Creating a network connection" (Page 140) for more information.
Click the "Highlighted: Connection" button to access the "Properties" configuration dialog of
the communication instruction.
165
Easy to communicate between devices
7.8 S7 communication
The inspector window displays the properties of the connection whenever you have selected
any part of the instruction. Specify the communication parameters in the "Configuration" tab
of the "Properties" for the communication instruction.
After inserting a GET or PUT block, the "Configuration" tab automatically appears and the
"Connection parameters" page is immediately shown. This page allows the user to configure
the necessary S7 connection and to configure the parameter "Connection ID" that is
referenced by the block parameter "ID". A "Block parameters" page allows the user to
configure additional block parameters.
Note
V4.0 CPU program GET/PUT operation is not automatically enabled
A V3.0 CPU program GET/PUT operation is automatically enabled in a V4.0 CPU.
However, a V4.0 CPU program GET/PUT operation in a V4.0 CPU is not automatically
enabled. You must go the CPU "Device configuration", inspector window "Properties"tab,
"Protection" property to enable GET/PUT access (Page 87).
166
Easy to communicate between devices
7.9 GPRS
7.9 GPRS
167
Easy to communicate between devices
7.9 GPRS
Requirements
The equipment used in the stations or the control center depends on the particular
application.
● For communication with or via a central control room, the control center requires a PC
with Internet access.
● Apart from the station equipment, a remote S7-1200 station with a CP 1242-7 must meet
the following requirements to be able to communicate via the GSM network:
– A contract with a suitable GSM network provider
If GPRS is used, the contract must allow the use of the GPRS service.
If there is to be direct communication between stations only via the GSM network, the
GSM network provider must assign a fixed IP address to the CPs. In this case,
communication between stations is not via the control center.
– The SIM card belonging to the contract
The SIM card is inserted in the CP 1242-7.
– Local availability of a GSM network in the range of the station
168
Easy to communicate between devices
7.9 GPRS
Telecontrol applications
● Sending messages by SMS
Via the CP 1242-7, the CPU of a remote S7-1200 station can receive SMS messages
from the GSM network or send messages by SMS to a configured mobile phone or an
S7-1200.
● Communication with a control center
Remote S7-1200 stations communicate via the GSM network and the Internet with a
telecontrol server in the master station. For data transfer using GPRS, the
"TELECONTROL SERVER BASIC" application is installed on the telecontrol server in the
master station. The telecontrol server communicates with a higher-level central control
system using the integrated OPC server function.
● Communication between S7-1200 stations via a GSM network
Communication between remote stations with a CP 1242-7 can be handled in two
different ways:
– Inter-station communication via a master station
In this configuration, a permanent secure connection between S7-1200 stations that
communicate with each other and the telecontrol server is established in the master
station. Communication between the stations is via the telecontrol server. The
CP 1242-7 operates in "Telecontrol" mode.
– Direct communication between the stations
For direct communication between stations without the detour via the master station,
SIM cards with a fixed IP address are used that allow the stations to address each
other directly. The possible communications services and security functions (for
example VPN) depend on what is offered by the network provider. The CP 1242-7
operates in "GPRS direct" mode.
169
Easy to communicate between devices
7.9 GPRS
170
Easy to communicate between devices
7.9 GPRS
Electrical connections
● Power supply of the CP 1242-7
The CP has a separate connection for the external 24 VDC power supply.
● Wireless interface for the GSM network
An extra antenna is required for GSM communication. This is connected via the SMA
socket of the CP.
Further information
The CP 1242-7 manual contains detailed information. You will find this on the Internet on the
pages of Siemens Industrial Automation Customer Support under the following entry ID:
45605894 (http://support.automation.siemens.com/WW/view/en/45605894)
171
Easy to communicate between devices
7.9 GPRS
7.9.6 Accessories
172
Easy to communicate between devices
7.9 GPRS
Further information
You will find detailed information in the device manual. You will find this on the Internet on
the pages of Siemens Industrial Automation Customer Support under the following entry ID:
23119005 (http://support.automation.siemens.com/WW/view/en/23119005)
A SIMATIC S7-1200 with a CP 1242-7 can send messages by SMS to a mobile phone or a
configured S7-1200 station.
173
Easy to communicate between devices
7.9 GPRS
174
Easy to communicate between devices
7.9 GPRS
In this configuration, two SIMATIC S7-1200 stations communicate directly with each other
using the CP 1242-7 via the GSM network. Each CP 1242-7 has a fixed IP address. The
relevant service of the GSM network provider must allow this.
175
Easy to communicate between devices
7.9 GPRS
176
Easy to communicate between devices
7.9 GPRS
177
Easy to communicate between devices
7.10 PtP, USS, and Modbus communication protocols
178
Easy to communicate between devices
7.10 PtP, USS, and Modbus communication protocols
Note
With version V4.1 of the S7-1200, you can use the point-to-point instructions for all types of
point-to-point communication: serial, serial over PROFINET, and serial over PROFIBUS.
STEP 7 provides the legacy point-to-point instructions only to support existing programs. The
legacy instructions still function, however, with V4.1 CPUs as well as V4.0 and earlier CPUs.
You do not have to convert prior programs from one set of instructions to the other.
179
Easy to communicate between devices
7.10 PtP, USS, and Modbus communication protocols
LED indicators
The communication modules have three LED indicators:
● Diagnostic LED (DIAG): This LED flashes red until it is addressed by the CPU. After the
CPU powers up, it checks for CMs and addresses them. The diagnostic LED begins to
flash green. This means that the CPU has addressed the CM, but has not yet provided
the configuration to it. The CPU downloads the configuration to the configured CMs when
the program is downloaded to the CPU. After a download to the CPU, the diagnostic LED
on the communication module should be a steady green.
● Transmit LED (Tx): The transmit LED illuminates when data is being transmitted out the
communication port.
● Receive LED (Rx): This LED illuminates when data is being received by the
communication port.
The communication board provides transmit (TxD) and receive (RxD) LEDs. It has no
diagnostic LED.
180
Easy to communicate between devices
7.10 PtP, USS, and Modbus communication protocols
181
Easy to communicate between devices
7.10 PtP, USS, and Modbus communication protocols
182
Easy to communicate between devices
7.10 PtP, USS, and Modbus communication protocols
Baud rate Calculated minimum USS_Port_Scan call Drive message interval timeout per
Interval (milliseconds) drive (milliseconds)
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
183
Easy to communicate between devices
7.10 PtP, USS, and Modbus communication protocols
WARNING
If an attacker can physically access your networks, the attacker can possibly read and
write data.
The TIA Portal, the CPU, and HMIs (except HMIs using GET/PUT) use secure
communication that protects against replay and "man-in-the-middle" attacks. Once
communication is enabled, the exchange of signed messages takes place in clear text
which allows an attacker to read data, but protects against unauthorized writing of data.
The TIA Portal, not the communication process, encrypts the data of know-how
protected blocks.
All other forms of communication (I/O exchange through PROFIBUS, PROFINET, AS-i,
or other I/O bus, GET/PUT, T-Block, and communication modules (CM)) have no
security features. You must protect these forms of communication by limiting physical
access. If an attacker can physically access your networks utilizing these forms of
communication, the attacker can possibly read and write data.
For security information and recommendations, please see our "Operational Guidelines
for Industrial Security" on the Service and Support site:
www.industry.siemens.com/topics/global/en/industrial-
security/Documents/operational_guidelines_industrial_security_en.pdf
(http://www.industry.siemens.com/topics/global/en/industrial-
security/Documents/operational_guidelines_industrial_security_en.pdf)
Note
Modbus TCP will only operate correctly with CPU firmware release V1.02 or later. An
attempt to execute the Modbus instructions on an earlier firmware version will result in an
error.
184
Easy to communicate between devices
7.10 PtP, USS, and Modbus communication protocols
The Modbus instructions do not use communication interrupt events to control the
communication process. Your program must poll the Modbus_Master / Modbus_Slave or
MB_CLIENT/ MB_SERVER instructions for transmit and receive complete conditions.
A Modbus TCP client (master) must control the client-server connection with the
DISCONNECT parameter. The basic Modbus client actions are shown below.
1. Initiate a connection to a particular server (slave) IP address and IP port number
2. Initiate client transmission of Modbus messages and receive the server responses
3. When required, initiate the disconnection of client and server to enable connection with a
different server.
185
Easy to communicate between devices
7.10 PtP, USS, and Modbus communication protocols
186