Page 2
Note the following: WARNING Siemens products may only be used for the applications described in the catalog and in the relevant technical documentation. If products and components from other manufacturers are used, these must be recommended or approved by Siemens. Proper transport, storage, installation, assembly, commissioning, operation and maintenance are required to ensure that the products operate safely and without any problems.
Siemens products that you are using, they can provide the fastest and most efficient answers to any problems you might encounter.
Page 4
(https://support.industry.siemens.com/cs/ww/en/view/108168658) has updates to the S7- 1200 Programmable Controller System Manual that occurred after publication. ● The Siemens Industry Online Support Web site also provides FAQs and other helpful documents for S7-1200 and STEP 7. ● You can also follow or join product discussions on the Service & Support technical forum (https://support.industry.siemens.com/tf/ww/en/?Language=en&siteid=csius&treeLang=e...
Page 5
In order to protect plants, systems, machines and networks against cyber threats, it is necessary to implement – and continuously maintain – a holistic, state-of-the-art industrial security concept. Siemens’ products and solutions only form one element of such a concept. Customer is responsible to prevent unauthorized access to its plants, systems, machines and networks.
Table of contents Preface ..............................3 Product overview ..........................27 Introducing the S7-1200 PLC ....................27 Expansion capability of the CPU .................... 30 Basic HMI panels ........................32 New features ............................33 STEP 7 programming software ......................37 System requirements ......................38 Different views to make the work easier .................
Page 8
Table of contents Wiring guidelines ........................76 PLC concepts ............................83 Execution of the user program ....................83 5.1.1 Operating modes of the CPU ....................87 5.1.2 Processing the scan cycle in RUN mode ................91 5.1.3 Organization blocks (OBs) ..................... 92 5.1.3.1 Program cycle OB ........................
Page 9
Table of contents 5.5.4 Program card ........................145 5.5.5 Firmware update ........................148 Recovery from a lost password .................... 151 Device configuration..........................153 Inserting a CPU ........................154 Uploading the configuration of a connected CPU ..............156 Adding modules to the configuration ..................158 Configuration control ......................
Page 10
Table of contents 7.6.4 Copy protection ........................214 Downloading the elements of your program ................ 216 Synchronizing the online CPU and offline project ..............219 Uploading from the online CPU ................... 221 7.9.1 Comparing the online CPU to the offline CPU ..............221 7.10 Debugging and testing the program..................
Page 11
Table of contents 8.6.9 Variant instructions ....................... 285 8.6.9.1 VariantGet (Read VARIANT tag value) ................285 8.6.9.2 VariantPut (Write VARIANT tag value) ................. 286 8.6.9.3 CountOfElements (Get number of ARRAY elements) ............287 8.6.10 Legacy instructions ....................... 288 8.6.10.1 FieldRead (Read field) and FieldWrite (Write field) instructions ........... 288 Conversion operations ......................
Page 12
Table of contents Extended instructions ........................... 335 Date, time-of-day, and clock functions ................. 335 9.1.1 Date and time-of-day instructions ..................335 9.1.2 Clock functions ........................338 9.1.3 TimeTransformationRule data structure ................342 9.1.4 SET_TIMEZONE (Set timezone) ..................343 9.1.5 RTM (Runtime meters) ......................344 String and character ......................
Page 13
Table of contents 9.5.2.1 SET_CINT (Set cyclic interrupt parameters)................. 424 9.5.2.2 QRY_CINT (Query cyclic interrupt parameters) ..............426 9.5.3 Time of day interrupts ......................427 9.5.3.1 SET_TINTL (Set time of day interrupt) ................. 428 9.5.3.2 CAN_TINT (Cancel time of day interrupt) ................429 9.5.3.3 ACT_TINT (Activate time of day interrupt) ................
Page 14
Table of contents 9.11.2 LOG2GEO (Determine the slot from the hardware identifier) ..........546 9.11.3 IO2MOD (Determine the hardware identifier from an I/O address) ........548 9.11.4 RD_ADDR (Determine the IO addresses from the hardware identifier) ......550 9.11.5 GEOADDR system data type ....................551 9.12 Common error codes for the Extended instructions ............
Page 15
Table of contents 10.2.8 Commissioning the PID_Temp controller ................642 10.3 Motion control ........................653 10.3.1 Phasing ..........................658 10.3.2 Configuring a pulse generator ....................661 10.3.3 Open loop motion control ...................... 662 10.3.3.1 Configuring the axis ......................662 10.3.3.2 Commissioning ........................
Page 16
Table of contents 11.2.4 Testing the PROFINET network ..................819 11.2.5 Locating the Ethernet (MAC) address on the CPU .............. 820 11.2.6 Configuring Network Time Protocol (NTP) synchronization ..........822 11.2.7 PROFINET device start-up time, naming, and address assignment ........824 11.2.8 Open user communication ....................
Page 17
Table of contents 11.2.16 S7 routing ..........................962 11.2.16.1 S7 routing between CPU and CP interfaces ................ 963 11.2.16.2 S7 routing between two CP interfaces .................. 963 11.2.17 Disabling SNMP ........................964 11.2.17.1 Disabling SNMP ........................965 11.2.18 Diagnostics ........................... 967 11.2.19 Distributed I/O instructions ....................
Page 18
Feature restrictions when the Internet options do not allow cookies ......... 1083 12.8.3 Rules for entering tag names and values ................1084 12.8.4 Importing the Siemens security certificate ................. 1085 12.8.5 Importing CSV format data logs to non-USA/UK versions of Microsoft Excel ....1086 S7-1200 Programmable controller...
Page 19
Table of contents Communication processor and Modbus TCP ..................1087 13.1 Using the serial communication interfaces ................. 1087 13.2 Biasing and terminating an RS485 network connector ............1088 13.3 Point-to-point (PtP) communication ..................1090 13.3.1 PtP, Freeport communication ..................... 1090 13.3.2 3964(R) communication ......................
Page 20
Table of contents 13.5.2.3 Modbus TCP instructions ....................1171 13.5.2.4 Modbus TCP examples ...................... 1185 13.5.3 Modbus RTU ........................1191 13.5.3.1 Overview ..........................1191 13.5.3.2 Selecting the version of the Modbus RTU instructions ............1193 13.5.3.3 Maximum number of supported Modbus slaves ..............1193 13.5.3.4 Modbus RTU instructions ....................
Page 21
Table of contents 13.10 Industrial Remote Communication (IRC) ................1288 13.10.1 Telecontrol CPs overview ....................1288 13.10.2 Connection to a GSM network .................... 1291 13.10.3 Applications of the CP 1242-7 .................... 1293 13.10.4 Other properties of the CP 1242-7 ..................1294 13.10.5 Further information ......................
Page 22
Backing up an online CPU ....................1354 15.17.3 Restoring a CPU ........................ 1356 Technical specifications ........................1359 Siemens Online Support website ..................1359 General technical specifications ..................1359 PROFINET interface X1 port pinouts ................. 1369 CPU 1211C ........................1370 A.4.1 General specifications and features...................
Page 23
Table of contents A.8.3 Digital inputs and outputs ....................1430 A.8.4 Analog inputs and outputs ....................1435 A.8.4.1 Analog input specifications ....................1435 A.8.4.2 Step response of built-in analog inputs of the CPU ............1435 A.8.4.3 Sample time for the built-in analog ports of the CPU ............1436 A.8.4.4 Measurement ranges of the analog inputs for voltage (CPUs)...........
Page 24
Table of contents A.14.4 Thermocouple signal boards (SBs)..................1519 A.14.4.1 SB 1231 1 analog thermocouple input specifications ............1519 A.14.4.2 Basic operation for a thermocouple ................... 1520 A.14.5 RTD signal boards (SBs) ....................1523 A.14.5.1 SB 1231 1 analog RTD input specifications ..............1523 A.14.5.2 Selection tables for the SB 1231 RTD ................
Page 25
Table of contents Basic HMI devices ......................1564 Spare parts and other hardware ..................1564 Programming software ......................1569 Device exchange and spare parts compatibility ..................1571 Exchanging a V3.0 CPU for a V4.2 CPU ................1571 S7-1200 V3.0 and earlier terminal block spare kits ............1578 Index..............................1581 S7-1200 Programmable controller System Manual, V4.2, 09/2016, A5E02486680-AK...
Page 26
Table of contents S7-1200 Programmable controller System Manual, V4.2, 09/2016, A5E02486680-AK...
Product overview 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.
Page 28
Product overview 1.1 Introducing the S7-1200 PLC Table 1- 1 Comparing the CPU models 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...
Page 29
Product overview 1.1 Introducing the S7-1200 PLC Table 1- 2 Blocks, timers, and counters supported by S7-1200 Element Description Blocks Type OB, FB, FC, DB Size CPU Model CPU 1211C CPU 1212C CPU 1214C CPU 1215C CPU 1217C Code blocks 50KB 64KB 64KB...
Product overview 1.2 Expansion capability of the CPU Expansion capability of the CPU The S7-1200 family provides a variety of modules and plug-in boards for expanding the capabilities of the CPU with additional I/O or other communication protocols. For detailed information about a specific module, see the technical specifications (Page 1359).
Page 31
• Analog I/O • RTD and thermocouple • SM 1278 IO-Link Master • SM 1238 Energy Meter • (https://support.industry.siemens.com/ cs/ww/en/view/109483435) ① Status LEDs ② Bus connector slide tab ③ Removable user wiring connector Communication modules (CMs) and communications processors (CPs) add...
Product overview 1.3 Basic HMI panels Basic HMI panels The SIMATIC HMI Basic Panels provide touch-screen devices for basic operator control and monitoring tasks. All panels have a protection rating for IP65 and have CE, UL, cULus, and NEMA 4x certification. The available Basic HMI panels (Page 1564)are described below: ●...
New features The following features are new in the V4.2 release: ● Enhancements to the Web server (Page 1001): – More shared functionality with the S7-1500 Web server – Ability to define user-defined Web page as start page – New or improved standard Web pages: Watch tables (Page 1033) Online backup (Page 1035) Communication (Page 1027): inclusion of communication statistics...
Page 34
New features Get_Name (Read the name of a PROFINET IO device) (Page 453) GetStationInfo (Read the IP or MAC address of a PROFINET IO device) (Page 460) CTRL_PTO (Pulse train output) (Page 488) DataLogClear (Empty data log) (Page 518) DataLogDelete (Delete data log) (Page 520) CREATE_DB (Create data block) (Page 534) ATTR_DB (Read data block attribute) (Page 541) DELETE_DB (Delete data block) (Page 542)
Page 35
New modules expand the power of the S7-1200 CPU and provide the flexibility to meet your automation needs: ● New Fail-safe CPUs (https://support.industry.siemens.com/cs/ww/en/view/104547552): There are two new fail-safe CPUs in conjunction with the S7-1200 V4.2 or later release: – CPU 1212FC DC/DC/DC (6ES7212-1AF40-0XB0) –...
Page 36
New features S7-1200 Programmable controller System Manual, V4.2, 09/2016, A5E02486680-AK...
STEP 7 programming software STEP 7 provides a user-friendly environment to develop, edit, and monitor the logic needed to control your application, including the tools for managing and configuring all of the devices in your project, such as controllers and HMI devices. To help you find the information you need, STEP 7 provides an extensive online help system.
STEP 7 programming software 3.1 System requirements System requirements You must install STEP 7 with Administrator privileges. Table 3- 1 System requirements Hardware/software Requirements Processor type Intel® Core™ i5-3320M 3.3 GHz or better 8 GB Available hard disk space 2 GB on system drive C:\ Operating systems You can use STEP 7 with the following operating systems (64- bit only):...
STEP 7 programming software 3.2 Different views to make the work easier Different views to make the work easier 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).
Page 40
STEP 7 programming software 3.2 Different views to make the work easier Each view also enables you to perform configuration tasks. 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.
STEP 7 programming software 3.3 Easy-to-use tools Easy-to-use tools 3.3.1 Inserting 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 programming software 3.3 Easy-to-use tools 3.3.3 Creating a complex equation with a simple instruction The Calculate instruction (Page 255) 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.
Page 43
STEP 7 programming software 3.3 Easy-to-use tools 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 - Out ) / (In - In )) * (In - In...
STEP 7 programming software 3.3 Easy-to-use tools 3.3.4 Adding inputs or outputs to a LAD or FBD instruction Some of the instructions allow you to create additional inputs or outputs. ● 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"...
STEP 7 programming software 3.3 Easy-to-use tools 3.3.6 Selecting a version for an instruction The development and release cycles for certain sets of instructions (such as Modbus, PID and motion) have created multiple released versions for these instructions. To help ensure compatibility and migration with older projects, STEP 7 allows you to choose which version of instruction to insert into your user program.
STEP 7 programming software 3.3 Easy-to-use tools 3.3.8 Dragging and dropping between editors To help you perform tasks quickly and easily, STEP 7 allows you to drag and drop elements from one editor to another. For example, you can drag an input from the CPU to the address of an instruction in your user program.
CPU (Page 87). Note You can also change the operating mode of the CPU from the Web server (Page 1001) or the SIMATIC Automation Tool (https://support.industry.siemens.com/cs/ww/en/view/98161300). S7-1200 Programmable controller System Manual, V4.2, 09/2016, A5E02486680-AK...
STEP 7 programming software 3.3 Easy-to-use tools 3.3.10 Changing the call type for a DB STEP 7 allows you to easily create or change the associ- ation of a DB for an instruction or an FB that is in an FB. •...
STEP 7 programming software 3.3 Easy-to-use tools 3.3.11 Temporarily disconnecting devices from a network From the network view, you can disconnect individual network devices from the subnet. Because the configuration of the device is not removed from the project, you can easily restore the connection to the device.
STEP 7 programming software 3.3 Easy-to-use tools 3.3.12 Virtual unplugging of devices from the configuration STEP 7 provides a storage area for "un- plugged" modules. You can drag a module from the rack to save the configuration of that module. These unplugged modules are saved with your project, allowing you to reinsert the module in the future without having to reconfigure the parameters.
STEP 7 programming software 3.4 Backward compatibility Backward compatibility STEP 7 V14 supports configuration and programming of the S7-1200 V4.2 CPU and provides for all of the new features (Page 33). You can download projects for S7-1200 V4.0 and V4.1 CPUs from STEP 7 (V12 or later) to an S7-1200 V4.2 CPU.
The small size of the S7-1200 allows you to make efficient use of space. 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.
Page 54
Installation 4.1 Guidelines for installing S7-1200 devices 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.
Page 55
Installation 4.1 Guidelines for installing S7-1200 devices When planning your layout for the S7-1200 system, allow enough clearance for the wiring and communications cable connections. ① ③ Side view Vertical installation ② ④ Horizontal installation Clearance area S7-1200 Programmable controller System Manual, V4.2, 09/2016, A5E02486680-AK...
Installation 4.2 Power budget Power budget Your CPU has an internal power supply that provides power for the CPU, the signal modules, signal board and communication modules and for other 24 V DC user power requirements. Refer to the technical specifications (Page 1359) for information about the 5 V DC logic budget supplied by your CPU and the 5 V DC power requirements of the signal modules, signal boards, and communication modules.
Installation 4.3 Installation and removal procedures Installation and removal procedures 4.3.1 Mounting dimensions for the S7-1200 devices S7-1200 Programmable controller System Manual, V4.2, 09/2016, A5E02486680-AK...
Page 58
Installation 4.3 Installation and removal procedures Table 4- 1 Mounting dimensions (mm) S7-1200 Devices Width A Width B Width C (mm) (mm) (mm) CPU 1211C and CPU 1212C CPU 1214C CPU 1215C 65 (top) Bottom: C1: 32.5 C2: 65 C3: 32.5 CPU 1217C Bottom: C1: 37.5...
Page 59
Installation 4.3 Installation and removal procedures 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.
Page 60
Installation 4.3 Installation and removal procedures 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.
Installation 4.3 Installation and removal procedures 4.3.2 Installing and removing the CPU You can install the CPU on a panel or on a DIN rail. Note Attach any communication modules to the CPU and install the assembly as a unit. Install signal modules separately after the CPU has been installed.
Page 62
Installation 4.3 Installation and removal procedures Table 4- 2 Installing the CPU on a DIN rail Task Procedure 1. Install the DIN rail. Secure the rail to the mounting panel every 75 mm. 2. Ensure that the CPU and all S7-1200 equipment are disconnected from electrical power.
Installation 4.3 Installation and removal procedures 4.3.3 Installing and removing an SB, CB, or BB Table 4- 4 Installing an SB, CB, or BB 1297 Task Procedure 1. Ensure that the CPU and all S7-1200 equipment are disconnect- ed from electrical power. 2.
Page 64
Installation 4.3 Installation and removal procedures Installing or replacing the battery in the BB 1297 battery board The BB 1297 requires battery type CR1025. The battery is not included with the BB 1297 and must be purchased. To install or replace the battery, follow these steps: 1.
Installation 4.3 Installation and removal procedures 4.3.4 Installing and removing an SM Table 4- 6 Installing an SM Task Procedure Install your SM after installing the CPU. 1. Ensure that the CPU and all S7-1200 equipment are discon- nected from electrical power. 2.
Page 66
Installation 4.3 Installation and removal procedures Table 4- 7 Removing an SM Task Procedure You can remove any SM without removing the CPU or other SMs in place. 1. Ensure that the CPU and all S7-1200 equipment are disconnected from electri- cal power.
Installation 4.3 Installation and removal procedures 4.3.5 Installing and removing a CM or CP Attach any communication modules to the CPU and install the assembly as a unit, as shown in Installing and removing the CPU (Page 61). Table 4- 8 Installing a CM or CP Task Procedure...
Installation 4.3 Installation and removal procedures 4.3.6 Removing and reinstalling the S7-1200 terminal block connector The CPU, SB and SM modules provide removable connectors to make connecting the wiring easy. Table 4- 10 Removing the connector Task Procedure Prepare the system for terminal block connector removal by removing the power from the CPU and opening the cover above the connector.
Installation 4.3 Installation and removal procedures 4.3.7 Installing and removing the expansion cable The S7-1200 expansion cable provides additional flexibility in configuring the layout of your S7-1200 system. Only one expansion cable is allowed per CPU system. You install the expansion cable either between the CPU and the first SM, or between any two SMs.
Page 70
Installation 4.3 Installation and removal procedures Table 4- 14 Removing the female connector of the expansion cable Task Procedure 1. Ensure that the CPU and all S7-1200 equipment are disconnected from electrical power. 2. Unlock the connector: – Place a screwdriver beside the tab on the top of the signal module.
Installation 4.3 Installation and removal procedures 4.3.8 TS (TeleService) adapter 4.3.8.1 Connecting the TeleService adapter Before installing the TS (TeleService) Adapter IE Basic or TS (TeleService) Adapter IE Advanced, you must first connect the TS Adapter and a TS module. Available TS modules: ●...
Page 72
Installation 4.3 Installation and removal procedures Note ④ Before connecting a TS module and TS adapter basic unit, ensure that the contact pins are not bent. When connecting, ensure that the male connector and guide pins are positioned correctly. Only connect a TS module into the TS adapter. Do not force a connection of the TS adapter to a different device, such as an S7-1200 CPU.
Installation 4.3 Installation and removal procedures 4.3.8.2 Installing the SIM card Locate the SIM card slot on the underside of the TS module GSM. Note The SIM card may only be removed or inserted if the TS module GSM is de-energized. Table 4- 15 Installing the SIM card Task...
Installation 4.3 Installation and removal procedures 4.3.8.3 Installing the TS adapter unit on a DIN rail Prerequisites: You must have connected the TS Adapter and a TS module together, and the DIN rail must have been installed. Note If you install the TS unit vertically or in high-vibration environment, the TS module can become disconnected from the TS Adapter.
Installation 4.3 Installation and removal procedures 4.3.8.4 Installing the TS adapter on a panel Prerequisites: You must have connected the TS Adapter and TS module. ① 1. Move the attachment slider to the backside of the TS Adapter and TS module in the direction of the arrow until it engages.
Installation 4.4 Wiring guidelines Wiring guidelines Proper grounding and wiring of all electrical equipment is important to help ensure the optimum operation of your system and to provide additional electrical noise protection for your application and the S7-1200. Refer to the technical specifications (Page 1359) for the S7-1200 wiring diagrams.
Page 77
Installation 4.4 Wiring guidelines Guidelines for isolation S7-1200 AC power supply boundaries and I/O boundaries to AC circuits have been designed and approved to provide safe separation between AC line voltages and low voltage circuits. These boundaries include double or reinforced insulation, or basic plus supplementary insulation, according to various standards.
Page 78
Installation 4.4 Wiring guidelines Guidelines for wiring the S7-1200 When designing the wiring for your S7-1200, provide a single disconnect switch that simultaneously removes power from the S7-1200 CPU power supply, from all input circuits, and from all output circuits. Provide over-current protection, such as a fuse or circuit breaker, to limit fault currents on supply wiring.
Page 79
Installation 4.4 Wiring guidelines A summary of Wiring rules for the S7-1200 CPUs, SMs and SBs is shown below: Table 4- 17 Wiring rules for S7-1200 CPUs, SMs, and SBs Wiring rules for... CPU and SM connector SB connector Connectible conductor 2 mm to 0.3 mm (14 AWG to 22...
Page 80
Installation 4.4 Wiring guidelines Guidelines for inductive loads Use suppressor circuits with inductive loads to limit the voltage rise when a control output turns off. Suppressor circuits protect your outputs from premature failure caused by the high voltage transient that occurs when current flow through an inductive load is interrupted. In addition, suppressor circuits limit the electrical noise generated when switching inductive loads.
Page 81
Installation 4.4 Wiring guidelines Typical suppressor circuit for DC or relay outputs that switch DC inductive loads In most applications, the addition of a diode (A) across a DC inductive load is suitable, but if your application requires faster turn-off times, then the addition of a zener diode (B) is recommended.
Page 82
Installation 4.4 Wiring guidelines If you design your own suppressor circuit, the following table suggests resistor and capacitor values for a range of AC loads. These values are based on calculations with ideal component parameters. I rms in the table refers to the steady-state current of the load when fully ON.
PLC concepts Execution of the user program The CPU supports the following types of code blocks that allow you to create an efficient structure for your user program: ● Organization blocks (OBs) define the structure of the program. Some OBs have predefined behavior and start events, but you can also create OBs with custom start events.
Page 84
PLC concepts 5.1 Execution of the user program Your S7-1200 automation solution can consist of a central rack with the S7-1200 CPU and additional modules. The term "central rack" refers to either the rail or panel installation of the CPU and associated modules. The modules (SM, SB, BB, CB, CM or CP) are detected and logged in only upon powerup.
Page 85
PLC concepts 5.1 Execution of the user program Process image update and process image partitions The CPU updates local digital and analog I/O points synchronously with the scan cycle using an internal memory area called the process image. The process image contains a snapshot of the physical inputs and outputs (the physical I/O points on the CPU, signal board, and signal modules).
Page 86
PLC concepts 5.1 Execution of the user program To assign digital or analog points to a process image partition, or to exclude I/O points from process image updates, follow these steps: 1. View the Properties tab for the appropriate device in Device configuration. 2.
PLC concepts 5.1 Execution of the user program 5.1.1 Operating modes of the CPU The CPU has three modes of operation: STOP mode, STARTUP mode, and RUN mode. Status LEDs on the front of the CPU indicate the current mode of operation. ●...
Page 88
PLC concepts 5.1 Execution of the user program You can configure the "startup after POWER ON" setting of the CPU. This configuration item appears under the "Device configuration" for the CPU under "Startup". Upon powering up, the CPU performs a sequence of power-up diagnostic checks and system initialization. During system initialization the CPU deletes all non-retentive bit (M) memory and resets all non-retentive DB contents to the initial values from load memory.
Page 89
PLC concepts 5.1 Execution of the user program You can change the current operating mode using the "STOP" or "RUN" commands (Page 1321) from the online tools of the programming software. You can also include a STP instruction (Page 310) 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.
Page 90
PLC concepts 5.1 Execution of the user program STARTUP processing Whenever the operating mode changes from STOP to RUN, the CPU clears the process image inputs, initializes the process image outputs and processes the startup OBs. Any read accesses to the process-image inputs by instructions in the startup OBs read zero rather than the current physical input value.
PLC concepts 5.1 Execution of the user program 5.1.2 Processing the scan cycle in RUN mode For each scan cycle, the CPU writes the outputs, reads the inputs, executes the user program, updates communication modules, and responds to user interrupt events and communication requests.
PLC concepts 5.1 Execution of the user program 5.1.3 Organization blocks (OBs) OBs control the execution of the user program. Specific events in the CPU trigger the execution of an organization block. OBs cannot call each other or be called from an FC or FB.
PLC concepts 5.1 Execution of the user program 5.1.3.2 Startup OB Startup OBs execute one time when the operating mode of the CPU changes from STOP to RUN, including powering up in the RUN mode and in commanded STOP-to-RUN transitions. After completion, the main "Program cycle"...
PLC concepts 5.1 Execution of the user program 5.1.3.4 Cyclic interrupt OB Cyclic interrupt OBs execute at a specified interval. You can configure up to a total of four cyclic interrupt events, with one OB corresponding to each cyclic interrupt event. Cyclic interrupt events The cyclic interrupt events allow you to configure the execution of an interrupt OB at a configured cycle time.
PLC concepts 5.1 Execution of the user program 5.1.3.5 Hardware interrupt OB Hardware interrupt OBs execute when the relevant hardware event occurs. A hardware interrupt OB interrupts normal cyclic program execution in reaction to a signal from a hardware event. Hardware interrupt events Changes in the hardware, such as a rising or falling edge on an input point, or an HSC (High Speed Counter) event trigger hardware interrupt events.
PLC concepts 5.1 Execution of the user program 5.1.3.6 Time error interrupt OB If configured, the time error interrupt OB (OB 80) executes when either the scan cycle exceeds the maximum cycle time or a time error event occurs. If triggered, it executes, interrupting normal cyclic program execution or any other event OB.
PLC concepts 5.1 Execution of the user program Time error interrupt OB includes start information that helps you determine which event and OB generated the time error. You can program instructions inside the OB to examine these start values and to take appropriate action. Table 5- 6 Start information for the time error OB (OB 80) Input...
Page 98
PLC concepts 5.1 Execution of the user program To include a diagnostic error interrupt OB in your project, you must add a diagnostic error interrupt by double-clicking "Add new block" under "Program blocks" in the tree, then choose "Organization block", and then "Diagnostic error interrupt". Note Diagnostic errors for multi-channel local analog devices (I/O, RTD, and Thermocouple) The diagnostic error interrupt OB can process only one channel's diagnostic error at a time.
Page 99
PLC concepts 5.1 Execution of the user program Table 5- 7 Startup information for the diagnostic error interrupt OB Input Data type Description IOstate WORD IO state of the device: Bit 0 = 1 if the configuration is correct, and = 0 if the configura- •...
PLC concepts 5.1 Execution of the user program 5.1.3.8 Pull or plug of modules OB The "Pull or plug of modules" OB executes when a configured and non-disabled distributed I/O module or submodule (PROFIBUS, PROFINET, AS-i) generates an event related to inserting or removing a module.
PLC concepts 5.1 Execution of the user program 5.1.3.9 Rack or station failure OB The "Rack or station failure" OB executes when the CPU detects the failure or communication loss of a distributed rack or station. Rack or station failure event The CPU generates a rack or station failure event when it detects one of the following: ●...
PLC concepts 5.1 Execution of the user program 5.1.3.10 Time of day OB Time of day OBs execute based on configured clock time conditions. The CPU supports two time of day OBs. Time of day events You can configure a time of day interrupt event to occur once on a specified date or time or cyclically with one of the following cycles: ●...
PLC concepts 5.1 Execution of the user program 5.1.3.12 Update OB Update OBs execute if a DPV1 or PNIO slave triggers an update interrupt. Update events For detailed information on events that trigger an update interrupt, refer to the manufacturer's documentation for the DPV1 or PNIO slave.
PLC concepts 5.1 Execution of the user program 5.1.3.15 MC-PreServo You can program the MC-PreServo OB to contain program logic for the STEP 7 program to execute directly before the MC-Servo OB executes. MC-PreServo events The MC-PreServo OB allows you to read out the configured application cycle information in microseconds.
PLC concepts 5.1 Execution of the user program 5.1.3.16 MC-PostServo You can program the MC-PreServo OB to contain program logic for the STEP 7 program to execute directly after the MC-Servo OB executes. MC-PostServo events The MC-PreServo OB allows you to read out the configured application cycle information in microseconds.
Page 106
PLC concepts 5.1 Execution of the user program Interruptible and non-interruptible execution modes OBs (Page 92) execute in priority order of the events that trigger them. In the Startup properties of the device configuration of the CPU (Page 170), you can configure OB execution to be interruptible or non-interruptible.
Page 107
PLC concepts 5.1 Execution of the user program Understanding event execution priorities and queuing The CPU limits the number of pending (queued) events from a single source, using a different queue for each event type. Upon reaching the limit of pending events for a given event type, the next event is lost.
Page 108
PLC concepts 5.1 Execution of the user program Event Quantity allowed Default OB priority MC-Servo 1 event MC-Interpolator 1 event The startup event and the program cycle event never occur at the same time because the startup event runs to completion before the program cycle event starts. You can have more than 50 hardware interrupt event OBs if you use the DETACH and ATTACH instructions.
PLC concepts 5.1 Execution of the user program 5.1.4 Monitoring and configuring the cycle time The cycle time is the time that the CPU operating system requires to execute the cyclic phase of the RUN mode. The CPU provides two methods of monitoring the cycle time: ●...
PLC concepts 5.1 Execution of the user program Configuring the cycle time and communication load You use the CPU properties in the Device configuration to configure the following parameters: ● Cycle: You can enter a maximum scan cycle monitoring time. You can also enable and enter a minimum scan cycle time.
Page 111
PLC concepts 5.1 Execution of the user program Retentive memory You can avoid data loss after power failure by marking certain data as retentive. The CPU allows you to configure the following data as retentive: ● Bit memory (M): You can define the size of retentive memory for bit memory in the PLC tag table or in the assignment list.
PLC concepts 5.1 Execution of the user program 5.1.5.1 System and clock memory You use the CPU properties to enable bytes for "system memory" and "clock memory". Your program logic can reference the individual bits of these functions by their tag names. ●...
Page 113
PLC concepts 5.1 Execution of the user program System memory configures a byte with bits that turn on (value = 1) for a specific event. Table 5- 19 System memory Reserved Always off Always on Diagnostic status indica- First scan indicator Value 0 Value 0 Value 1...
PLC concepts 5.1 Execution of the user program 5.1.6 Diagnostics buffer The CPU supports a diagnostics buffer that contains an entry for each diagnostic event. Each entry includes a date and time the event occurred, an event category, and an event description.
PLC concepts 5.1 Execution of the user program ● Creating a backup of the CPU ● Restoring the CPU configuration 5.1.7 Time of day clock The CPU supports a time-of-day clock. A super-capacitor supplies the energy required to keep the clock running during times when the CPU is powered down. The super-capacitor charges while the CPU has power.
PLC concepts 5.1 Execution of the user program 5.1.8 Configuring the outputs on a RUN-to-STOP transition You can configure the behavior of the digital and analog outputs when the CPU is in STOP mode. For any output of a CPU, SB or SM, you can set the outputs to either freeze the value or use a substitute value: ●...
PLC concepts 5.2 Data storage, memory areas, I/O and addressing Data storage, memory areas, I/O and addressing 5.2.1 Accessing the data of the S7-1200 STEP 7 facilitates symbolic programming. You create symbolic names or "tags" for the addresses of the data, whether as PLC tags relating to memory addresses and I/O points or as local variables used within a code block.
Page 118
PLC concepts 5.2 Data storage, memory areas, I/O and addressing Each different memory location has a unique address. Your user program uses these addresses to access the information in the memory location. References to the input (I) or output (Q) memory areas, such as I0.3 or Q1.7, access the process image. To immediately access the physical input or output, append the reference with ":P"...
Page 119
PLC concepts 5.2 Data storage, memory areas, I/O and addressing 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).
Page 120
PLC concepts 5.2 Data storage, memory areas, I/O and addressing Because the physical input points receive their values directly from the field devices connected to these points, writing to these points is prohibited. That is, I_:P accesses are read-only, as opposed to I accesses which can be read or write. I_:P accesses are also restricted to the size of inputs supported by a single CPU, SB, or SM, rounded up to the nearest byte.
Page 121
PLC concepts 5.2 Data storage, memory areas, I/O and addressing M (bit memory area): Use the bit memory area (M memory) for both control relays and data to store the intermediate status of an operation or other control information. You can access the bit memory area in bits, bytes, words, or double words.
Page 122
PLC concepts 5.2 Data storage, memory areas, I/O and addressing Note When you specify an absolute address in LAD or FBD, STEP 7 precedes this address with a "%" character to indicate that it is an absolute address. While programming, you can enter an absolute address either with or without the "%"...
PLC concepts 5.3 Processing of analog values Processing of analog values Analog signal modules provide input signals or expect output values that represent either a voltage range or a current range. These ranges are ±10 V, ±5 V, ±2.5 V, or 0 - 20 mA. The values returned by the modules are integer values where 0 to 27648 represents the rated range for current, and -27648 to 27648 for voltage.
Page 124
PLC concepts 5.3 Processing of analog values In PLC applications, the typical method is to normalize the analog input value to a floating point value between 0.0 and 1.0. Then, you would scale the resulting value to a floating point value in the range of your engineering units.
PLC concepts 5.4 Data types Data types Data types are used to specify both the size of a data element as well as how the data are to be interpreted. Each instruction parameter supports at least one data type, and some parameters support multiple data types.
PLC concepts 5.4 Data types Although not available as data types, the following BCD numeric format is supported by the conversion instructions: Table 5- 28 Size and range of the BCD format Format Size (bits) Numeric Range Constant Entry Examples BCD16 -999 to 999 123, -123...
PLC concepts 5.4 Data types 5.4.2 Integer data types Table 5- 30 Integer data types (U = unsigned, S = short, D= double) Data Bit size Number Range Constant examples Address type examples USInt 0 to 255 78, 2#01001110 MB0, DB1.DBB4, Tag_name SInt -128 to 127...
PLC concepts 5.4 Data types 5.4.4 Time and Date data types Table 5- 32 Time and date data types Data type Size Range Constant Entry Examples Time 32 bits T#-24d_20h_31m_23s_648ms to T#5m_30s T#24d_20h_31m_23s_647ms T#1d_2h_15m_30s_45ms TIME#10d20h30m20s630ms Stored as: -2,147,483,648 ms to 500h10000ms +2,147,483,647 ms 10d20h30m20s630ms...
Page 129
PLC concepts 5.4 Data types DTL (Date and Time Long) data type uses a12 byte structure that saves information on date and time. You can define DTL data in either the Temp memory of a block or in a DB. A value for all components must be entered in the "Start value"...
PLC concepts 5.4 Data types 5.4.5 Character and String data types Table 5- 35 Character and String data types Data type Size Range Constant Entry Examples Char 8 bits 16#00 to 16#FF 'A', 't', '@', 'ä', '∑' WChar 16 bits 16#0000 to 16#FFFF 'A', 't', '@', 'ä', '∑', Asian characters, Cyrillic characters, and others...
Page 131
PLC concepts 5.4 Data types The following example defines a String with maximum character count of 10 and current character count of 3. This means the String currently contains 3 one-byte characters, but could be expanded to contain up to 10 one-byte characters. Table 5- 36 Example of a String data type Total Charac-...
PLC concepts 5.4 Data types 5.4.6 Array data type Arrays You can create an array that contains multiple elements of the same data type. Arrays can be created in the block interface editors for OB, FC, FB, and DB. You cannot create an array in the PLC tags editor.
PLC concepts 5.4 Data types 5.4.7 Data structure data type You can use the data type "Struct" to define a structure of data consisting of other data types. The struct data type can be used to handle a group of related process data as a single data unit.
PLC concepts 5.4 Data types 5.4.9 Variant pointer data type The data type Variant can point to variables of different data types or parameters. The Variant pointer can point to structures and individual structural components. The Variant pointer does not occupy any space in memory. Table 5- 40 Properties of the Variant pointer Length...
PLC concepts 5.4 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.
Page 136
PLC concepts 5.4 Data types Example This example shows the input parameters of a standard-access FB. The byte tag B1 is overlaid with an array of Booleans: 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.
Page 137
PLC concepts 5.4 Data types 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. ●...
PLC concepts 5.5 Using a memory card Using a memory card Note The CPU supports only the pre-formatted SIMATIC memory cards (Page 1546). Before you copy any program to the formatted memory card, delete any previously saved program from the memory card. Use the memory card either as a transfer card or as a program card.
PLC concepts 5.5 Using a memory card 5.5.1 Inserting a memory card in the CPU NOTICE Protect memory card and receptacle from electrostatic discharge Electrostatic discharge can damage the memory card or the receptacle on the CPU. Make contact with a grounded conductive pad and/or wear a grounded wrist strap when you handle the memory card.
Page 140
PLC concepts 5.5 Using a memory card Table 5- 41 Inserting a memory card To insert a memory card, open the top CPU door and insert the memory card in the slot. A push-push type connector allows for easy insertion and removal. The memory card is keyed for proper installa- tion.
Page 141
PLC concepts 5.5 Using a memory card How the CPU evaluates the memory card If you do not configure the CPU to "Disable copy from internal load memory to external load memory" in the Protection properties of the device configuration (Page 212), the CPU determines what type of memory card you inserted: ●...
PLC concepts 5.5 Using a memory card 5.5.2 Configuring the startup parameter of the CPU before copying the project to the memory card When you copy a program to a transfer card or a program card, the program includes the startup parameter for the CPU.
Page 143
PLC concepts 5.5 Using a memory card Creating a transfer card Always remember to configure the startup parameter of the CPU (Page 142) before copying a program to the transfer card. To create a transfer card, follow these steps: 1. Insert a blank SIMATIC memory card that is not write-protected into an SD card reader/writer attached to your computer.
Page 144
PLC concepts 5.5 Using a memory card 6. In the "Load preview" dialog, click the "Load" button to copy the CPU device to the memory card. 7. When the dialog displays a message that the CPU device (program) has been loaded without errors, click the "Finish"...
PLC concepts 5.5 Using a memory card 5.5.4 Program card NOTICE Electrostatic discharge can damage the memory card or the receptacle on the CPU. Make contact with a grounded conductive pad and/or wear a grounded wrist strap when you handle the memory card. Store the memory card in a conductive container. Check that the memory card is not write-protected.
Page 146
PLC concepts 5.5 Using a memory card Always remember to configure the startup parameter of the CPU (Page 142) before copying a project to the program card. To create a program card, follow these steps: 1. Insert a blank SIMATIC memory card that is not write-protected into an SD card reader/writer attached to your computer.
Page 147
PLC concepts 5.5 Using a memory card Using a program card as the load memory for your CPU WARNING Risks associated with inserting a program card Verify that the CPU is not actively running a process before inserting the memory card. Inserting a memory card will cause the CPU to go to STOP mode, which could affect the operation of an online process or machine.
Do not use the Windows formatter utility or any other formatting utility to reformat the memory card. If a Siemens memory card is reformatted using the Microsoft Windows formatter utility, then the memory card will no longer be usable by a S7-1200 CPU.
Page 149
PLC concepts 5.5 Using a memory card To download the firmware update to your memory card, follow these steps: 1. Insert a blank SIMATIC memory card that is not write-protected into an SD card reader/writer attached to your computer. (If the card is write-protected, slide the protection switch away from the "Lock"...
Page 150
PLC concepts 5.5 Using a memory card After the CPU reboots, the firmware update starts. The RUN/STOP LED alternately flashes green and yellow to indicate that the update is being copied. When the RUN/STOP LED turns on (solid yellow) and the MAINT LED flashes, the copy process has finished.
PLC concepts 5.6 Recovery from a lost password Recovery from a lost password If you have lost the password for a password-protected CPU, use an empty transfer card to delete the password-protected program. The empty transfer card erases the internal load memory of the CPU.
Page 152
PLC concepts 5.6 Recovery from a lost password S7-1200 Programmable controller System Manual, V4.2, 09/2016, A5E02486680-AK...
Device configuration You create the device configuration for your PLC by adding a CPU and additional modules to your project. ① Communication module (CM) or communication processor (CP): Up to 3, inserted in slots 101, 102, and 103 ② CPU: Slot 1 ③...
Device configuration 6.1 Inserting a CPU Inserting a CPU You can insert a CPU into your pro- ject from either the Portal view or the Project view of STEP 7: • In the Portal view, select "Devices & Networks" and click "Add new device".
Page 155
Device configuration 6.1 Inserting a CPU "Add new device" dialog Device view of the hardware configuration Selecting the CPU in the Device view displays the CPU proper- ties in the inspector window. The CPU does not have a pre- configured IP address. You must manually assign an IP address for the CPU during the device configuration.
Device configuration 6.2 Uploading the configuration of a connected CPU Uploading the configuration of a connected CPU STEP 7 provides two methods for uploading the hardware configuration of a connected CPU: ● Uploading the connected device as a new station ●...
Page 157
Device configuration 6.2 Uploading the configuration of a connected CPU Detecting the hardware configuration of an unspecified CPU If you are connected to a CPU, you can upload the configuration of that CPU, including any modules, to your project. Simply create a new project and select the "unspecified CPU"...
Device configuration 6.3 Adding modules to the configuration Adding modules to the configuration Use the hardware catalog to add modules to the CPU: ● Signal module (SM) provides additional digital or analog I/O points. These modules are connected to the right side of the CPU. ●...
(options) that use a subset of this configuration. The PROFINET with STEP 7 manual (http://support.automation.siemens.com/WW/view/en/49948856) refers to these types of projects as "standard machine projects". A control data record that you program in the startup program block notifies the CPU as to which modules are missing in the real installation as compared to the configuration or which modules are located in different slots as compared to the configuration.
Page 160
Device configuration 6.4 Configuration control 4. Create a PLC data type to contain the control data record. Configure it as a struct that includes four USints for configuration control information and additional USints to correspond to the slots of a maximum S7-1200 device configuration, as follows: 5.
Page 161
Device configuration 6.4 Configuration control 6. In this data block, configure the Block_length, Block_ID, Version, and Subversion as shown below. Configure the values for the slots based on their presence or absence and position in your actual installation: – 0: Configured module is not present in the actual configuration. (The slot is empty.) –...
Page 162
Device configuration 6.4 Configuration control 7. In the startup OB, call the extended WRREC (Write data record) instruction to transfer the control data record that you created to index 196 of hardware ID 33. Use a label and JMP (jump) instruction to wait for the WRREC instruction to complete. Network 1: Network 2: Note...
Page 163
Device configuration 6.4 Configuration control Control data record A control data record 196 contains the slot assignment and represents the actual configuration, as shown below: Byte Element Value Explanation Block length Header Block ID Version Subversion Assignment of CPU annex card Actual annex card, 0, or 255* Control element Describes in each element which...
Page 164
Device configuration 6.4 Configuration control Rules Observe the following rules: ● Configuration control does not support position changes for communication modules. The control data record slot positions for slots 101 to 103 must correspond to the actual installation. If you have not configured a module for the slot in your device configuration, enter 255 for that slot position in the control data record.
Page 165
Device configuration 6.4 Configuration control Behavior during operation For the online display and for the display in the diagnostics buffer (module OK or module faulty), STEP 7 uses the device configuration and not the differing real configuration. Example: A module outputs diagnostics data. This module is configured in slot 4, but is actually inserted in slot 3.
Device configuration 6.4 Configuration control 6.4.3 Example of configuration control This example describes a configuration consisting of a CPU and three I/O modules.The module at slot 3 is not present in the first actual installation, so you use configuration control to "hide"...
Page 167
Device configuration 6.4 Configuration control To indicate the absence of the missing module, you must configure slot 3 in the control data record with 0. S7-1200 Programmable controller System Manual, V4.2, 09/2016, A5E02486680-AK...
Page 168
Device configuration 6.4 Configuration control Example: Actual installation with module subsequently added to a different slot In the second example, the module in slot 3 of the device configuration is present in the actual installation but is in slot 4. Figure 6-3 Device configuration compared to actual installation with modules in slots 3 and 4 swapped...
Page 169
Device configuration 6.4 Configuration control To correlate the device configuration to the actual installation, edit the control data record to assign the modules to the correct slot positions. S7-1200 Programmable controller System Manual, V4.2, 09/2016, A5E02486680-AK...
Device configuration 6.5 Changing a device Changing a device You can change the device type of a configured CPU or module. From Device configuration, right-click the device and select "Change device" from the context menu. From the dialog, navigate to and select the CPU or module that you want to replace. The Change device dialog shows you compatibility information between the two devices.
Page 171
Device configuration 6.6 Configuring the operation of the CPU Table 6- 2 CPU properties Property Description PROFINET interface Sets the IP address for the CPU and time synchronization DI, DO, and AI Configures the behavior of the local (on-board) digital and analog I/O (for example, digital input filter times and digital output reaction to a CPU stop).
Device configuration 6.6 Configuring the operation of the CPU 6.6.2 Configuring digital input filter times The digital input filters protect your program from responding to unwanted fast changes in the input signals, as may result from switch contact bounce or electrical noise. The default filter time of 6.4 ms blocks unwanted transitions from typical mechanical contacts.
Page 173
Configuring filter times for digital inputs used as HSCs For inputs that you use as high-speed counters (HSCs), change the input filter time to an appropriate value to avoid missing counts. Siemens recommends the following settings: Type of HSC Recommended input filter time 1 MHz 0.1 microseconds...
Device configuration 6.6 Configuring the operation of the CPU 6.6.3 Pulse catch The S7-1200 CPU provides a pulse catch feature for digital input points. The pulse catch feature allows you to capture high-going pulses or low-going pulses that are of such a short duration that they would not always be seen when the CPU reads the digital inputs at the beginning of the scan cycle.
Device configuration 6.7 Configuring multilingual support Configuring multilingual support The Multilingual support settings allow you to assign one of two project languages for each user interface language for the S7-1200 Web server (Page 1001). You can also configure no project language for a user interface language. What is a project language? The project language is the language that the TIA Portal uses to display user-defined project texts as network comments and block comments.
Page 176
Device configuration 6.8 Configuring the parameters of the modules Project language correspondence to user interface language in the Web server The Web server supports the same user interface languages as the TIA Portal; however, it only supports up to two project languages. You can configure the Web server to use one of two project languages for diagnostic buffer text entries depending on the user interface language of the Web server.
Device configuration 6.8 Configuring the parameters of the modules Configuring the parameters of the modules To configure the operational parameters for the modules, select the module in the Device view and use the "Properties" tab of the inspector window to configure the parameters for the module.
Page 178
Device configuration 6.8 Configuring the parameters of the modules Configuring a communication interface (CM, CP or CB) Depending on the type of communication interface, you configure the parameters for the network. S7-1200 Programmable controller System Manual, V4.2, 09/2016, A5E02486680-AK...
Device configuration 6.9 Configuring the CPU for communication Configuring the CPU for communication The S7-1200 is designed to solve your communications and networking needs by supporting not only the simplest of networks but also supporting more complex networks. The S7-1200 also provides tools that allow you to communicate with other devices, such as printers and weigh scales which use their own communications protocols.
Page 180
Device configuration 6.10 Time synchronization For the TCP, ISO-on-TCP, and UDP Ethernet protocols, use the "Properties" of the instruction (TSEND_C, TRCV_C, or TCON) to configure the "Local/Partner" connections. The figure shows the "Connection properties" of the "Configuration tab" for an ISO-on-TCP con- nection.
NTP server or through a CP in the local rack of the S7-1200 that is connected to a SCADA system which includes a master clock. Refer to S7-1200 CPs (https://support.industry.siemens.com/cs/us/en/ps) at Siemens Industry Online Support, Product Support for further information on all S7-1200 CPs that support the Time sychronization function.
Page 182
Device configuration 6.10 Time synchronization When you activate time synchronization in a module, the Engineering Station (ES) prompts you to select the "CPU synchronizes the modules of the device." if you have not already selected the check box in the CPU’s "Time synchronization" dialog. The ES also warns you if you configured more than one master clock source for time synchronization (for example, you activated time synchronization on more than one CP or on both the CPU and a module).
Programming concepts Guidelines for designing a PLC system When designing a PLC system, you can choose from a variety of methods and criteria. The following general guidelines can apply to many design projects. Of course, you must follow the directives of your own company's procedures and the accepted practices of your own training and location.
Page 184
Programming concepts 7.1 Guidelines for designing a PLC system Recommended steps Tasks Specify the operator Based on the requirements of the functional specifications, create the following drawings of the stations operator stations: Overview drawing that shows the location of each operator station in relation to the process •...
Programming concepts 7.2 Structuring your user program Structuring your user program When you create a user program for the automation tasks, you insert the instructions for the program into code blocks: ● An organization block (OB) responds to a specific event in the CPU and can interrupt the execution of the user program.
Page 186
Programming concepts 7.2 Structuring your user program Choosing the type of structure for your user program Based on the requirements of your application, you can choose either a linear structure or a modular structure for creating your user program: ● A linear program executes all of the instructions for your automation tasks in sequence, one after the other.
Programming concepts 7.3 Using blocks to structure your program Using blocks to structure your program By designing FBs and FCs to perform generic tasks, you create modular code blocks. You then structure your program by having other code blocks call these reusable modules. The calling block passes device-specific parameters to the called block.
Programming concepts 7.3 Using blocks to structure your program 7.3.1 Organization block (OB) Organization blocks provide structure for your program. They serve as the interface between the operating system and the user program. OBs are event driven. An event, such as a diagnostic interrupt or a time interval, causes the CPU to execute an OB.
Page 189
Programming concepts 7.3 Using blocks to structure your program Creating additional OBs You can create multiple OBs for your user program, even for the program cycle and startup OB events. Use the "Add new block" dialog to create an OB and enter a name for your OB. If you create multiple program cycle OBs for your user program, the CPU executes each program cycle OB in numerical sequence, starting with the program cycle OB with the lowest number (such as OB 1).
Programming concepts 7.3 Using blocks to structure your program 7.3.2 Function (FC) A function (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. For example, use FCs to perform standard and reusable operations (such as for mathematical calculations) or technological functions (such as for individual controls using bit logic operations).
Page 191
Programming concepts 7.3 Using blocks to structure your program Assigning the start value in the instance DB The instance DB stores both a default value and a start value for each parameter. The start value provides the value to be used when the FB is executed. The start value can then be modified during the execution of your user program.
Programming concepts 7.3 Using blocks to structure your program 7.3.4 Data block (DB) You create data blocks (DB) in your user program to store data for the code blocks. All of the program blocks in the user program can access the data in a global DB, but an instance DB stores data for a specific function block (FB).
Page 193
Programming concepts 7.3 Using blocks to structure your program Optimized and standard data blocks You can also configure a data block to be either standard or optimized. A standard DB is compatible with STEP 7 Classic programming tools and the classic S7-300 and S7-400 CPUs.
Programming concepts 7.3 Using blocks to structure your program 7.3.5 Creating reusable code blocks Use the "Add new block" dialog under "Program blocks" in the Project navi- gator to create OBs, FBs, FCs, and global DBs. When you create a code block, you select the pro- gramming language for the block.
Programming concepts 7.3 Using blocks to structure your program 7.3.6 Passing parameters to blocks Function Blocks (FB) and Functions (FC) have three different interface types: ● IN ● IN/OUT ● OUT FBs and FCs receive parameters through the IN and IN/OUT interface types. The blocks process the parameters and return values to the caller through the IN/OUT and OUT interface types.
Page 196
DB is different for optimized versus non-optimized DBs. Refer to the "Optimized blocks" section of the S7-Programming Guideline for S7-1200/1500, STEP 7 (TIA Portal), 03/2014 (http://support.automation.siemens.com/WW/view/en/81318674) for a discussion of optimized blocks. You create FBs and FCs to process either optimized or non-optimized data. You can select the "Optimized block access"...
Page 197
Programming concepts 7.3 Using blocks to structure your program Effect of optimization settings on user programs The copying of the parameter can cause an issue in a user program if an HMI or interrupt OB modifies elements of the structure. For example, there is an IN/OUT parameter of a function (normally passed as "call-by-reference"), but the optimization settings of the data block and function are different: 1.
Programming concepts 7.4 Understanding data consistency Understanding data consistency The CPU maintains the data consistency for all of the elementary data types (such as Words or DWords) and all of the system-defined structures (for example, IEC_TIMERS or DTL). The reading or writing of the value cannot be interrupted. (For example, the CPU protects the access to a DWord value until the four bytes of the DWord have been read or written.) To ensure that the program cycle OBs and the interrupt OBs cannot write to the same memory location at the same time, the CPU does not execute an interrupt OB until the read or write...
Programming concepts 7.5 Programming language Programming language STEP 7 provides the following standard programming languages for S7-1200: ● LAD (ladder logic) is a graphical programming language. The representation is based on circuit diagrams (Page 199). ● FBD (Function Block Diagram) is a programming language that is based on the graphical logic symbols used in Boolean algebra (Page 200).
Programming concepts 7.5 Programming language Consider the following rules when creating a LAD network: ● You cannot create a branch that could result in a power flow in the reverse direction. ● You cannot create a branch that would cause a short circuit. 7.5.2 Function Block Diagram (FBD) Like LAD, FBD is also a graphical programming language.
Programming concepts 7.5 Programming language 7.5.3 Structured Control Language (SCL) is a high-level, PASCAL-based programming language for the SIMATIC S7 CPUs. SCL supports the block structure of STEP 7 (Page 187). Your project can include program blocks in any of the three programming languages: SCL, LAD, and FBD.
Programming concepts 7.5 Programming language 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.
Page 203
Programming concepts 7.5 Programming language The result of an expression can be used either for assigning a value to a tag used by your program, as a condition to be used by a control statement, or as parameters for another SCL instruction or for calling a code block.
Page 204
Programming concepts 7.5 Programming language Control statements A control statement is a specialized type of SCL expression that performs the following tasks: ● Program branching ● Repeating sections of the SCL program code ● Jumping to other parts of the SCL program ●...
Page 205
Programming concepts 7.5 Programming language Calling other code blocks from your SCL program To call another code block in your user program, simply enter the name (or absolute address) of the FB or FC with the parameters. For an FB, you must provide the instance DB to be called with the FB.
Programming concepts 7.5 Programming language 7.5.3.3 Indexed addressing with PEEK and POKE instructions SCL provides PEEK and POKE instructions that allow you to read from or write to data blocks, I/O, or memory. You provide parameters for specific byte offsets or bit offsets for the operation.
Page 207
Programming concepts 7.5 Programming language POKE(area:=_in_, Writes the value (Byte, Word, or DWord) to dbNumber:=_in_, the referenced byteOffset of the referenced byteOffset:=_in_, data block, I/O or memory area value:=_in_); Example referencing data block: POKE(area:=16#84, dbNumber:=2, byteOffset:=3, value:="Tag_1"); Example referencing QB3 output: POKE(area:=16#82, dbNumber:=0, byteOffset:=3, value:="Tag_1");...
Programming concepts 7.5 Programming language 7.5.4 EN and ENO for LAD, FBD and SCL Determining "power flow" (EN and ENO) for an instruction Certain instructions (such as the Math and the Move instructions) provide parameters for EN and ENO. These parameters relate to power flow in LAD or FBD and determine whether the instruction is executed during that scan.
Page 209
Programming concepts 7.5 Programming language Using ENO in program code You can also use ENO in your program code, for example by assigning ENO to a PLC tag, or by evaluating ENO in a local block. Examples: “MyFunction” ( IN1 := … , IN2 := …...
Programming concepts 7.6 Protection Protection 7.6.1 Access protection for the CPU The CPU provides four levels of security for restricting access to specific functions. When you configure the security level and password for a CPU, you limit the functions and memory areas that can be accessed without entering a password.
Page 211
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 1005) with strong passwords.
Programming concepts 7.6 Protection 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.
Programming concepts 7.6 Protection 7.6.3 Know-how protection Know-how protection allows you to prevent one or more code blocks (OB, FB, FC, or DB) in your program from unauthorized access. You create a password to limit access to the code block. The password-protection prevents unauthorized reading or modification of the code block.
Programming concepts 7.6 Protection 7.6.4 Copy protection An additional security feature allows you to bind program blocks for use with a specific memory card or CPU. This feature is especially useful for protecting your intellectual property. When you bind a program block to a specific device, you restrict the program or code block for use only with a specific memory card or CPU.
Page 215
Programming concepts 7.6 Protection 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.
Programming concepts 7.7 Downloading the elements of your program Downloading the elements of your program You can download the elements of your project from the programming device to the CPU. When you download a project, the CPU stores the user program (OBs, FCs, FBs and DBs) in internal load memory or if a SIMATIC memory card is present in external load memory (the card).
Page 217
Programming concepts 7.7 Downloading the elements of your program Downloading when the configured CPU is different from the connected CPU STEP 7 and the S7-1200 permit a download if the connected CPU has the capacity to store a download from the configured CPU, based on the memory requirements of the project and the compatibility of the I/O.
Page 218
Programming concepts 7.7 Downloading the elements of your program STEP 7 and the S7-1200 prohibit a download if the connected CPU does not have the capacity to store a download from the configured CPU; for example, you cannot download the hardware configuration and program for the following cases: ●...
Programming concepts 7.8 Synchronizing the online CPU and offline project See also Synchronizing the online CPU and offline project (Page 219) Synchronizing the online CPU and offline project When you download project blocks to the CPU, the CPU can detect whether blocks or tags have changed in the online CPU since the last download.
Page 220
Programming concepts 7.8 Synchronizing the online CPU and offline project Synchronization choices When you download a project to the CPU, you see the synchronization dialog if STEP 7 detects that data blocks or tags in the online CPU are newer than the project values. For example, if the STEP 7 program has executed WRIT_DBL and changed a start value for a tag in Data_block_1, STEP 7 displays the following synchronization dialog when you initiate a download:...
Programming concepts 7.9 Uploading from the online CPU Uploading from the online CPU You can also copy the program blocks from an online CPU or a memory card attached to your programming device. Prepare the offline project for the copied program blocks: 1.
Programming concepts 7.10 Debugging and testing the program 7.10 Debugging and testing the program 7.10.1 Monitor and modify data in the CPU As shown in the following table, you can monitor and modify values in the online CPU. Table 7- 5 Monitoring and modifying data with STEP 7 Editor Monitor...
Programming concepts 7.10 Debugging and testing the program 7.10.2 Watch tables and force tables You use "watch tables" for monitoring and modifying the values of a user program being executed by the online CPU. You can create and save different watch tables in your project to support a variety of test environments.
Page 224
Programming concepts 7.10 Debugging and testing the program 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.
Programming concepts 7.10 Debugging and testing the program 7.10.4 Call structure to examine the calling hierarchy The call structure describes the call hierarchy of the block within your user program. It provides an overview of the blocks used, calls to other blocks, the relationships between blocks, the data requirements for each block, and the status of the blocks.
Page 226
Programming concepts 7.10 Debugging and testing the program S7-1200 Programmable controller System Manual, V4.2, 09/2016, A5E02486680-AK...
Basic instructions Bit logic operations 8.1.1 Bit logic instructions LAD and FBD are very effective for handling Boolean logic. While SCL is especially effective for complex mathematical computation and for project control structures, you can use SCL for Boolean logic. LAD contacts Table 8- 1 Normally open and normally closed contacts...
Page 228
Basic instructions 8.1 Bit logic operations FBD AND, OR, and XOR boxes In FBD programming, LAD contact networks are transformed into AND (&), OR (>=1), and EXCLUSIVE OR (x) box networks where you can specify bit values for the box inputs and outputs.
Page 229
Basic instructions 8.1 Bit logic operations NOT logic inverter Table 8- 5 Invert RLO (Result of Logic Operation) Description 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.
Basic instructions 8.1 Bit logic operations Table 8- 7 Data types for the parameters Parameter Data type Description Bool Assigned bit ● If there is power flow through an output coil or an FBD "=" box is enabled, then the output bit is set to 1.
Page 231
Basic instructions 8.1 Bit logic operations Set and Reset Bit Field Table 8- 10 SET_BF and RESET_BF instructions Description Not available Set bit field: When SET_BF is activated, a data value of 1 is assigned to "n" bits starting at address tag OUT. When SET_BF is not activat- ed, OUT is not changed.
Page 232
Basic instructions 8.1 Bit logic operations Table 8- 13 Data types for the parameters Parameter Data type Description S, S1 Bool Set input; 1 indicates dominance R, R1 Bool Reset input; 1 indicates dominance INOUT Bool Assigned bit tag "INOUT" Bool Follows state of "INOUT"...
Basic instructions 8.1 Bit logic operations 8.1.3 Positive and negative edge instructions Table 8- 14 Positive and negative transition detection Description Not available Scan operand for positive signal edge. LAD: The state of this contact is TRUE when a positive transition (OFF- to-ON) is detected on the assigned "IN"...
Page 234
Basic instructions 8.1 Bit logic operations Table 8- 15 P_TRIG and N_TRIG LAD / FBD Description Not available Scan RLO (result of logic operation) for positve signal edge. The Q output power flow or logic state is TRUE when a positive transi- tion (OFF-to-ON) is detected on the CLK input state (FBD) or CLK pow- er flow in (LAD).
Page 235
Basic instructions 8.1 Bit logic operations For R_TRIG and F_TRIG, when you insert the instruction in the program, the "Call options" dialog opens automatically. In this dialog you can assign whether the edge memory bit is stored in its own data block (single instance) or as a local tag (multiple instance) in the block interface.
Basic instructions 8.2 Timer operations Timer operations You use the timer instructions to create programmed time delays. The number of timers that you can use in your user program is limited only by the amount of memory in the CPU. Each timer uses a 16 byte IEC_Timer data type DB structure to store timer data that is specified at the top of the box or coil instruction.
Page 237
Basic instructions 8.2 Timer operations Table 8- 19 Data types for the parameters Parameter Data type Description Box: IN Bool TP, TON, and TONR: Coil: Power flow Box: 0=Disable timer, 1=Enable timer Coil: No power flow=Disable timer, Power flow=Enable timer TOF: Box: 0=Enable timer, 1=Disable timer Coil: No power flow=Enable timer, Power flow=Disable timer...
Page 238
Basic instructions 8.2 Timer operations Timer coil example The -(TP)-, -(TON)-, -(TOF)-, and -(TONR)- timer coils must be the last instruction in a LAD 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.
Page 239
Basic instructions 8.2 Timer operations Operation of the timers Table 8- 22 Types of IEC timers Timer Timing diagram TP: Generate pulse The TP timer generates a pulse with a preset width time. TON: Generate ON-delay The TON timer sets output Q to ON after a preset time delay.
Page 240
Basic instructions 8.2 Timer operations Timer Timing diagram TOF: Generate OFF-delay The TOF timer resets output Q to OFF after a preset time delay. TONR: Time accumulator The TONR timer sets output Q to ON after a preset time delay. Elapsed time is accumulated over multiple timing periods until the R input is used to reset the elapsed time.
Page 241
Basic instructions 8.2 Timer operations A timer update is performed when and only when: ● A timer instruction (TP, TON, TOF, or TONR) is executed ● The "ELAPSED" member of the timer structure in DB is referenced directly by an instruction ●...
Page 242
Basic instructions 8.2 Timer operations Time data retention after a RUN-STOP-RUN transition or a CPU power cycle If a run mode session is ended with stop mode or a CPU power cycle and a new run mode session is started, then the timer data stored in the previous run mode session is lost, unless the timer data structure is specified as retentive (TP, TON, TOF, and TONR timers).
Page 243
Basic instructions 8.2 Timer operations Assign a multi-instance DB to store timer data as retentive data This option only works if you place the timer in an FB. This option depends upon whether the FB properties specify "Optimized block access" (allows symbolic access only).
Basic instructions 8.3 Counter operations Counter operations Table 8- 23 Counter instructions LAD / FBD Description "IEC_Counter_0_DB".CTU Use the counter instructions to count internal program events and external process events. Each counter uses a structure stored in a CU:=_bool_in, data block to maintain counter data. You assign the data block when the counter instruction is placed in the editor.
Page 245
Basic instructions 8.3 Counter operations The number of counters that you can use in your user program is limited only by the amount of memory in the CPU. Counters use the following amount of memory: ● For SInt or USInt data types, the counter instruction uses 3 bytes. ●...
Page 246
Basic instructions 8.3 Counter operations Table 8- 26 Operation of CTD (count down) Counter Operation The CTD counter counts down by 1 when the value of parame- ter CD changes from 0 to 1. The CTD timing diagram shows the operation for an unsigned integer count value (where PV = If the value of parameter CV (current count value) is equal •...
Page 247
Basic instructions 8.3 Counter operations Counter data retention after a RUN-STOP-RUN transition or a CPU power cycle If a run mode session is ended with stop mode or a CPU power cycle and a new run mode session is started, then the counter data stored in the previous run mode session is lost, unless the counter data structure is specified as retentive (CTU, CTD, and CTUD counters).
Page 248
Basic instructions 8.3 Counter operations 5. When the call options dialog appears, click the cancel button. You should now see a new counter instruction which has "???" both just above and just below the instruction name. 6. On the top of the new counter instruction, type the name (do not use the helper to browse) of the global DB and counter structure that you created above (example: "Data_block_3.Static_1").
Page 249
Basic instructions 8.3 Counter operations If the FB does not specify "Optimized block access", then the block access type is standard, which is compatible with S7-300/400 classic configurations and allows symbolic and direct access. To assign a multi-instance to a standard block access FB, follow these steps: 1.
Basic instructions 8.4 Comparator operations Comparator operations 8.4.1 Compare values instructions Table 8- 28 Compare instructions Description out := in1 = in2; Compares two values of the same data type. When the LAD contact comparison is TRUE, then the contact is activated.
Basic instructions 8.4 Comparator operations 8.4.2 IN_Range (Value within range) and OUT_Range (Value outside range) Table 8- 31 Value within Range and value outside range instructions LAD / FBD Description out := IN_RANGE(min, Tests whether an input value is in or out of a specified value range. val, max);...
Basic instructions 8.4 Comparator operations 8.4.3 OK (Check validity) and NOT_OK (Check invalidity) Table 8- 33 OK (check validity) and Not OK (check invalidity) instructions Description Not available Tests whether an input data reference is a valid real num- ber according to IEEE specification 754. Not available For LAD and FBD: When the LAD contact is TRUE, the contact is activated and passes power flow.
Basic instructions 8.4 Comparator operations 8.4.4 Variant and array comparison instructions 8.4.4.1 Equality and non-equality comparison instructions The S7-1200 CPU provides instructions for querying the data type of a tag to which a Variant operand points for either equality or non-equality to the data type of the other operand. In addition, the S7-1200 CPU provides instructions for querying the data type of an array element for either equality or non-equality to the data type of the other operand.
Basic instructions 8.4 Comparator operations Table 8- 37 Data types for the parameters Parameter Data type Description Operand1 Variant First operand Operand2 Bit strings, integers, floating-point numbers, Second operand timers, date and time, character strings, ARRAY, PLC data types 8.4.4.2 Null comparsion instructions You can use the instructions IS_NULL and NOT_NULL to determine whether or not the input actually points to an object or not.
Basic instructions 8.5 Math functions Table 8- 41 Data types for the parameters Parameter Data type Description Operand Variant Operand to evaluate for whether it is an array. Math functions 8.5.1 CALCULATE (Calculate) Table 8- 42 CALCULATE instruction LAD / FBD Description Use the stand- The CALCULATE instruction lets you create a math function that oper-...
Page 256
Basic instructions 8.5 Math functions 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...
Basic instructions 8.5 Math functions Table 8- 46 ENO status Description No error The Math operation result value would be outside the valid number range of the data type selected. The least significant part of the result that fits in the destination size is returned. Division by 0 (IN2 = 0): The result is undefined and zero is returned.
Basic instructions 8.5 Math functions 8.5.4 NEG (Create twos complement) Table 8- 50 NEG (create twos complement) instruction LAD / FBD Description -(in); The NEG instruction inverts the arithmetic sign of the value at parameter IN and stores the result in parameter OUT. For LAD and FBD: Click the "???"...
Basic instructions 8.5 Math functions Table 8- 54 Data types for parameters Parameter Data type Description IN/OUT SInt, Int, DInt, USInt, UInt, UDInt Math operation input and output Table 8- 55 ENO status Description No error The resulting value is outside the valid number range of the selected data type. Example for SInt: INC (+127) results in +128, which exceeds the data type maximum.
Basic instructions 8.5 Math functions 8.5.7 MIN (Get minimum) and MAX (Get maximum) Table 8- 59 MIN (get minimum) and MAX (get maximum) instructions LAD / FBD Description out:= MIN( The MIN instruction compares the value of two parameters IN1 in1:=_variant_in_, and IN2 and assigns the minimum (lesser) value to parameter in2:=_variant_in_...
Basic instructions 8.5 Math functions 8.5.8 LIMIT (Set limit value) Table 8- 62 LIMIT (set limit value) instruction LAD / FBD Description LIMIT(MN:=_variant_in_, The Limit instruction tests if the value of parameter IN is inside the IN:=_variant_in_, value range specified by parameters MIN and MAX and if not, MX:=_variant_in_, clamps the value at MIN or MAX.
Basic instructions 8.5 Math functions 8.5.9 Exponent, logarithm, and trigonometry instructions You use the floating point instructions to program mathematical operations using a Real or LReal data type: ● SQR: Form square (IN = OUT) ● SQRT: Form square root (√IN = OUT) ●...
Page 264
Basic instructions 8.5 Math functions Table 8- 66 Data types for parameters Parameter Data type Description IN, IN1 Real, LReal, Constant Inputs SInt, Int, DInt, USInt, UInt,UDInt, Real, LReal, Constant EXPT exponent input Real, LReal Outputs Table 8- 67 ENO status Instruction Condition Result (OUT)
Basic instructions 8.6 Move operations Move operations 8.6.1 MOVE (Move value), MOVE_BLK (Move block), UMOVE_BLK (Move block uninterruptible), and MOVE_BLK_VARIANT (Move block) Use the Move instructions to copy data elements to a new memory address and convert from one data type to another. The source data is not changed by the move process. ●...
Page 266
Basic instructions 8.6 Move operations Table 8- 69 Data types for the MOVE instruction Parameter Data type Description SInt, Int, DInt, USInt, UInt, UDInt, Real, LReal, Byte, Word, Source address DWord, Char, WChar, Array, Struct, DTL, Time, Date, TOD, IEC data types, PLC data types SInt, Int, DInt, USInt, UInt, UDInt, Real, LReal, Byte, Word, Destination address DWord, Char, WChar, Array, Struct, DTL, Time, Date, TOD,...
Page 267
Basic instructions 8.6 Move operations Note Rules for data copy operations • To copy the Bool data type, use SET_BF, RESET_BF, R, S, or output coil (LAD) (Page 230) • To copy a single elementary data type, use MOVE • To copy an array of an elementary data type, use MOVE_BLK or UMOVE_BLK •...
Page 268
Basic instructions 8.6 Move operations Table 8- 73 Condition codes for the MOVE_BLK_VARIANT instruction RET_VAL Description (W#16#...) 0000 No error 80B4 Data types do not correspond. 8151 Access to the SRC parameter is not possible. 8152 The operand at the SRC parameter is an invalid type. 8153 Code generation error at the SRC parameter 8154...
Basic instructions 8.6 Move operations 8.6.2 Deserialize You can use the "Deserialize" instruction to convert the sequential representation of a PLC data type (UDT) back to a PLC data type and to fill its entire contents. If the comparison is TRUE, then the box output is TRUE.
Page 270
Basic instructions 8.6 Move operations Table 8- 76 RET_VAL parameter RET_VAL Description (W#16#...) 0000 No error 80B0 The memory areas for the SRC_ARRAY and DEST_VARIABLE parameters overlap. 8136 The data block at the DEST_VARIABLE parameter is not a block with standard access. 8150 The Variant data type at the SRC_ARRAY parameter contains no value.
Page 271
Basic instructions 8.6 Move operations Function block (or Function) interface: Custom PLC data types: The structure of the two PLC data types (UDTs) for this example are as follows: Data blocks: The two data blocks for this example are as follows: S7-1200 Programmable controller System Manual, V4.2, 09/2016, A5E02486680-AK...
Basic instructions 8.6 Move operations 8.6.3 Serialize You can use the "Serialize" instruction to convert several PLC data types (UDTs) to a sequential representation without any loss of structure. You can use the instruction to temporarily save multiple structured data items from your program to a buffer, for example to a global data block, and send them to another CPU.
Page 273
Basic instructions 8.6 Move operations Table 8- 79 RET_VAL parameter RET_VAL Description (W#16#...) 0000 No error 80B0 The memory areas for the SRC_VARIABLE and DEST_ARRAY parameters overlap. 8150 The Variant data type at the SRC_VARIABLE parameter contains no value. 8152 Code generation error at the SRC_VARIABLE parameter.
Page 274
Basic instructions 8.6 Move operations Block Interface: Custom PLC data types: The structure of the two PLC data types (UDTs) for this example are as follows: Data blocks: The two data blocks for this example are as follows: S7-1200 Programmable controller System Manual, V4.2, 09/2016, A5E02486680-AK...
Basic instructions 8.6 Move operations 8.6.4 FILL_BLK (Fill block) and UFILL_BLK (Fill block uninterruptible) Table 8- 80 FILL_BLK and UFILL_BLK instructions LAD / FBD Description FILL_BLK( Interruptible fill instruction: Fills an address range with copies of a in:=_variant_in, specified data element count:=int, out=>_variant_out);...
Basic instructions 8.6 Move operations Table 8- 82 ENO status Condition Result No error The IN element was successfully copied to all COUNT destinations. The destination (OUT) range exceeds Elements that fit are copied. No partial ele- the available memory area ments are copied.
Basic instructions 8.6 Move operations 8.6.6 LOWER_BOUND: (Read out ARRAY low limit) Table 8- 85 LOWER_BOUND instruction LAD / FBD Description out := LOWER_BOUND( You can declare tags with ARRAY[*] in the block ARR:=_variant_in_, interface. For these local tags, you can read out DIM:=_udint_in_);...
Page 278
Basic instructions 8.6 Move operations Example In the function (FC) block interface, the input parameter ARRAY_A is a one-dimensional array with variable dimensions. If the "Enable_Start" operand returns signal state "1", the CPU executes the LOWER_BOUND instruction. It reads out the variable low limit of the ARRAY #ARRAY_A from the one-dimensional array.
Basic instructions 8.6 Move operations 8.6.7 UPPER_BOUND: (Read out ARRAY high limit) Table 8- 86 LOWER_BOUND instruction LAD / FBD Description out := UPPER_BOUND( You can declare tags with ARRAY[*] in the block ARR:=_variant_in_, interface. For these local tags, you can read out DIM:=_udint_in_);...
Page 280
Basic instructions 8.6 Move operations Example In the function (FC) block interface, the input parameter ARRAY_A is a one-dimensional array with variable dimensions. If the "Enable_Start" operand returns signal state "1", the CPU executes the instruction. It reads out the variable high limit of the ARRAY #ARRAY_A from the one-dimensional array. If the instruction executes without errors, it sets operand "Enable_Out"...
Basic instructions 8.6 Move operations 8.6.8 Read / Write memory instructions 8.6.8.1 PEEK and POKE (SCL only) SCL provides PEEK and POKE instructions that allow you to read from or write to data blocks, I/O, or memory. You provide parameters for specific byte offsets or bit offsets for the operation.
Page 282
Basic instructions 8.6 Move operations POKE(area:=_in_, Writes the value (Byte, Word, or DWord) to dbNumber:=_in_, the referenced byteOffset of the referenced byteOffset:=_in_, data block, I/O or memory area value:=_in_); Example referencing data block: POKE(area:=16#84, dbNumber:=2, byteOffset:=3, value:="Tag_1"); Example referencing QB3 output: POKE(area:=16#82, dbNumber:=0, byteOffset:=3, value:="Tag_1");...
Basic instructions 8.6 Move operations 8.6.8.2 Read and write big and little Endian instructions (SCL) The S7-1200 CPU provides SCL instructions for reading and writing data in little endian format and in big endian format. Little endian format means that the byte with the least significant bit is in the lowest memory address.
Page 284
Basic instructions 8.6 Move operations Table 8- 89 Parameters for the WRITE_LITTLE and WRITE_BIG instructions Parameter Data type Description src_variable Bit strings, integers, floating-point numbers, LDT, TOD, LTOD, Source data from tag DATA, Char, WChar dest_array Array of Byte Memory area at which to write data DINT Zero-based position at which to start writing data into the dest_array...
Basic instructions 8.6 Move operations 8.6.9 Variant instructions 8.6.9.1 VariantGet (Read VARIANT tag value) You can use the "Read out Variant tag value" instruction to read the value of the tag to which the Variant pointer at the SRC parameter points and write it in the tag at the DST parameter. The SRC parameter has the Variant data type.
Basic instructions 8.6 Move operations 8.6.9.2 VariantPut (Write VARIANT tag value) You can use the "Write VARIANT tag value" instruction to write the value of the tag at the SRC parameter to the tag at the DST parameter to which the VARIANT points. The DST parameter has the VARIANT data type.
Basic instructions 8.6 Move operations 8.6.9.3 CountOfElements (Get number of ARRAY elements) You can use the "Get number of ARRAY elements" instruction to query how many Array elements are in a tag pointed to by a Variant. If it is a one-dimensional ARRAY, the instruction returns the difference between the high and low limit +1 is output.
Basic instructions 8.6 Move operations 8.6.10 Legacy instructions 8.6.10.1 FieldRead (Read field) and FieldWrite (Write field) instructions Note STEP 7 V10.5 did not support a variable reference as an array index or multi-dimensional arrays. The FieldRead and FieldWrite instructions were used to provide variable array index operations for a one-dimensional array.
Page 289
Basic instructions 8.6 Move operations The enable output ENO = 0, if one of the following conditions applies: ● The EN input has signal state "0" ● The array element specified at the INDEX parameter is not defined in the array referenced at MEMBER parameter ●...
Basic instructions 8.7 Conversion operations Conversion operations 8.7.1 CONV (Convert value) Table 8- 102 Convert (CONV) instruction LAD / FBD Description out := <data type in>_TO_<data type out>(in); Converts a data element from one data type to another data type. For LAD and FBD: Click the "???"...
Basic instructions 8.7 Conversion operations 8.7.2 Conversion instructions for SCL Conversion instructions for SCL Table 8- 105 Conversion from a Bool, Byte, Word, or DWord Data type Instruction Result BOOL_TO_BYTE, BOOL_TO_WORD, Bool The value is transferred to the least significant bit of the BOOL_TO_DWORD, BOOL_TO_INT, target data type.
Page 292
Basic instructions 8.7 Conversion operations Table 8- 106 Conversion from a short integer (SInt or USInt) Data type Instruction Result SINT_TO_BOOL SInt The least significant bit is transferred into the destination data type. SINT_TO_BYTE The value is transferred to the target data type SINT_TO_WORD, SINT_TO_DWORD The value is transferred to the least significant byte of the target data type.
Page 293
Basic instructions 8.7 Conversion operations Table 8- 108 Conversion from a double integer (Dint or UDInt) Data type Instruction Result DINT_TO_BOOL DInt The least significant bit is transferred into the destination data type. DINT_TO_BYTE, DINT_TO_WORD, DINT_TO_SINT, The value is converted. DINT_TO_USINT, DINT_TO_INT, DINT_TO_UINT, DINT_TO_UDINT, DINT_TO_REAL, DINT_TO_LREAL, DINT_TO_CHAR, DINT_TO_STRING...
Basic instructions 8.7 Conversion operations Table 8- 111 Conversion from a Char or String Data type Instruction Result CHAR_TO_SINT, CHAR_TO_USINT, Char The value is converted. CHAR_TO_INT, CHAR_TO_UINT, CHAR_TO_DINT, CHAR_TO_UDINT CHAR_TO_STRING The value is transferred to the first character of the string. STRING_TO_SINT, STRING_TO_USINT, String The value is converted.
Basic instructions 8.7 Conversion operations Table 8- 114 ENO status Description Result OUT No error Valid result IN is +/- INF or +/- NaN +/- INF or +/- NaN 8.7.4 CEIL and FLOOR (Generate next higher and lower integer from floating-point number) Table 8- 115 CEIL and FLOOR instructions LAD / FBD...
Basic instructions 8.7 Conversion operations 8.7.5 SCALE_X (Scale) and NORM_X (Normalize) Table 8- 118 SCALE_X and NORM_X instructions LAD / FBD Description out :=SCALE_X(min:=_in_, Scales the normalized real parameter VALUE value:=_in_, where ( 0.0 <= VALUE <= 1.0 ) in the data type max:=_in_);...
Page 297
Basic instructions 8.7 Conversion operations Note SCALE_X parameter VALUE should be restricted to ( 0.0 <= VALUE <= 1.0 ) If parameter VALUE is less than 0.0 or greater than 1.0: • The linear scaling operation can produce OUT values that are less than the parameter MIN value or above the parameter MAX value for OUT values that fit within the value range of the OUT data type.
Page 298
Basic instructions 8.7 Conversion operations Example (LAD): normalizing and scaling an analog input value An analog input from an analog signal module or signal board using input in current is in the range 0 to 27648 for valid values. Suppose an analog input represents a temperature where the 0 value of the analog input represents -30.0 degrees C and 27648 represents 70.0 degrees C.
Basic instructions 8.7 Conversion operations 8.7.6 Variant conversion instructions 8.7.6.1 VARIANT_TO_DB_ANY (Convert VARIANT to DB_ANY) You use the "VARIANT to DB_ANY" instruction to read the operand at the IN parameter and convert it to the data type DB_ANY. The IN parameter is of the Variant data type and represents either an instance data block or an ARRAY data block.
Basic instructions 8.7 Conversion operations Description (W#16#...) 8132 The data block is too short and not an Array data block (second access). 8134 The data block is write-protected 8150 The data type Variant at parameter IN provides the value "0". To receive this error message, the "Handle errors within block"...
Page 301
Basic instructions 8.7 Conversion operations Table 8- 128 Error output codes for the DB_ANY_TO_VARIANT instruction Description (W#16#...) 0000 No error 8130 The number of the data block is 0. 8131 The data block does not exist or is too short. 8132 The data block is too short and not an Array data block.
Basic instructions 8.8 Program control operations Program control operations 8.8.1 JMP (Jump if RLO = 1), JMPN (Jump if RLO = 0), and Label (Jump label) instructions Table 8- 129 JMP, JMPN, and LABEL instruction Description See the GOTO (Page 325) Jump if RLO (result of logic operation) = 1: statement.
Basic instructions 8.8 Program control operations 8.8.2 JMP_LIST (Define jump list) Table 8- 131 JMP_LIST instruction LAD / FBD Description CASE k OF The JMP_LIST instruction acts as a program jump distributor to control 0: GOTO dest0; the execution of program sections. Depending on the value of the K 1: GOTO dest1;...
Basic instructions 8.8 Program control operations 8.8.3 SWITCH (Jump distributor) Table 8- 133 SWITCH instruction LAD / FBD Description Not available The SWITCH instruction acts as a program jump distributor to control the execution of program sections. Depending on the re- sult of comparisons between the value of the K input and the values assigned to the specified comparison inputs, a jump occurs to the program label that corresponds to the first comparison test...
Page 305
Basic instructions 8.8 Program control operations Adding inputs, deleting inputs, and specifying comparison types When the LAD or FBD SWITCH box is first placed in your program there are two comparison inputs. You can assign comparison types and add inputs/jump destinations, as shown below. Click a comparison operator inside the box and select a new operator from the drop-down list.
Basic instructions 8.8 Program control operations 8.8.4 RET (Return) The optional RET instruction is used to terminate the execution of the current block. If and only if there is power flow to the RET coil (LAD) or if the RET box input is true (FBD), then program execution of the current block will end at that point and instructions beyond the RET instruction will not be executed.
Basic instructions 8.8 Program control operations 8.8.5 ENDIS_PW (Enable/disable CPU passwords) Table 8- 138 ENDIS_PW instruction LAD / FBD Description ENDIS_PW( The ENDIS_PW instruction can allow and req:=_bool_in_, disallow client connections to a S7-1200 f_pwd:=_bool_in_, CPU, even when the client can provide the full_pwd:=_bool_in_, correct password.
Page 308
Basic instructions 8.8 Program control operations Calling ENDIS_PW with REQ=1 disallows password types where the corresponding password input parameter is FALSE. Each password type can be allowed or disallowed independently. For example, if the fail-safe password is allowed and all other passwords disallowed, then you can restrict CPU access to a small group of employees.
Basic instructions 8.8 Program control operations Note Password protect CPU access levels 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.
Basic instructions 8.8 Program control operations Setting the PLC maximum cycle time Configure the value for maximum scan cycle time in the Device configuration for "Cycle time". Table 8- 142 Cycle time values Cycle time monitor Minimum value Maximum value Default value Maximum cycle time 1 ms...
Basic instructions 8.8 Program control operations 8.8.8 GET_ERROR and GET_ERROR_ID (Get error and error ID locally) instructions The get error instructions provide information about program block execution errors. If you add a GET_ERROR or GET_ERROR_ID instruction to your code block, you can handle program errors within your program block.
Page 312
Basic instructions 8.8 Program control operations Structure components Data type Description Offset Area Location Scope Number Area Offset Area DB no. Offset PtrNo. Area DB no. Offset /Acc PtrNo. / Slot No. / Area DB no. Offset Scope OPERAND_NUMBER UInt Operand number of the machine command POINTER_NUMBER_ UInt...
Page 313
Basic instructions 8.8 Program control operations Table 8- 149 Error_ID values ERROR_ID hexa- ERROR_ID decimal Program block execution error decimal No error 2520 9504 Corrupted string 2522 9506 Operand out of range read error 2523 9507 Operand out of range write error 2524 9508 Invalid area read error...
Basic instructions 8.8 Program control operations The ErrorStruct data type used by the GET_ERROR instruction can be added in the data block editor and block interface editors, so your program logic can access these values. Select ErrorStruct from the data type drop-down list to add this structure. You can create multiple ErrorStruct elements by using unique names.
Page 315
Basic instructions 8.8 Program control operations The Measure program runtime" instruction uses an internal high-frequency counter to calculate the time. If the counter overruns, the instruction returns values <= 0.0. Ignore these runtime values. Note The CPU cannot exactly determine the runtime of a command sequence, because the sequence of instructions within a command sequence changes during optimized compilation of the program.
Basic instructions 8.8 Program control operations When the "Tag_1" operand in network 1 has the signal state "1", the RUNTIME instruction executes. The starting point for the runtime measurement is set with the first call of the instruction and buffered as reference for the second call of the instruction in the "Mem" operand.
Basic instructions 8.8 Program control operations 8.8.10.2 IF-THEN statement The IF-THEN statement is a conditional statement that controls program flow by executing a group of statements, based on the evaluation of a Bool value of a logical expression. You can also use brackets to nest or structure the execution of multiple IF-THEN statements. Table 8- 153 Elements of the IF-THEN statement Description IF "condition"...
Basic instructions 8.8 Program control operations 8.8.10.3 CASE statement Table 8- 155 Elements of the CASE statement Description CASE "Test_Value" OF The CASE statement executes one of several "ValueList": Statement[; Statement, ...] groups of statements, depending on the value "ValueList": Statement[; Statement, ...] of an expression.
Page 319
Basic instructions 8.8 Program control operations The CASE statement is executed according to the following rules: ● The Test_value expression must return a value of the type Int. ● When a CASE statement is processed, the program checks whether the value of the Test_value expression is contained within a specified list of values.
Basic instructions 8.8 Program control operations 8.8.10.4 FOR statement Table 8- 157 Elements of the FOR statement Description FOR "control_variable" := "begin" TO "end" A FOR statement is used to repeat a sequence of [BY "increment"] DO statements as long as a control variable is within statement;...
Basic instructions 8.8 Program control operations 8.8.10.5 WHILE-DO statement Table 8- 159 WHILE statement Description WHILE "condition" DO The WHILE statement performs a series of statements until a given condition is Statement; TRUE. Statement; You can nest WHILE loops. The END_WHILE statement refers to the last executed ...;...
Basic instructions 8.8 Program control operations 8.8.10.6 REPEAT-UNTIL statement Table 8- 161 REPEAT instruction Description REPEAT The REPEAT statement executes a group of statements until a given condition is Statement; TRUE. You can nest REPEAT loops. The END_REPEAT statement always refers to the last UNTIL "condition"...
Basic instructions 8.8 Program control operations 8.8.10.7 CONTINUE statement Table 8- 163 CONTINUE statement Description CONTINUE The CONTINUE statement skips the subsequent statements of a program loop (FOR, Statement; WHILE, REPEAT) and continues the loop with the examination of whether the condition is met for termination.
Basic instructions 8.8 Program control operations 8.8.10.8 EXIT statement Table 8- 164 EXIT instruction Description EXIT; An EXIT statement is used to exit a loop (FOR, WHILE or REPEAT) at any point, regardless of whether the terminate condition is satisfied. The EXIT statement executes according to the following rules: ●...
Basic instructions 8.8 Program control operations 8.8.10.9 GOTO statement Table 8- 165 GOTO statement Description GOTO JumpLabel; The GOTO statement skips over statements by jumping to a label in the same Statement; block..; The jump label ("JumpLabel") and the GOTO statement must be in the same block. JumpLabel: Statement;...
Basic instructions 8.9 Word logic operations Word logic operations 8.9.1 AND, OR, and XOR logic operation instructions Table 8- 167 AND, OR, and XOR logic operation instructions LAD / FBD Description out := in1 AND in2; AND: Logical AND out := in1 OR in2; OR: Logical OR out := in1 XOR in2;...
Basic instructions 8.9 Word logic operations 8.9.2 INV (Create ones complement) Table 8- 169 INV instruction LAD / FBD Description Not available Calculates the binary one's complement of the parameter IN. The one's complement is formed by inverting each bit value of the IN parameter (changing each 0 to 1 and each 1 to 0).
Page 328
Basic instructions 8.9 Word logic operations Table 8- 172 Data types for the parameters Parameter Data type Description ENCO: Byte, Word, DWord ENCO: Bit pattern to encode DECO: UInt DECO: Value to decode ENCO: Int ENCO: Encoded value DECO: Byte, Word, DWord DECO: Decoded bit pattern Table 8- 173 ENO status Condition...
Basic instructions 8.9 Word logic operations 8.9.4 SEL (Select), MUX (Multiplex), and DEMUX (Demultiplex) instructions Table 8- 175 SEL (select) instruction LAD / FBD Description out := SEL( SEL assigns one of two input values to parameter OUT, depending g:=_bool_in, on the parameter G value.
Page 330
Basic instructions 8.9 Word logic operations To add an input, click the "Create" icon or right-click on an input stub for one of the existing IN parameters and select the "Insert input" command. To remove an input, right-click on an input stub for one of the existing IN parameters (when there are more than the original two inputs) and select the "Delete"...
Page 331
Basic instructions 8.9 Word logic operations Table 8- 180 Data types for the DEMUX instruction Parameter Data type Description UInt Selector value: 0 selects OUT1 • 1 selects OUT2 • n selects OUTn • SInt, Int, DInt, USInt, UInt, UDInt, Real, LReal, Byte, Word, Input DWord, Time, Date, TOD, Char, WChar OUT0, OUT1, ..
Basic instructions 8.10 Shift and rotate 8.10 Shift and rotate 8.10.1 SHR (Shift right) and SHL (Shift left) instructions Table 8- 182 SHR and SHL instructions LAD / FBD Description out := SHR( Use the shift instructions (SHL and SHR) to shift the bit pattern of in:=_variant_in_, parameter IN.
Basic instructions 8.10 Shift and rotate 8.10.2 ROR (Rotate right) and ROL (Rotate left) instructions Table 8- 185 ROR and ROL instructions LAD / FBD Description out := ROL( Use the rotate instructions (ROR and ROL) to rotate the bit pattern of in:=_variant_in_, parameter IN.
Page 334
Basic instructions 8.10 Shift and rotate S7-1200 Programmable controller System Manual, V4.2, 09/2016, A5E02486680-AK...
Extended instructions Date, time-of-day, and clock functions 9.1.1 Date and time-of-day instructions Use the date and time instructions for calendar and time calculations. ● T_CONV converts a value to or from (date and time data types) and (byte, word, and dword size data types) ●...
Page 336
Extended instructions 9.1 Date, time-of-day, and clock functions Note Using T_CONV to convert a larger data size to a smaller data size Data values can be truncated when you convert a larger data type with more bytes to a smaller data type with less bytes. If this error occurs, then ENO is set to 0. Conversion to/from DTL data type DTL (Date and Time Long) contains year, month, date, and time data.
Page 337
Extended instructions 9.1 Date, time-of-day, and clock functions Table 9- 5 T_DIFF (Time difference) instruction LAD / FBD Description out := T_DIFF( T_DIFF subtracts the DTL value (IN2) from the DTL value (IN1). Pa- in1:=_DTL_in, rameter OUT provides the difference value as a Time data type. in2:=_DTL_in);...
CPU system time. 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. S7-1200 Programmable controller System Manual, V4.2, 09/2016, A5E02486680-AK...
Page 339
Extended instructions 9.1 Date, time-of-day, and clock functions Use the clock instructions to set and read the CPU system clock. The data type DTL (Page 128) is used to provide date and time values. Table 9- 9 System time instructions LAD / FBD Description ret_val :=...
Page 340
Extended instructions 9.1 Date, time-of-day, and clock functions Table 9- 10 Data types for the parameters Parameter and type Data type Description Time of day to set in the CPU system clock RD_SYS_T: Current CPU system time RD_LOC_T: Current local time, including any adjustment for daylight saving time, if configured LOCTIME WR_LOC_T: Local time...
Page 341
Extended instructions 9.1 Date, time-of-day, and clock functions Condition codes: ENO = 1 means no error occurred. ENO = 0 means an execution error occurred, and a condition code is provided at the RET_VAL output. RET_VAL (W#16#..) Description 0000 The current local time is in standard time. 0001 Daylight saving time has been configured, and the current local time is in daylight saving time.
Extended instructions 9.1 Date, time-of-day, and clock functions 9.1.3 TimeTransformationRule data structure Description The changeover rules for standard and daylight saving time are defined in the TimeTransformationRule structure. The structure is as follows: Name Data type Description TimeTransformationRule STRUCT Bias Time difference between local time and UTC [minutes] Range: -1439 to 1439 DaylightBias...
Extended instructions 9.1 Date, time-of-day, and clock functions 9.1.4 SET_TIMEZONE (Set timezone) Table 9- 11 SET_TIMEZONE instruction LAD / FBD Description "SET_TIMEZONE_DB"( Sets the local time zone and daylight sav- REQ:=_bool_in, ing parameters that are used to transform Timezone:=_struct_in, the CPU system time to local time. DONE=>_bool_out_, BUSY=>_bool_out_, ERROR=>_bool_out_,...
Extended instructions 9.1 Date, time-of-day, and clock functions 9.1.5 RTM (Runtime meters) Table 9- 13 RTM instruction LAD / FBD Description RTM(NR:=_uint_in_, The RTM (Runtime Meters) instruction can set, start, stop, and MODE:=_byte_in_, read the runtime hour meters in the CPU. PV:=_dint_in_, CQ=>_bool_out_, CV=>_dint_out_);...
Page 345
Extended instructions 9.1 Date, time-of-day, and clock functions Your program can also use RTM execution mode 7 to save the runtime meter values in a memory card. The states of all timers at the instant RTM mode 7 is executed are stored in the memory card.
Extended instructions 9.2 String and character String and character 9.2.1 String data overview String data type String data is stored as a 2-byte header followed by up to 254 character bytes of ASCII character codes. A String header contains two lengths. The first byte is the maximum length that is given in square brackets when you initialize a string, or 254 by default.
Extended instructions 9.2 String and character 9.2.3 String conversion instructions 9.2.3.1 S_CONV, STRG_VAL, and VAL_STRG (Convert to/from character string and number) instructions You can convert number character strings to number values or number values to number character strings with these instructions: ●...
Page 348
Extended instructions 9.2 String and character S_CONV (value to string conversion) Table 9- 20 Data types (value to string) Parameter and type Data type Description String, WString, Char, WChar, SInt, Int, DInt, USInt, UInt, UDInt, Input number value Real, LReal String, WString Output character string An integer, unsigned integer, or floating point value IN is converted to the corresponding...
Page 349
Extended instructions 9.2 String and character Table 9- 21 Maximum string lengths for each data type IN data type Character Converted string example Total string length including maximum and current length positions bytes allocated by S_CONV USInt "x255" 6 SInt "-128"...
Page 350
Extended instructions 9.2 String and character Conversion begins in the string IN at character offset P and continues until the end of the string, or until the first character is encountered that is not "+", "-", ".", ",", "e", "E", or "0" to "9".
Page 351
Extended instructions 9.2 String and character VAL_STRG (convert numerical value to string) Table 9- 26 Value-to-string operation LAD / FBD Description "VAL_STRG"( Converts an integer, unsigned integer, or floating point in:=_variant_in, value to the corresponding character string representa- size:=_usint_in, tion. prec:=_usint_in, format:=_word_in, p:=uint_in,...
Page 352
Extended instructions 9.2 String and character The FORMAT parameter for the VAL_STRG instruction is defined below. The unused bit positions must be set to zero. Table 9- 28 Format of the VAL_STRG instruction Bit 8 Bit 7 Bit 0 s = Number sign character 1= use sign character "+"...
Page 353
Extended instructions 9.2 String and character ● When the FORMAT is set to fixed point notation, integer, unsigned integer, and real data type values are written to the output buffer as: <leading spaces><sign><digits without leading zeroes>'.'<PREC digits> ● Leading zeros to the left of the decimal point (except the digit adjacent to the decimal point) are suppressed.
Page 354
Extended instructions 9.2 String and character Table 9- 31 Example of S_CONV string to value conversion IN string OUT data type OUT value "123" Int or DInt TRUE "-00456" Int or DInt -456 TRUE "123.45" Int or DInt TRUE "+2345" Int or DInt 2345 TRUE...
Page 355
Extended instructions 9.2 String and character Table 9- 33 Example: STRG_VAL conversion IN string FORMAT OUT data type OUT value (W#16#..) "123" 0000 Int or DInt TRUE "-00456" 0000 Int or DInt -456 TRUE "123.45" 0000 Int or DInt TRUE "+2345"...
Page 356
Extended instructions 9.2 String and character The following examples of VAL_STRG conversions are based on an OUT string initialized as follows: " " Current Temp = xxxxxxxxxx C where the " " character represents space characters allocated for the converted value. Table 9- 34 Example: VAL_STRG conversion Data type...
Extended instructions 9.2 String and character 9.2.3.2 Strg_TO_Chars and Chars_TO_Strg (Convert to/from character string and array of CHAR) instructions Strg_TO_Chars copies an ASCII character string into an array of character bytes. Chars_TO_Strg copies an array of ASCII character bytes into a character string. Note Only the zero based array types (Array [0..n] of Char) or (Array [0..n] of Byte) are allowed as the input parameter Chars for the Chars_TO_Strg instruction, or as the IN_OUT parameter...
Page 358
Extended instructions 9.2 String and character Table 9- 37 Chars_TO_Strg instruction LAD / FBD Description Chars_TO_Strg( All or part of an array of characters is copied to a string. Chars:=_variant_in_, The output string must be declared before Chars_TO_Strg is pChars:=_dint_in_, executed.
Extended instructions 9.2 String and character 9.2.3.3 ATH and HTA (Convert to/from ASCII string and hexadecimal number) instructions Use the ATH (ASCII to hexadecimal) and HTA (hexadecimal to ASCII) instructions for conversions between ASCII character bytes (characters 0 to 9 and uppercase A to F only) and the corresponding 4-bit hexadecimal nibbles.
Page 360
Extended instructions 9.2 String and character Table 9- 43 HTA instruction LAD / FBD Description ret_val := HTA( Converts packed hexadecimal digits to their corresponding ASCII in:=_variant_in_, character bytes. n:=_uint_in_, out=>_variant_out_); Table 9- 44 Data types for the HTA instruction Parameter and type Data Type Description...
Extended instructions 9.2 String and character Table 9- 46 ATH and HTA condition codes RET_VAL Description (W#16#..) 0000 No error TRUE 0007 Invalid ATH input character: A character was found that was not an ASCII character 0- FALSE 9, lowercase a to f, or uppercase A to F 8101 Illegal or invalid input pointer, for example, an access to a DB that does not exist.
Extended instructions 9.2 String and character Table 9- 48 Data types for the parameters Parameter and type Data type Description String, WString Input string DInt Maximum number of characters allowed for IN string 9.2.4.2 LEN (Determine the length of a character string) Table 9- 49 Length instruction LAD / FBD...
Extended instructions 9.2 String and character 9.2.4.3 CONCAT (Combine character strings) Table 9- 52 Concatenate strings instruction LAD / FBD Description out := CONCAT(in1, in2); CONCAT (concatenate strings) joins string parameters IN1 and IN2 to form one string provided at OUT. After concatenation, String IN1 is the left part and String IN2 is the right part of the combined string.
Extended instructions 9.2 String and character 9.2.4.4 LEFT, RIGHT, and MID (Read substrings in a character string) instructions Table 9- 55 Left, right and middle substring operations LAD / FBD Description out := LEFT(in, L); LEFT (Left substring) provides a substring made of the first L charac- ters of string parameter IN.
Extended instructions 9.2 String and character Table 9- 57 ENO status Condition No errors detected Valid characters Current length is set to 0 L or P is less than or equal to 0 • P is greater than maximum length of IN •...
Extended instructions 9.2 String and character Table 9- 60 ENO status Condition No errors detected Valid characters P is greater than current length of IN IN is copied to OUT with no char- acters deleted Resulting string after characters are deleted is larger than maximum length Resulting string characters are of OUT string copied until the maximum length...
Extended instructions 9.2 String and character Table 9- 63 ENO status Condition No errors detected Valid characters P is greater than length of IN1 IN2 is concatenated with IN1 immediate- ly following the last IN1 character P is less than 0 Current length is set to 0 Resulting string after insertion is larger than maximum length of Resulting string characters are copied...
Page 368
Extended instructions 9.2 String and character Table 9- 65 Data types for the parameters Parameter and type Data type Description String, WString Input string String, WString String of replacement characters Number of characters to replace Position of first character to be replaced String, WString Result string If parameter L is equal to zero, then the string IN2 is inserted at position P of string IN1...
Extended instructions 9.2 String and character 9.2.4.8 FIND (Find characters in a character string) Table 9- 67 Find substring instruction LAD / FBD Description out := FIND( Provides the character position of the substring specified by IN2 within in1:=_string_in_, the string IN1. The search starts on the left. The character position of in2:=_string_in);...
Extended instructions 9.2 String and character 9.2.5 Runtime information 9.2.5.1 GetSymbolName (Read out a tag on the input parameter) Table 9- 70 GetSymbolName instruction LAD / FBD Description OUT := GetSymbolName( The GetSymbolName instruction returns a variable:=_parameter_in_, string corresponding to the name of a variable size:=_dint_in_);...
Page 371
Extended instructions 9.2 String and character Example: Meaning of SIZE parameter The following example illustrates the meaning of the SIZE parameter. The following tag name is read from the block interface: "MyPLCTag" (The double quotes at the start and end belong to the name.) SIZE GetSymbolName returns...
Page 372
Extended instructions 9.2 String and character Example: Reading a symbol name In the following example, you read out the name of a tag that is interconnected via the input parameter of a block. Create two tags in a global data block for storing the data. Create an input parameter inputValue with the BYTE data type in the Level1 block.
Extended instructions 9.2 String and character 9.2.5.2 GetSymbolPath (Query composite global name of the input parameter assignment) Table 9- 71 GetSymbolPath instruction LAD / FBD Description OUT := GetSymbolPath( The GetSymbolPath instruction reads the variable:=_parameter_in_, composite global name of an input parameter size:=_dint_in_);...
Page 374
Extended instructions 9.2 String and character Usage Note the following tips on using the GetSymbolPath instruction: ● Specify the block interface through which the name of the input tag is read at the VARIABLE parameter of the instruction: – If a data block tag supplies the input parameter, GetSymbolPath outputs the name of the DB, contained structures and the name of the tag.
Page 375
Extended instructions 9.2 String and character Example: Calling GetSymbolPath over mutiple block call levels The following example shows the use of GetSymbolPath over several call levels: ● Organization block OB1 calls the FB_Level_1 block, which in turn calls the FB_Level_2 block.
Extended instructions 9.2 String and character 9.2.5.3 GetInstanceName (Read out name of the block instance) Table 9- 72 GetInstanceName instruction LAD / FBD Description OUT := GetInstanceName( You can use the GetInstanceName instruction size:=_dint_in_); to read the name of the instance data block within a function block.
Page 377
Extended instructions 9.2 String and character Example: Meaning of SIZE parameter To limit the length of the read instance name, use the SIZE parameter. If the instruction has truncated the name, it indicates the truncation by the character "..." (Unicode character 16#2026) at the end of the name.
Page 378
Extended instructions 9.2 String and character Example: Reading the name of an instance data block The following example shows how to read out the name of an instance data block. Create two tags in a global data block for storing the data. Define the parameters of the instruction as follows.
Extended instructions 9.2 String and character 9.2.5.4 GetInstancePath (Query composite global name of the block instance) Table 9- 73 GetInstancePath instruction LAD / FBD Description OUT := GetInstancePath( You use the GetInstancePath instruction to size:=_dint_in_); read the composed global name of the block instance within a function block.
Page 380
Extended instructions 9.2 String and character Example: Calling GetInstancePath to get the path of a multi-instance FB call In the following example, the FB_Level_3 function block calls the GetInstancePath instruction. ● The FB_Level_3 function block stores its data in the calling FB_Level_2 function block. ●...
Extended instructions 9.2 String and character SIZE GetInstancePath returns Explanation '"IDB_...' First character of WSTRING:' • The first five characters of the name and identifier that • the name was truncated: "IDB_... Last character of WSTRING:' • '"IDB_LEVEL_1".Level_2_ First character of WSTRING:' •...
Page 382
Extended instructions 9.2 String and character Example: Meaning of the SIZE parameter To limit the length of the block name to a certain number of characters, specify the maximum length at the SIZE parameter. If GetBlockName truncates the name, it indicates the truncation by the character "..."...
Page 383
Extended instructions 9.2 String and character Example: Reading a block name The following example shows how to read out a block name. 1. Create two tags in a global data block for storing the data. 2. Define the parameters of the instruction as follows: The Level1_gbn block executes the GetBlockName instruction.
Extended instructions 9.3 Distributed I/O (PROFINET, PROFIBUS, or AS-i) Distributed I/O (PROFINET, PROFIBUS, or AS-i) 9.3.1 Distributed I/O Instructions The following Distributed I/O instructions can be used with PROFINET, PROFIBUS, or AS-i: ● RDREC instruction (Page 385): Reads a data record with the number INDEX from a module or device.
Extended instructions 9.3 Distributed I/O (PROFINET, PROFIBUS, or AS-i) 9.3.2 RDREC and WRREC (Read/write data record) You can use the RDREC (Read data record) and WRREC (Write data record) instructions with PROFINET, PROFIBUS, and AS-i. Table 9- 75 RDREC and WRREC instructions LAD / FBD Description "RDREC_DB"(...
Page 386
Extended instructions 9.3 Distributed I/O (PROFINET, PROFIBUS, or AS-i) Table 9- 76 RDREC and WRREC data types for the parameters Parameter and type Data type Description Bool REQ = 1: Transfer data record HW_IO (Word) Logical address of the DP slave/PROFINET IO component (module or submodule): For an output module, bit 15 must be set (for example, for •...
Page 387
Extended instructions 9.3 Distributed I/O (PROFINET, PROFIBUS, or AS-i) Parameter and type Data type Description OUT (RDREC) UInt Length of the fetched data record information (RDREC) • IN (WRREC) Maximum byte length of the data record to be transferred • (WRREC) RECORD IN_OUT...
Extended instructions 9.3 Distributed I/O (PROFINET, PROFIBUS, or AS-i) 9.3.3 GETIO (Read process image) You use the instruction "GETIO" to consistently read inputs of modules or submodules of DP slaves and PROFINET IO devices. The instruction "GETIO" calls the instruction "DPRD_DAT (Page 408)".
Extended instructions 9.3 Distributed I/O (PROFINET, PROFIBUS, or AS-i) 9.3.4 SETIO (Transfer process image) You use the instruction "SETIO" to consistently transfer data from the source range defined by the OUTPUTS parameter to the addressed modules or submodules of DP slaves and PROFINET IO devices.
Extended instructions 9.3 Distributed I/O (PROFINET, PROFIBUS, or AS-i) 9.3.5 GETIO_PART (Read process image area) You use the instruction "GETIO_PART" to consistently read a related part of the inputs of modules or submodules of DP slaves and PROFINET IO devices. GETIO_PART calls the instruction "DPRD_DAT (Page 408)".
Page 391
Extended instructions 9.3 Distributed I/O (PROFINET, PROFIBUS, or AS-i) Parameters The following table shows the parameters of the GETIO_PART instruction: Parameter Declaration Data type Description HW_SUBMO Hardware identifier of the module DULE OFFSET Number of the first byte to be read in the process image for the component (smallest possible value: 0) Number of bytes to be read STATUS...
Extended instructions 9.3 Distributed I/O (PROFINET, PROFIBUS, or AS-i) 9.3.6 SETIO_PART (Transfer process image area) You can use the "SETIO_PART" instruction to consistently write data from the source area spanned by OUTPUTS to the outputs of modules or submodules of DP slaves and PROFINET IO devices.
Page 393
Extended instructions 9.3 Distributed I/O (PROFINET, PROFIBUS, or AS-i) Parameters The following table shows the parameters of the SETIO_PART instruction: Parameter Declaration Data type Description HW_SUBMO Hardware identifier of the IO module DULE OFFSET Number of the first byte to be written in the process image for the compo- nent (smallest possible value: 0) Number of bytes to be written STATUS...
Extended instructions 9.3 Distributed I/O (PROFINET, PROFIBUS, or AS-i) 9.3.7 RALRM (Receive interrupt) You can use the RALRM (Read alarm) instruction with PROFINET and PROFIBUS. Table 9- 81 RALRM instruction LAD / FBD Description "RALRM_DB"( Use the RALRM (read alarm) instruction to read diagnostic mode:=_int_in_, interrupt information from PROFIBUS or PROFINET I/O mod- f_ID:=_word_in_,...
Page 395
Extended instructions 9.3 Distributed I/O (PROFINET, PROFIBUS, or AS-i) Parameter and type Data type Description HW_IO (Word) Hardware identifier of the I/O module that caused the diagnostic inter- rupt Note: Refer to the F_ID parameter for an explanation of how to deter- mine the device ID.
Page 396
Extended instructions 9.3 Distributed I/O (PROFINET, PROFIBUS, or AS-i) Calling RALRM You can call the RALRM instruction in three different operating modes (MODE). Table 9- 83 RALRM instruction operating modes MODE Description ID contains the hardware identifier of the I/O module that triggered the interrupt. •...
Page 397
Extended instructions 9.3 Distributed I/O (PROFINET, PROFIBUS, or AS-i) TInfo organization block data The table below shows how the TInfo data is arranged for the RALRM instruction: Same for OBs: Status, Update, Profile, SI_Format OB_Class OB_Nr Diagnostic error interrupt, Pull or plug of modules, Rack or station failure LADDR TI_Submodule - OBs: Status, Update,...
Extended instructions 9.3 Distributed I/O (PROFINET, PROFIBUS, or AS-i) 9.3.8 D_ACT_DP (Enable/disable PROFINET IO devices) With the "D_ACT_DP" instruction, you can disable and enable configured PROFINET IO devices in a targeted manner. In addition, you can determine whether each assigned PROFINET IO device is currently activated or deactivated.
Page 399
Extended instructions 9.3 Distributed I/O (PROFINET, PROFIBUS, or AS-i) Examples From a machine OEM's point of view, there are numerous device options possible in series production of machines. However, each delivered machine includes only one combination of selected options. The manufacturer configures every one of these possible machine options as a PROFINET IO device.
Page 400
Extended instructions 9.3 Distributed I/O (PROFINET, PROFIBUS, or AS-i) Activating PROFINET IO devices When you reactivate a PROFINET IO device with D_ACT_DP, the associated PROFINET IO controller configures the component and assigns parameters (as with the return of a failed PROFINET IO station).
Page 401
Extended instructions 9.3 Distributed I/O (PROFINET, PROFIBUS, or AS-i) Parameter Declara- Data type Description tion RET_VAL If an error occurs while the program executes the instruction, the return value contains an error code. BUSY Bool Active code: BUSY = 1: The job is still active. •...
Page 402
Extended instructions 9.3 Distributed I/O (PROFINET, PROFIBUS, or AS-i) Error code* Explanation (W#16#...) 80A6 Slot error in the PROFINET IO device; not all user data can be accessed (this error code is only available when MODE = 1). Note: D_ACT_DP returns this error information only if the activated component fails again after parameter assignment and before the end of the D_ACT_DP instruction execution.
Extended instructions 9.3 Distributed I/O (PROFINET, PROFIBUS, or AS-i) 9.3.9 STATUS parameter for RDREC, WRREC, and RALRM The output parameter STATUS contains error information that is interpreted as ARRAY[1...4] OF BYTE, with the following structure: Table 9- 85 STATUS output array Array element Name Description...
Page 404
Extended instructions 9.3 Distributed I/O (PROFINET, PROFIBUS, or AS-i) Table 9- 87 STATUS[3] values Error_decode Error_code_1 Explanation (DVP1) Description (B#16#..) (B#16#..) No error, no warning Reserved, reject Initial call; no active data record transfer Reserved, reject Initial call; data record transfer has started Reserved, reject Intermediate call;...
Page 405
Extended instructions 9.3 Distributed I/O (PROFINET, PROFIBUS, or AS-i) Error_decode Error_code_1 Explanation (DVP1) Description (B#16#..) (B#16#..) Write length error The length information in the RECORD parameter is incorrect. With "RALRM": Length error in AINFO • Note: Refer to the online information system of STEP 7 for immediate access to information on how to interpret the "AINFO"...
Page 406
Extended instructions 9.3 Distributed I/O (PROFINET, PROFIBUS, or AS-i) Error_decode Error_code_1 Explanation (DVP1) Description (B#16#..) (B#16#..) Internal temporary error. Job could not be carried out. Repeat the job. If this error occurs often, check your installation for sources of electrical interference. DP slave or module not available Data record transfer was cancelled due to priority class cancellation.
Page 407
Extended instructions 9.3 Distributed I/O (PROFINET, PROFIBUS, or AS-i) Array element STATUS[4] With DPV1 errors, the DP Master passes on STATUS[4] to the CPU and to the instruction. Without a DPV1 error, this value is set to 0, with the following exceptions for the RDREC: ●...
Extended instructions 9.3 Distributed I/O (PROFINET, PROFIBUS, or AS-i) 9.3.10 Others 9.3.10.1 DPRD_DAT and DPWR_DAT (Read/write consistent data) Use the DPRD_DAT (Read consistent data) instruction to read one or more bytes of data consistently, and use the DPWR_DAT (Write consistent data) instruction to transfer one or more bytes of data consistently.
Page 409
Extended instructions 9.3 Distributed I/O (PROFINET, PROFIBUS, or AS-i) Note If you are using the DPRD_DAT and DPWR_DAT instructions with consistent data, you must remove this consistent data from the process-image automatic update. Refer to "PLC concepts: Execution of the user program" (Page 83) for more information. Table 9- 89 Parameters Parameter...
Page 410
Extended instructions 9.3 Distributed I/O (PROFINET, PROFIBUS, or AS-i) DPWR_DAT operations Use the parameter LADDR to select the module of the DP standard slave / PROFINET IO device. If an access error occurs on the addressed module, the error code W#16#8090 is output.
Extended instructions 9.3 Distributed I/O (PROFINET, PROFIBUS, or AS-i) 9.3.10.2 RCVREC (I-device/I-slave receive data record) An I-device can receive a data record from a higher-level controller. The receipt takes place in the user program with the RCVREC instruction (receive data record). Table 9- 91 RCVREC instruction LAD / FBD...
Page 412
Extended instructions 9.3 Distributed I/O (PROFINET, PROFIBUS, or AS-i) Set CODE1 and CODE2 to zero for the positive answer to the higher-level controller. If the received data record is to be rejected, enter the negative answer to the higher-level controller in Error Code 1 of the CODE1 and in Error Code 2 of the CODE2. Note If the I-device has received a request for a data record receipt, you must recognize the delivery of this request within a certain duration.
Extended instructions 9.3 Distributed I/O (PROFINET, PROFIBUS, or AS-i) Parameters The following table shows the parameters of the RCVREC instruction: Parameter Declara- Data type Description tion MODE Mode F_ID HW_SUBMODULE Subslot in the transfer area of the I-device for the data record to be received (only relevant for MODE = 2).
Page 414
Extended instructions 9.3 Distributed I/O (PROFINET, PROFIBUS, or AS-i) The instruction has the following operating modes: ● Check whether the I-device has a request for making a data record available ● Transfer the requested data record to the higher-level controller ●...
Page 415
Extended instructions 9.3 Distributed I/O (PROFINET, PROFIBUS, or AS-i) Operating modes You can determine the operating mode of the PRVREC instruction with the input parameter MODE. This step is explained in the following table: MODE Meaning Check whether a request for making a data record available exists If a request from a higher-level controller for making a data record available exists on the I-device, the instruc- tion only writes to the NEW, SLOT, SUBSLOT, INDEX, and RLEN output parameters.
Extended instructions 9.3 Distributed I/O (PROFINET, PROFIBUS, or AS-i) Parameters The following table shows the parameters of the PRVREC instruction: Parameter Declara- Data type Description tion MODE Mode F_ID HW_SUBMODULE Subslot in the transfer area of the I-device for the data record to be sent (only relevant for MODE = 2).
Page 417
Extended instructions 9.3 Distributed I/O (PROFINET, PROFIBUS, or AS-i) Table 9- 94 DPNRM_DG instruction data types for the parameters Parameter and type Data type Description Bool REQ=1: Read request LADDR HW_DPSLAVE Configured diagnostic address of the DP slave: Must be the address of the station and not for the I/O device.
Page 418
Extended instructions 9.3 Distributed I/O (PROFINET, PROFIBUS, or AS-i) Table 9- 96 DPNRM_DG instruction error codes Error code Description Restriction 0000 No error 7000 First call with REQ=0: No data transfer active; BUSY has the value 0. 7001 First call with REQ =1: No data transfer active; BUSY has the value 1. Distributed I/Os 7002 Interim call (REQ irrelevant): Data transfer already active;...
You can find further information on PROFIenergy in the TIA Portal STEP 7 online help. You can find examples that use the PROFIenergy instructions in the Industry Online Support in the entry "PROFIenergy - Saving Energy with SIMATIC S7 (http://support.automation.siemens.com/WW/view/en/41986454)". S7-1200 Programmable controller System Manual, V4.2, 09/2016, A5E02486680-AK...
Extended instructions 9.5 Interrupts Interrupts 9.5.1 ATTACH and DETACH (Attach/detach an OB and an interrupt event) instructions You can activate and deactivate interrupt event-driven subprograms with the ATTACH and DETACH instructions. Table 9- 97 ATTACH and DETACH instructions LAD / FBD Description ret_val := ATTACH( ATTACH enables interrupt OB subprogram...
Page 421
Extended instructions 9.5 Interrupts Hardware interrupt events The following hardware interrupt events are supported by the CPU: ● Rising edge events: first 12 built-in CPU digital inputs (DIa.0 to DIb.3) and all SB digital inputs – A rising edge occurs when the digital input transitions from OFF to ON as a response to a change in the signal from a field device connected to the input.
Page 422
Extended instructions 9.5 Interrupts Adding new hardware interrupt OB code blocks to your program By default, no OB is attached to an event when the event is first enabled. This is indicated by the "HW interrupt:" device configuration "<not connected>" label. Only hardware-interrupt OBs can be attached to a hardware interrupt event.
Page 423
Extended instructions 9.5 Interrupts DETACH operation Use the DETACH instruction to detach either a particular event or all events from a particular OB. If an EVENT is specified, then only this one event is detached from the specified OB_NR; any other events currently attached to this OB_NR will remain attached. If no EVENT is specified, then all events currently attached to OB_NR will be detached.
Extended instructions 9.5 Interrupts 9.5.2 Cyclic interrupts 9.5.2.1 SET_CINT (Set cyclic interrupt parameters) Table 9- 100 SET_CINT (Set cyclic interrupt parameters) LAD / FBD Description ret_val := SET_CINT( Set the specified interrupt OB to begin cyclic execution ob_nr:=_int_in_, that interrupts the program scan. cycle:=_udint_in_, phase:=_udint_in_);...
Page 425
Extended instructions 9.5 Interrupts If lower and higher priority OBs are called in the same time interval, the lower priority OB is only called after the higher priority OB has finished processing. The execution start time for the low priority OB can shift depending on the processing time of higher priority OBs. If you want to start the execution of a lower priority OB on a fixed time cycle, then phase shift time should be greater then the processing time of higher priority OBs.
Extended instructions 9.5 Interrupts 9.5.2.2 QRY_CINT (Query cyclic interrupt parameters) Table 9- 103 QRY_CINT (Query cyclic interrupt) LAD / FBD Description ret_val := QRY_CINT( Get parameter and execution status from a cyclic ob_nr:=_int_in_, interrupt OB. The values that are returned existed cycle=>_udint_out_, at the time QRY_CINT was executed.
CPU system time. 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. S7-1200 Programmable controller System Manual, V4.2, 09/2016, A5E02486680-AK...
Extended instructions 9.5 Interrupts 9.5.3.1 SET_TINTL (Set time of day interrupt) Table 9- 107 SET_TINTL (Set date and time of day interrupt with DTL data type) LAD / FBD Description ret_val := SET_TINTL( Set a date and time of day interrupt. The OB_NR:=_int_in_, program interrupt OB can be set for one SDT:=_dtl_in_,...
Extended instructions 9.5 Interrupts The DTL data weekday value in parameter SDT is ignored. Set a CPU's current date and time using the "Set time of day" function in the "Online & diagnostics" view of an online CPU. You must set the month, day of month, and year. STEP 7 calculates the interrupt period based on the CPU date and time clock.
Extended instructions 9.5 Interrupts Table 9- 112 Condition codes RET_VAL (W#16#..) Description 0000 No error 8090 Invalid OB_NR parameter 80A0 No start date / time set for that interrupt OB 9.5.3.3 ACT_TINT (Activate time of day interrupt) Table 9- 113 ACT_TINT (Activate date and time of day interrupt) LAD / FBD Description ret_val:=ACT_TINT(_int_in_);...
Extended instructions 9.5 Interrupts 9.5.3.4 QRY_TINT (Query status of time of day interrupt) Table 9- 116 QRY_TINT (Query date and time of day interrupt) LAD / FBD Description ret_val:=QRY_TINT( Queries the date and time of day interrupt status for OB_NR:=_int_in_, the specified interrupt OB.
Extended instructions 9.5 Interrupts 9.5.4 Time delay interrupts You can start and cancel time delay interrupt processing with the SRT_DINT and CAN_DINT instructions, or query the interrupt status with the QRY_DINT instruction. Each time delay interrupt is a one-time event that occurs after the specified delay time. If the time delay event is cancelled before the time delay expires, the program interrupt does not occur.
Page 433
Extended instructions 9.5 Interrupts Operation When EN=1, the SRT_DINT instruction starts the internal time delay timer (DTIME). When the time delay elapses, the CPU generates a program interrupt that triggers the execution of the associated time delay interrupt OB. You can cancel an in-process time delay interrupt before the specified time delay occurs by executing the CAN_DINT instruction.
Page 434
Extended instructions 9.5 Interrupts QRY_DINT parameter STATUS Table 9- 122 If there is an error (REL_VAL <> 0), then STATUS = 0. Value Description In RUN In startup The interrupt is enabled. The interrupt is disabled. The interrupt is not active or has elapsed. The interrupt is active.
Extended instructions 9.5 Interrupts 9.5.5 DIS_AIRT and EN_AIRT (Delay/enable execution of higher priority interrupts and asynchronous error events) instructions Use the DIS_AIRT and EN_AIRT instructions to disable and enable alarm interrupt processing. Table 9- 124 DIS_AIRT and EN_AIRT instructions LAD / FBD Description DIS_AIRT();...
Extended instructions 9.6 Alarms Alarms 9.6.1 Gen_UsrMsg (Generate user diagnostic alarms) Table 9- 126 Gen_UsrMsg instruction LAD / FBD Description ret_val :=Gen_UsrMsg( You use the "Gen_UsrMsg" instruction to Mode:=_uint_in_, generate a user diagnostic alarm that can be TextID:=_uint_in_, either an incoming or outgoing alarm. By means of user diagnostic alarms, you can TextListID:=_uint_in_, write a user entry to the diagnostics buffer and...
Page 437
Extended instructions 9.6 Alarms Parameters The following table shows the parameters of the "Gen_UsrMsg" instruction: Parameter Declaration Data type Memory area Description Mode Input UInt I, Q, M, D, L or Parameters for selecting the constant status of the alarm: 1: incoming alarm •...
Page 438
Extended instructions 9.6 Alarms Byte Parameter Data type Start value Description Number of the associ- ated value 12..13 Value[7] UINT 14..15 Value[8] UINT Eighth associ- ated value of the alarm. Parameter RET_VAL The following table defines output values for the RET_VAL parameter. See also Common error codes for the Extended instructions (Page 553).
Extended instructions 9.7 Diagnostics (PROFINET or PROFIBUS) Diagnostics (PROFINET or PROFIBUS) 9.7.1 Diagnostic instructions The following diagnostic instructions can be used with either PROFINET or PROFIBUS: ● RD_SINFO instruction (Page 440): Reads the current OB's start information ● LED instruction (Page 450): Reads the state of the LEDs for a distributed I/O device. ●...
Extended instructions 9.7 Diagnostics (PROFINET or PROFIBUS) 9.7.2 RD_SINFO (Read current OB start information) Description Table 9- 127 RD_SINFO instruction LAD / FBD Description ret_val := RD_SINFO( You use the instruction "RD_SINFO" to read the TOP_SI=>_variant_out_, start information of the following OBs: Last OB called that has not yet been com- •...
Page 441
Extended instructions 9.7 Diagnostics (PROFINET or PROFIBUS) Organization blocks (OB) System data types (SDT) System data type numbers TimeErrorOB SI_TimeError DiagnosticErrorOB SI_DiagnosticInterrupt PullPlugEventOB SI_PlugPullModule PeripheralAccessErrorOB SI_AccessError RackStationFailureOB SI_StationFailure ServoOB SI_Servo IpoOB SI_Ipo StartupOB SI_Startup ProgrammingErrorOB SI_ProgIOAccessError IOaccessErrorOB *The SI_classic SDT is not applicable for the S7-1200. The S7-1200 CPU returns a RET_VAL of #16#8081 if the TOP_SI parameter is of type SI_classic.
Page 442
Extended instructions 9.7 Diagnostics (PROFINET or PROFIBUS) Structures The following tables define the structure elements of the individual structures: Table 9- 128 SI_classic structure Structure element Data type Description EV_CLASS BYTE Bits 0 to 3: Event ID • Bits 4 to 7: Event class •...
Page 443
Extended instructions 9.7 Diagnostics (PROFINET or PROFIBUS) Table 9- 131 SI_TimeOfDay structure Structure element Data type Description SI_Format USINT 16#FF = No information • 16#FE = Optimized start information • OB_Class USINT := 10 OB class for "No information" or "Optimized start information" OB_Nr UINT OB number (1 ...
Page 444
Extended instructions 9.7 Diagnostics (PROFINET or PROFIBUS) Table 9- 135 SI_Submodule structure Structure element Data type Description SI_Format USINT 16#FF = No information • 16#FE = Optimized start information • OB_Class USINT OB class for "No information" or "Optimized start information" OB_Nr UINT OB number (1 ...
Page 445
Extended instructions 9.7 Diagnostics (PROFINET or PROFIBUS) Table 9- 138 SI_CPURedundancyError structure Structure element Data type Description SI_Format USINT 16#FF = No information • 16#FE = Optimized start information • OB_Class USINT := 72 OB class for "No information" or "Optimized start information" OB_Nr UINT OB number (1 ...
Page 446
Extended instructions 9.7 Diagnostics (PROFINET or PROFIBUS) Table 9- 141 SI_PlugPullModule structure Structure element Data type Description SI_Format USINT 16#FF = No information • 16#FE = Optimized start information • OB_Class USINT := 83 OB class for "No information" or "Optimized start information" OB_Nr UINT OB number (1 ...
Page 447
Extended instructions 9.7 Diagnostics (PROFINET or PROFIBUS) Table 9- 144 SI_Servo structure Structure element Data type Description SI_Format USINT 16#FF = No information • 16#FE = Optimized start information • OB_Class USINT := 91 OB class for "No information" or "Optimized start information" OB_Nr UINT OB number (1 ...
Page 448
Extended instructions 9.7 Diagnostics (PROFINET or PROFIBUS) Table 9- 147 SI_ProgIOAcessError structure Structure element Data type Description SI_Format USINT 16#FF = No information • 16#FE = Optimized start information • OB_Class USINT OB class for "No information" or "Optimized start information" OB_Nr UINT OB number (1 ...
Page 449
Extended instructions 9.7 Diagnostics (PROFINET or PROFIBUS) RET_VAL parameter The following table shows the meaning of the values of the RET_VAL parameter: Error code* Explanation (W#16#...) 8081 Start information of the current OB does not correspond to the specified system data type 8083 Start information of the last startup OB started does not correspond to the specified system data type * You can display the error code as either integer or hexadecimal values in the program editor.
Extended instructions 9.7 Diagnostics (PROFINET or PROFIBUS) The following table shows the assignment between the structure elements of the START_UP_SI parameter of the "RD_SINFO" instruction and the associated local tags of OB 100. START_UP_SI Data type OB 100 - Local tag Data type structure element EV_CLASS...
Extended instructions 9.7 Diagnostics (PROFINET or PROFIBUS) Table 9- 150 Status of RET_VAL RET_VAL (W#16#...) Description 0 to 9 LED state LED does not exist Color 1 On (solid) Color 2 On (Solid) Color 1 flashing at 2 Hz Color 2 flashing 2 Hz Color 1 &...
Page 452
Extended instructions 9.7 Diagnostics (PROFINET or PROFIBUS) Table 9- 152 Data types for the parameters Parameter and type Data type Description LADDR Input HW_IO Identifier of the module IM_TYPE Input UInt Identification and maintenance (I&M) data number: 0: I&M0 (MLFB, serial number, version, and other information) •...
Extended instructions 9.7 Diagnostics (PROFINET or PROFIBUS) 9.7.5 Get_Name (Read the name of a PROFINET IO device) The "Get_Name" instruction reads the name of a PROFINET IO device, PROFIBUS slave, or AS-i slave. The name is displayed in the network view and in the properties of the IO device. Table 9- 154 Get_Name instruction LAD / FBD Description...
Page 454
Extended instructions 9.7 Diagnostics (PROFINET or PROFIBUS) Parameters The following table shows the parameters of the Get_Name instruction: Parameter Declaration Data type Description LADDR HW_IOSYSTEM Hardware identifier (HW-IoSystem) of the distributed IO sys- tem. The number is taken from the system constants or the properties of the IO system.
Page 455
Extended instructions 9.7 Diagnostics (PROFINET or PROFIBUS) STATUS parameter Error code* Explanation (W#16#...) No error 7000 No job in progress 7001 First call of the asynchronous Get_Name instruction. Execution of the instruction not yet complete (BUSY = 1, DONE = 0). 7002 Additional call of the asynchronous Get_Name instruction.
Page 456
Extended instructions 9.7 Diagnostics (PROFINET or PROFIBUS) Example The following example shows how you can read the station name of an ET 200SP PROFINET IO device: 1. Configuring the ET 200SP: – Create the ET 200SP with the station name "Conveyor_1" in the network view and assign it to the same PROFINET IO system as the CPU.
Page 457
Extended instructions 9.7 Diagnostics (PROFINET or PROFIBUS) Note When using the dropdown to make your selections for configuring the tag to the DATA parameter, select the DB (in the example, "Datablock") and the tag (in the example, "String[ ]"). In order to read the entire String data type, you must delete the brackets so that the final result is: "Datablock".String –...
Page 458
Extended instructions 9.7 Diagnostics (PROFINET or PROFIBUS) 3. Executing the Get_Name instruction: – As the instruction executes, the BUSY output parameter may get set to "1", and the DONE parameter is then set to "0". – Error code information is displayed at the STATUS output parameter. S7-1200 Programmable controller System Manual, V4.2, 09/2016, A5E02486680-AK...
Page 459
Extended instructions 9.7 Diagnostics (PROFINET or PROFIBUS) 4. Completing execution of the Get_Name instruction: – After execution of the instruction, the program writes "Conveyor_1", the station name of the ET 200SP, into the data block at the DATA parameter. – The program writes "10", the number of characters in the station name, to the LEN parameter.
Extended instructions 9.7 Diagnostics (PROFINET or PROFIBUS) 9.7.6 GetStationInfo (Read the IP or MAC address of a PROFINET IO device) The "GetStationInfo" instruction reads the IP or MAC address of a PROFINET IO device in the local IO system or a PROFINET IO device located in a lower-level IO system (connected using CP/CM modules).
Page 461
Extended instructions 9.7 Diagnostics (PROFINET or PROFIBUS) The instruction displays the execution status of the read job using the BUSY, DONE, and ERROR output parameters and the STATUS output parameter. Note Address the IO device using only the hardware identifier of the station The station, the IO device, and PROFINET interface have their own hardware identifier.
Page 462
Extended instructions 9.7 Diagnostics (PROFINET or PROFIBUS) Parameter Declaration Data type Description ERROR Bool STATUS parameter: 0: No error. • 1: An error occurred during execution of the instruction. • Detailed information is output using the STATUS parameter. STATUS Word STATUS parameter: The parameter is only set for the duration of one call.
Page 463
Extended instructions 9.7 Diagnostics (PROFINET or PROFIBUS) ● Use the "IF_CONF_MAC" structure at parameter DATA for storing the MAC address: Byte Parameter Data type Start value Description 0 … 1 UINT ID of the "IF_CONF_MAC" structure 2 … 3 Length UNIT Length of data read in BYTE 4 ...
Page 464
Extended instructions 9.7 Diagnostics (PROFINET or PROFIBUS) Example In the example below, you use the GetStationInfo instruction to read the IP address data of an IO device and write the information to a data block. The IP address data includes the IP address, subnet mask, and (if used) the address data of the router.
Page 465
Extended instructions 9.7 Diagnostics (PROFINET or PROFIBUS) 2. Assigning parameters for the GetStationInfo instruction: – Create five tags and a structure with the IF_CONF_v4 data type in a global data block for storing the IP address data. Assign any name to the structure. (In the example, the structure name is "IP_Address".) S7-1200 Programmable controller System Manual, V4.2, 09/2016, A5E02486680-AK...
Page 466
Extended instructions 9.7 Diagnostics (PROFINET or PROFIBUS) 3. Assigning parameters for the GetStationInfo instruction: – Enter the hardware ID of the IO device at the LADDR parameter. The hardware identifier uniquely identifies the product, and, in this example, the hardware ID is "270".
Page 467
Extended instructions 9.7 Diagnostics (PROFINET or PROFIBUS) 4. Executing the GetStationInfo instruction: – When the REQ input = 1 (FALSE), the instruction displays no IP address information at the DATA input/output parameter or error code information at the STATUS output parameter.
Extended instructions 9.7 Diagnostics (PROFINET or PROFIBUS) 9.7.7 DeviceStates instruction You can use the DeviceStates instruction to return the states of all distributed I/O slave devices connected to a specified distributed I/O Master. Table 9- 156 DeviceStates instruction LAD / FBD Description ret_val := DeviceStates( DeviceStates retrieves the I/O device opera-...
Extended instructions 9.7 Diagnostics (PROFINET or PROFIBUS) After execution, the STATE parameter contains the error state of each I/O device as a bit list (for the assigned LADDR and MODE). Table 9- 158 Condition codes RET_VAL (W#16#...) Description No error 8091 LADDR does not exist.
Page 470
Extended instructions 9.7 Diagnostics (PROFINET or PROFIBUS) Table 9- 159 Example 1: No errors: A value of 0x01FC_FF03 is returned for MODE 1 (Device configu- ration active). Byte with value Bit pattern with value Notes Byte 1 0x01 Bit 7 0000-0001 Bit 0 Bit 0 is true;...
Page 471
Extended instructions 9.7 Diagnostics (PROFINET or PROFIBUS) Table 9- 161 Example 2 (continued): A module has been pulled from PROFIBUS slave device "DPSlave_12". A value of 0x01FC_FF03 is returned for MODE 4 (Device exists). Byte with value Bit pattern with value Notes Byte 1 0x01 Bit 7 0000-0001 Bit 0...
Page 472
Extended instructions 9.7 Diagnostics (PROFINET or PROFIBUS) PROFINET example The PROFINET example consists of the following: ● 16 PROFINET slave devices named "et200s_1" through "et200s_16" ● The 16 PROFINET devices use PROFINET device numbers 1 through 16, respectively. ● Each slave device is configured with multiple I/O modules. ●...
Page 473
Extended instructions 9.7 Diagnostics (PROFINET or PROFIBUS) Table 9- 164 Example 2: A module has been pulled from PROFINET slave device "et200s_1". A value of 0x0300_0000 is returned for MODE 2 (Device defective). Byte with value Bit pattern with value Notes Byte 1 0x03 Bit 7 0000-0011 Bit 0...
Extended instructions 9.7 Diagnostics (PROFINET or PROFIBUS) 9.7.8 ModuleStates instruction You can use the ModuleStates instruction to return the status of all of the modules in a PROFIBUS or PROFINET station. Table 9- 167 ModuleStates instruction LAD / FBD Description ret_val := ModuleStates( ModuleStates retrieves the operational states laddr:=_word_in_,...
Page 475
Extended instructions 9.7 Diagnostics (PROFINET or PROFIBUS) Table 9- 168 Data types for the parameters Parameter and type Data type Description LADDR HW_DEVICE Logical address (Identifier for the I/O modules) MODE UInt Supports five modes of operation. The MODE input determines which data will be returned to the location specified for STATE information.
Extended instructions 9.7 Diagnostics (PROFINET or PROFIBUS) 9.7.8.1 ModuleStates example configurations PROFIBUS example The PROFIBUS example consists of the following: ● 16 PROFIBUS devices named "DPSlave_10" through "DPSlave_25" ● The 16 PROFIBUS devices use PROFIBUS addresses 10 through 25, respectively. ●...
Page 477
Extended instructions 9.7 Diagnostics (PROFINET or PROFIBUS) Table 9- 171 Example 2: A module has been pulled from PROFIBUS slave device "DPSlave_12". A value of 0x0900_0000 is returned for MODE 2 (Module defective). Byte with value Bit pattern with value Notes Byte 1 0x09 Bit 7 0000-1001 Bit 0...
Page 478
Extended instructions 9.7 Diagnostics (PROFINET or PROFIBUS) PROFINET example The PROFINET example consists of the following: ● 16 PROFINET slave devices named "et200s_1" through "et200s_16" ● The 16 PROFINET devices use PROFINET device numbers 1 through 16, respectively. ● Each slave device is configured with multiple I/O modules. ●...
Page 479
Extended instructions 9.7 Diagnostics (PROFINET or PROFIBUS) Table 9- 176 Example 2 (continued): A module has been pulled from PROFIBUS slave device "et200s_1". A value of 0xFF7F_1F00 is returned for MODE 4 (Module exists). Byte with value Bit pattern with value Notes Byte 1 0xFF Bit 7 1111-1111 Bit 0...
Extended instructions 9.7 Diagnostics (PROFINET or PROFIBUS) 9.7.9 GET_DIAG (Read diagnostic information) Description You can use the "GET_DIAG" instruction to read out the diagnostic information of a hardware device. The hardware device is selected with the LADDR parameter. With the MODE parameter, you select which diagnostic information to read.
Page 481
Extended instructions 9.7 Diagnostics (PROFINET or PROFIBUS) MODE parameter Depending on the value at the MODE parameter, different diagnostics data is output at the DIAG, CNT_DIAG and DETAILS output parameters: Table 9- 180 MODE parameter MODE Description DIAG CNT_DIAG DETAILS Output of all supported diag- Bit string of the supported nostic information for a mod-...
Page 482
Extended instructions 9.7 Diagnostics (PROFINET or PROFIBUS) DIS structure With the MODE parameter = 1, the diagnostics information is output in accordance with the DIS structure. The following table shows the meaning of the individual parameter values: Table 9- 181 Structure of the Diagnostic Information Source (DIS) Parameter Data type Value...
Page 483
Extended instructions 9.7 Diagnostics (PROFINET or PROFIBUS) Parameter Data type Value Description 16 to 31 Status information for modules generated by the CPU: Bit 16 = 1: Module disabled Bit 17 = 1: CiR operation active Bit 18 = 1: Input not available Bit 19 = 1: Output not available Bit 20 = 1: Overflow diagnostics buffer Bit 21 = 1: Diagnostics not available...
Page 484
Extended instructions 9.7 Diagnostics (PROFINET or PROFIBUS) Parameter Data type Value Description Module defective No power In STOP / without DIS DNN structure With the MODE parameter = 2, the diagnostics information details are output in accordance with the DNN structure. The following table shows the meaning of the individual parameter values: Table 9- 182 Structure of the Diagnostic Navigation Node (DNN) Parameter...
Page 485
Extended instructions 9.7 Diagnostics (PROFINET or PROFIBUS) Example The following ladder logic network and DB show how to use the three modes with the three structures: ● DIS ● DNN ① ② S7-1200 Programmable controller System Manual, V4.2, 09/2016, A5E02486680-AK...
Extended instructions 9.7 Diagnostics (PROFINET or PROFIBUS) Note In the DB, you must manually type in the data type to access each of the three structures; there is no dropdown list selection. Type in the data types exactly as shown below: •...
Extended instructions 9.8 Pulse Pulse 9.8.1 CTRL_PWM (Pulse width modulation) Table 9- 185 CTRL_PWM (Pulse Width Modulation) instruction LAD / FBD Description "CTRL_PWM_DB"( Provides a fixed cycle time output with a variable duty PWM:=_uint_in_, cycle. The PWM output runs continuously after being ENABLE:=_bool_in_, started at the specified frequency (cycle time).
Extended instructions 9.8 Pulse Note Digital I/O points assigned to PWM and PTO cannot be forced The digital I/O points used by the pulse-width modulation (PWM) and pulse-train output (PTO) devices are assigned during device configuration. When digital I/O point addresses are assigned to these devices, the values of the assigned I/O point addresses cannot be modified by the Watch table force function.
Page 489
Extended instructions 9.8 Pulse Table 9- 189 Data types for the parameters Parameter and type Data type Description Bool 1 = Instruction enabled 0 = Instruction disabled Bool 1 = Set PTO output frequency to value in FREQUENCY input 0 = No change to PTO HW_PTO PTO identifier: Hardware ID of the pulse generator: (Word)
Page 490
Extended instructions 9.8 Pulse The CTRL_PTO instruction stores the parameter information in the DB. The data block parameters are not separately changed by the user, but are controlled by the CTRL_PTO instruction. Specify the enabled pulse generator to use, by using its tag name or hardware identifier for the PTO parameter.
Page 491
Extended instructions 9.8 Pulse Since the CTRL_PTO instruction only starts the PTO, the CTRL_PTO instruction finishes immediately. As a result, the BUSY output never turns on. The DONE output comes on as long as no error occurs. If an error is detected, the ERROR parameter is set to TRUE, and the STATUS parameter contains a condition code.
Extended instructions 9.8 Pulse Table 9- 190 STATUS parameter error code value Error code (W#16#...) Description No errors 0x8090 Pulse generator with the specified hardware ID is in use. 0x8091 Frequency out-of-range. The desired frequency exceeds the maximum frequency of the pulse output selected.
Page 493
Extended instructions 9.8 Pulse The table below shows the default I/O assignments; however, the four pulse generators can be configured to any CPU built-in or SB digital output. Different output points support different voltages and speeds, so take that into account when assigning PWM/PTO locations.
Extended instructions 9.8 Pulse Description Pulse Direction PWM4 Built-in outputs Q0.6 SB outputs Q4.3 The CPU 1211C does not have outputs Q0.4, Q0.5, Q0.6, or Q0.7. Therefore, these outputs can- not be used in the CPU 1211C. The CPU 1212C does not have outputs Q0.6 or Q0.7. Therefore, these outputs cannot be used in the CPU 1212C.
Page 495
Extended instructions 9.8 Pulse Table 9- 193 SB signal board output: Maximum frequency (PTO) and minimum cycle time (PWM) SB signal board SB output channel PTO maximum fre- PWM minimum cycle quency time SB 1222, 200 kHz DQe.0 to DQe.3 200kHz 5 µs SB 1223, 200 kHz...
Page 496
Extended instructions 9.8 Pulse ● Initial pulse duration (only applies to PWM): Assign the pulse duration of the first pulse. You can change this value at runtime using the Q word address configured in I/O addresses. Range is based upon the Pulse duration format. ●...
Page 497
Extended instructions 9.8 Pulse Hardware outputs In the hardware outputs section, select the output channel from the dropdown menu. Depending on the configuration, there may be one or two outputs to select. If you do assign an output channel to a pulse generator, the output channel cannot be used by another pulse generator, HSC, or the process image register.
Extended instructions 9.9 Recipes and Data logs When you select the "Allow runtime modification of the cycle time" check box, the TIA Portal automatically selects a new address for the output address. The new output address cannot be the same as the default address for that pulse generator. The TIA Portal uses the next available block of six consecutive bytes.
Extended instructions 9.9 Recipes and Data logs Recipe import (from CSV file to recipe DB) Once a recipe export operation is completed, then you can use the generated CSV file as a data structure template. 1. Use the file browser page in the CPU web server to download an existing recipe CSV file from the CPU to a PC 2.
Page 500
Extended instructions 9.9 Recipes and Data logs First, create a new PLC data type Add a new PLC data type whose name is the recipe type. In the following image, "Beer_Recipe" is the new complex PLC data type that stores a sequence of simple data types.
Page 501
Extended instructions 9.9 Recipes and Data logs Recipe export (from recipe DB to CSV file) "RecipeExport (Page 502)" execution transfers recipe DB data to a CSV file, as shown in the following text file. Recipe_DB.csv index,productname,water,barley,wheat,hops,yeast,waterTmp, mashTmp,mashTime,QTest 1,”Pils”,10,9,3,280,39,40,30,100,0 2,”Lager”,10,9,3,150,33,50,30,120,0 3,”BlackBeer”,10,9,3,410,47,60,30,90,1 4 ”Not_used”,0,0,0,0,0,0,0,0,0 5 ”Not_used”,0,0,0,0,0,0,0,0,0 Recipe import (from CSV file to recipe DB)
Extended instructions 9.9 Recipes and Data logs Display CSV recipe data in Excel The CSV file can be opened in Excel to make reading and editing easier. If the commas are not recognized as decimal separators, use the Excel import function to output the data in structured form 9.9.1.3 Program instructions that transfer recipe data...
Page 503
Extended instructions 9.9 Recipes and Data logs Table 9- 195 Data types for the parameters Parameter and type Data type Description Bool Control parameter REQUEST: Activates the export on a positive edge. RECIPE_DB In/Out Variant Pointer to the recipe data block. Refer to the "Recipe DB example (Page 499)"...
Page 504
Extended instructions 9.9 Recipes and Data logs RecipeImport (Recipe import) Table 9- 197 RecipeImport instruction LAD/FBD Description "RecipeImport_DB"( The "RecipeImport" instruction im- req:=_bool_in_, ports recipe data from a CSV file, in done=>_bool_out_, CPU load memory, to a recipe data block referenced by the RECIPE_DB busy=>_bool_out_, parameter.
Page 505
Extended instructions 9.9 Recipes and Data logs A recipe DB that contains a structure which is consistent with the CSV file data structure must exist, before a recipe import operation is possible. CSV file rules: ● The CSV file must be located in the root directory "Recipes" folder of internal load memory or external load memory, if an optional external "program"...
Extended instructions 9.9 Recipes and Data logs 9.9.1.4 Recipe example program Prerequisites for the recipe example program The prerequisites for the recipe example program are as follows: ● A recipe DB that stores all recipe records. The recipe DB is stored in load memory. ●...
Page 507
Extended instructions 9.9 Recipes and Data logs Example recipe program Network 1 A rising edge on REQ starts the export process. A CSV file is generated from the recipe DB data and placed in the CPU memory recipes folder. Network 2 Capture the STATUS output from RecipeExport execution, because it is only valid for one scan.
Page 508
Extended instructions 9.9 Recipes and Data logs Network 5 READ_DBL copies the start values from one recipe "Recipe_DB". Products[1] (in CPU load memory) to the Active_Recipe DB current values (in CPU work memory). After READ_DBL execution, your program logic can access the recipe component values by addressing locations in the Active_Recipe DB.
Extended instructions 9.9 Recipes and Data logs 9.9.2 Data logs Your control program can use the Data log instructions to store run-time data values in persistent log files. The CPU stores data log files in flash memory (CPU or memory card) in standard CSV (Comma Separated Value) format.
Extended instructions 9.9 Recipes and Data logs 9.9.2.2 Program instructions that control data logs DataLogCreate (Create data log) Table 9- 200 DataLogCreate instruction LAD/FBD Description "DataLogCreate_DB"( Creates and initializes a data log file. The CPU req:=_bool_in_, creates the file in the \DataLogs folder, using the records:=_udint_in_, name in the NAME parameter, and implicitly opens the file for write operations.
Page 511
Extended instructions 9.9 Recipes and Data logs Parameter and type Data type Description NAME Variant Data log name: You provide the name. This variant only supports a String data type and can only be located in local, DB, or M memory. (Default value: ' ') The string reference is also used as the name of the data log file.
Page 512
Extended instructions 9.9 Recipes and Data logs The CPU creates a data log file with a pre-determined fixed sized based on the RECORDS and DATA parameters and organizes the data records as a circular log file. The DataLogWrite instruction appends new records to the data log file until it stores the maximum number of records that is specified by the RECORDS parameter.
Page 513
Extended instructions 9.9 Recipes and Data logs Table 9- 202 Values of ERROR and STATUS ERROR STATUS Description (W#16#..) 0000 No error 7000 Call with no REQ edge: BUSY = 0, DONE = 0 7001 First call with REQ edge (working): BUSY = 1, DONE = 0 7002 call (working): BUSY = 1, DONE = 0 8070...
Page 514
Extended instructions 9.9 Recipes and Data logs DataLogOpen (Open data log) Table 9- 203 DataLogOpen instruction LAD / FBD Description "DataLogOpen_DB"( Opens a pre-existing data log file. You must open a data log before req:=_bool_in_, you can write (Page 516) new records to the log. You can open and mode:=_uint_in_, close data logs individually.
Page 515
Extended instructions 9.9 Recipes and Data logs You can provide either the NAME or an ID (ID parameter as an input) of a pre-existing data log. If you provide both parameters and a valid ID does correspond to the NAME data log, then the ID is used, and the NAME ignored.
Page 516
Extended instructions 9.9 Recipes and Data logs DataLogWrite (Write data log) Table 9- 206 DataLogWrite instruction LAD / FBD Description "DataLogWrite_DB"( Writes a data record into the specified data log. The pre-existing target req:=_bool_in_, data log must be open (Page 514) before you can write to it with a Dat- done=>_bool_out_, aLogWrite instruction.
Page 517
Extended instructions 9.9 Recipes and Data logs NOTICE Data log creation operations must be complete, before starting a data log write operation DataLogCreate and DataLogNewFile log file creation operations extend over many program scan cycles. The actual time required for the log file creation depends on the record structure and number of records.
Page 518
Extended instructions 9.9 Recipes and Data logs DataLogClear (Empty data log) Description Table 9- 209 DataLogClear instruction LAD / FBD Description "DataLogClear_DB"( The "DataLogClear" instruction deletes all data REQ:=_bool_in_, records in an existing data log. The instruction DONE=>_bool_out_, does not delete the optional header of the CSV file (see the description of the HEADER parameter of BUSY=>_bool_out_, the instruction "DataLogCreate (Page 510)").
Page 519
Extended instructions 9.9 Recipes and Data logs Parameter STATUS Error code* Explanation (W#16#...) 0000 No error. 7000 No job processing active. 7001 Start of job processing. Parameter BUSY = 1, DONE = 0 7002 Intermediate call (REQ i rrelevant): Instruction already active; BUSY has the value "1". 8080 The data log file selected with the ID parameter cannot be processed with the "DataLogClear"...
Page 520
Extended instructions 9.9 Recipes and Data logs Table 9- 211 Data types for the parameters Parameter and type Data type Description Bool A low to high (positive edge) signal starts the operation. (Default value: False) In/Out DWord Numeric identifier of a data log. Only used as an input for the DataLogClose instruction.
Page 521
Extended instructions 9.9 Recipes and Data logs Parameters The following table shows the parameters of the "DataLogDelete" instruction: Parameter Declaration Data type Memory area Description Input BOOL I, Q, M, L, D, T, C or Execution of the instruction upon a rising constant edge.
Page 522
Extended instructions 9.9 Recipes and Data logs Parameter RET_VAL Error code* Explanation (W#16#...) No error. 7000 No job processing active. 7001 Start of job processing. Parameter BUSY = 1, DONE = 0 7002 Intermediate call (REQ i rrelevant): Instruction already active; BUSY has the value "1". 8091 A data type other than STRING is being used at the NAME parameter.
Page 523
Extended instructions 9.9 Recipes and Data logs Table 9- 215 Data types for the parameters Parameter and type Data type Description Bool A low to high (positive edge) signal starts the operation. (Default value: False) RECORDS UDInt The maximum number of data records the circular data log can contain before overwriting the oldest entry.
Page 524
Extended instructions 9.9 Recipes and Data logs DataLogNewFile operation: When your program logic gets the data log is full signal, this state is used to activate a DataLogNewFile operation. You must execute DataLogNewFile with the ID of an existing (usually full) and open data log, but a new unique NAME parameter.
Extended instructions 9.9 Recipes and Data logs 9.9.2.3 Working with data logs The data log files are stored as comma separated value format (*.csv) in persistent flash memory. You can view the data logs by using the PLC Web server feature or by removing the PLC memory card and inserting it in a standard PC card reader.
Extended instructions 9.9 Recipes and Data logs Make a copy of the data log files and put the copies on a local drive of your PC. Then, you can use Excel to open a local copy of a *.csv file and not the original file that is stored on the memory card.
Page 527
Extended instructions 9.9 Recipes and Data logs Determining load memory free space The amount of load memory free space varies during normal operations as the operating system uses and releases memory. Use the following steps to view the load memory memory size.
Page 528
Extended instructions 9.9 Recipes and Data logs Size of individual data elements Log data is stored as character bytes in the CSV (comma separated values) file format. The following table shows the number of bytes that are required to store each data element. Data type Number of bytes (includes data plus one comma byte) Bool Byte...
Extended instructions 9.9 Recipes and Data logs 9.9.2.5 Data log example program This Data log example program does not show all the program logic necessary to get sample values from a dynamic process, but does show the key operations of the Data log instructions.
Page 530
Extended instructions 9.9 Recipes and Data logs Network 1 REQ rising edge starts the data log creation process. Network 2 Capture the DONE output from DataLogCreate because it is only valid for one scan. Network 3 If an error exists save the status output Network 4 A positive edge signal triggers when to store new process values in the MyData structure.
Page 531
Extended instructions 9.9 Recipes and Data logs Network 5 The EN input state is based upon when the DataLogCreate operation is complete. A create operation extends over many scan cycles and must be complete before executing a write operation. The positive edge signal on the REQ input is the event that triggers an enabled write operation.
Page 532
Extended instructions 9.9 Recipes and Data logs Network 8 The ID parameter is an IN/OUT type. First, you supply the ID value of the existing Data log whose structure you want to copy. After the DataLogNewFile operation is complete, a new and unique ID value for the new Data log is written back to the ID reference location. The required DONE bit = TRUE capture is not shown, refer to networks 1, 2, and 4 for an example of DONE bit logic.
Page 533
Extended instructions 9.9 Recipes and Data logs Table 9- 218 Downloaded .csv file examples viewed with Excel Two records written in a five record max- imum file Five records in a Data log file with a five record maximum After one additional record is written to the file above which is full, the sixth write operation overwrites the oldest record one with record six.
Extended instructions 9.10 Data block control 9.10 Data block control 9.10.1 CREATE_DB (Create data block) Table 9- 219 CREATE_DB instruction LAD / FBD Description ret_val := CREATE_DB( Use the instruction "CREATE_DB" to create a REQ:=_bool_in_, new data block in the load and/or work memory. LOW_LIMIT:=_uint_in_, The instruction "CREATE_DB"...
Page 535
Extended instructions 9.10 Data block control Functional description The "CREATE_DB" instruction works asynchronously. Processing takes place across several calls. You start the job by calling "CREATE_DB" with REQ = 1. The output parameters RET_VAL and BUSY indicate the status of the job. See also: DELETE_DB (Delete data block) (Page 542) Parameters The following table shows the parameters of the "CREATE_DB"...
Page 536
Extended instructions 9.10 Data block control Parameter Declara- Data Memory area Description tion type Bit 3 = 0: Creation of the DB either in the load memory or in • the work memory (selection using bit 0, see above) Bit 3 = 1: Creation of the DB both in the load memory and in •...
Page 537
Extended instructions 9.10 Data block control Parameter RET_VAL Error code* Description (W#16#...) 0000 No error 0081 The destination area is greater than the source area. The source area is written completely to the destination area. The remaining bytes of the destination area remain unchanged.
Extended instructions 9.10 Data block control 9.10.2 READ_DBL and WRIT_DBL (Read/write a data block in load memory) instructions Table 9- 220 READ_DBL and WRIT_DBL instructions LAD / FBD Description READ_DBL( Copies DB start values or part of the req:=_bool_in_, values, from load memory to a target srcblk:=_variant_in_, DB in the work memory.
Page 539
Extended instructions 9.10 Data block control You must create the data blocks for READ_DBL and WRIT_DBL prior to calling these instructions in the STEP 7 program. If you created the source DB as a "standard" type then the destination DB must also be the "standard" type. If you created the source data block as an "optimized"...
Page 540
Extended instructions 9.10 Data block control Recipes and machine setup information You can use the READ_DBL and WRIT_DBL instructions to manage recipes or machine setup information. This essentially becomes another method of achieving retentive data for values that do not change often, although you would want to limit the number of writes to prevent wearing out the flash prematurely.
Extended instructions 9.10 Data block control 9.10.3 ATTR_DB (Read data block attribute) Table 9- 223 ATTR_DB instruction LAD / FBD Description ret_val := ATTR_DB( You use the instruction "ATTR_DB" to obtain REQ:=_bool_in_, information about a data block (DB) located in the DB_NUMBER:=_uint_in_, work memory of the CPU.
Extended instructions 9.10 Data block control Parameter Declaration Data type Memory area Description If bit 0 = 1, then bit 2 is irrelevant and gets the value Bit 2 = 0: Retentive - The DB is regarded as re- • tentive if at least one value has been set as reten- tive.
Page 543
Extended instructions 9.10 Data block control Functional description The "DELETE_DB" instruction works asynchronously, that is, its execution extends over multiple calls. You start the interrupt transfer by calling the instruction with REQ = 1. Output parameter BUSY and bytes 2 and 3 of output parameter RET_VAL show the status of the job.
Extended instructions 9.11 Address handling 9.11 Address handling 9.11.1 GEO2LOG (Determine the hardware identifier from the slot) You use the GEO2LOG instruction to determine the hardware identifier based upon slot information. Table 9- 225 GEO2LOG instruction LAD / FBD Description ret_val := GEO2LOG( You use the GEO2LOG instruction to GEOADDR:=_variant_in_out_,...
Page 545
Extended instructions 9.11 Address handling ● With HWTYPE = 5 (submodule): – All parameters of GEOADDR are evaluated. – The hardware identifier of the submodule is output. The AREA parameter of the GEOADDR system data type is not evaluated. Table 9- 226 Data types for the parameters Parameter and type Data type Description...
Extended instructions 9.11 Address handling 9.11.2 LOG2GEO (Determine the slot from the hardware identifier) You use the LOG2GEO instruction to determine the geographical address (module slot) from the logical address belonging to a hardware identifier. Table 9- 228 LOG2GEO instruction LAD / FBD Description ret_val := LOG2GEO(...
Page 547
Extended instructions 9.11 Address handling Table 9- 229 Data types for the parameters Parameter and type Data type Description LADDR HW_ANY Hardware identifier of the IO system or the module. The number is as- signed automatically and is stored in the properties of the CPU or the interface of the hardware configuration.
Extended instructions 9.11 Address handling 9.11.3 IO2MOD (Determine the hardware identifier from an I/O address) You use the IO2MOD instruction to determine the hardware identifier of the module from an I/O address of a (sub)module. Table 9- 231 IO2MOD instruction LAD / FBD Description ret_val := IO2MOD(...
Page 549
Extended instructions 9.11 Address handling Table 9- 232 Data types for the parameters Parameter Declaration Data type Memory area Description ADDR IN or IN/OUT ? Variant I, Q, M, D, L IO address (I, Q, PI, PQ) within a (sub)module. Make sure that slice access is not used for the parameter ADDR.
Extended instructions 9.11 Address handling 9.11.4 RD_ADDR (Determine the IO addresses from the hardware identifier) You use the RD_ADDR instruction to get the I/O addresses of a submodule. Table 9- 234 RD_ADDR instruction LAD / FBD Description ret_val := RD_ADDR( You use the RD_ADDR instruction to get the laddr:=_word_in_, I/O addresses of a submodule.
Extended instructions 9.11 Address handling Table 9- 235 Data types for the parameters Parameter and type Data type Description LADDR HW_IO Hardware identifier of the (sub)module RET_VAL Error code of the instruction PIADDR UDInt Start address of the input module PICOUNT UInt Number of bytes of the inputs...
Page 552
Extended instructions 9.11 Address handling Structure of the GEOADDR system data type The structure GEOADDR is automatically created if you enter "GEOADDR" as the data type in a data block. Parameter name Data type Description GEOADDR STRUCT HWTYPE UINT Hardware type: 1: IO system (PROFINET/PROFIBUS) •...
Extended instructions 9.12 Common error codes for the Extended instructions 9.12 Common error codes for the Extended instructions Table 9- 237 Common condition codes for the extended instructions Condition code (W#16#..) Description 8x22 Area too small for input 8x23 Area too small for output 8x24 Illegal input area 8x25...
Page 554
Extended instructions 9.12 Common error codes for the Extended instructions S7-1200 Programmable controller System Manual, V4.2, 09/2016, A5E02486680-AK...
Technology instructions 10.1 Counting (High-speed counters) The basic counter instructions, described in "Counter operations" (Page 244) are limited to counting events that occur at a rate slower than the scan cycle of the S7-1200 CPU. The High-speed counter (HSC) function provides the ability to count pulses occurring at a higher rate than the PLC scan cycle.
Technology instructions 10.1 Counting (High-speed counters) 10.1.1.2 Example To use the CTRL_HSC_EXT instruction, follow the steps below: 1. Place the CTRL_HSC_EXT instruction in the ladder network, which also creates the following instance data block: "CTRL_HSC_EXT_DB": 2. Attach the HSC’s hardware identifier, found in the HSC’s properties, to the "HSC" pin of the ladder instruction.
Page 558
Technology instructions 10.1 Counting (High-speed counters) 3. Create a global data block named "Data_block_1" (You can also use an existing global data block.): – Within "Data_block_1", locate an empty row and add a variable named "MyHSC". – In the "Data type" column, add one of the following System Data Types (SDT). Select the SDT that corresponds to the HSC’s configured type of counting.
Page 559
Technology instructions 10.1 Counting (High-speed counters) 4. Assign the variable "'Data_block_1'. MyHSC" to the CTRL input pin of the CTRL_HSC_EXT instruction: – Select "Data_Block_1". – Select "MyHSC". S7-1200 Programmable controller System Manual, V4.2, 09/2016, A5E02486680-AK...
Page 560
Technology instructions 10.1 Counting (High-speed counters) – Delete the period (".") following: "'Data_Block_1'.MyHSC". Then, either click outside the box or press the ESC key once and then press the Enter key. Note After deleting the period (".") following: "'Data_Block_1'.MyHSC", do not press only the Enter key.
Technology instructions 10.1 Counting (High-speed counters) 10.1.1.3 CTRL_HSC_EXT Instruction System Data Types (SDT) The following System Data Types (SDTs) are only used with the CTRL_HSC_EXT instruction’s CTRL pin. To use them, create a user data block and add an object with the data type of the SDT that corresponds to the HSC’s configured mode (type of counting).
Page 562
Technology instructions 10.1 Counting (High-speed counters) Table 10- 4 HSC_Count structure Structure element Declaration Data type Description CurrentCount Dint Returns the HSC’s current count value CapturedCount Dint Returns the counter value captured on the specified input event SyncActive Bool Status bit: Sync input was activated DirChange Bool Status bit: Counting direction has changed...
Page 563
Technology instructions 10.1 Counting (High-speed counters) SDT: HSC_Period The "HSC_Period" data type corresponds to an HSC configured for "Period" mode. The CTRL_HSC_EXT instruction provides program access to the number of input pulses over a specified measurement interval. This instruction allows for the time period between input pulses to be calculated with a fine nanosecond resolution.
Page 564
Technology instructions 10.1 Counting (High-speed counters) The following examples show how the instruction makes period measurements: S7-1200 Programmable controller System Manual, V4.2, 09/2016, A5E02486680-AK...
Page 565
Technology instructions 10.1 Counting (High-speed counters) SDT: HSC_Frequency The "HSC_Frequency" data type corresponds to an HSC configured for "Frequency" mode. The instruction CTRL_HSC_EXT provides program access to the frequency of input pulses, measured over a specified time period. Using the CTRL_HSC_EXT instruction in Frequency mode provides the following capabilities: Table 10- 6 HSC_Frequency structure...
Technology instructions 10.1 Counting (High-speed counters) 10.1.2 Operating the high-speed counter 10.1.2.1 Synchronization function You use the Sync (synchronization) function to set the counter to the start value with an external input signal. You can modify the start value by executing the CTRL_HSC_EXT instruction.
Technology instructions 10.1 Counting (High-speed counters) Refer to Input functions (Page 578) for information on how to configure the Synchronization function. 10.1.2.2 Gate function Many applications require counting processes to be started or stopped in accordance with other events. In such cases, counting is started and stopped using the internal gate function. Each HSC channel has two gates: a software gate and a hardware gate.
Page 568
Technology instructions 10.1 Counting (High-speed counters) The figure below shows an example of the hardware gate opening and closing with a digital input. The digital input is configured for an active high level: Note The configured input filters delay the control signal of the digital input. The hardware gate function is only available to be used when the HSC is configured for Count mode.
Technology instructions 10.1 Counting (High-speed counters) 10.1.2.3 Capture function You use the Capture function to save the current counter value with an external reference signal. When configured and enabled by the "HSC_Count.EnCapture" bit, the Capture function causes the current count to be captured on the occurrence of an external input edge.
Technology instructions 10.1 Counting (High-speed counters) 10.1.2.4 Compare function When enabled, the Compare output function generates a single, configurable pulse that occurs every time the configured event occurs. The events include count equal to one of the reference values or the counter overflows. If a pulse is in progress and the event occurs again, a pulse is not produced for that event.
Technology instructions 10.1 Counting (High-speed counters) 10.1.2.5 Applications A typical application uses the HSC to monitor feedback from an incremental shaft encoder. The shaft encoder provides a specified number of counts per revolution that you can use as the clock generator input to the HSC. There is also a reset pulse that occurs once per revolution that you can use as the sync input to the HSC.
Technology instructions 10.1 Counting (High-speed counters) 10.1.3 Configuring a high-speed counter To setup the high-speed counter (HSC): ● Select Device Configuration from the Project navigator. ● Select the CPU you wish to configure. ● Click the Properties tab, located in the Inspector window (see figure below). ●...
Technology instructions 10.1 Counting (High-speed counters) The following table provides an overview of what inputs and outputs are available for each configuration: Table 10- 8 Counting modes for HSC Type Input 1 Input 2 Input 3 Input 4 Input 5 Output 1 Function Single-phase...
Technology instructions 10.1 Counting (High-speed counters) 10.1.3.2 Operating phase Select the desired operating phase of the HSC. The four figures below show when the counter value changes, when the current value (CV) equals the reference value (RV) event occurs, and when the direction change event occurs. Single phase Single-phase (not available with motion control) counts pulses: ●...
Page 575
Technology instructions 10.1 Counting (High-speed counters) Two phase Two phase counts: ● Up on the clock up input ● Down on the clock down input S7-1200 Programmable controller System Manual, V4.2, 09/2016, A5E02486680-AK...
Page 576
Technology instructions 10.1 Counting (High-speed counters) A/B counter A/B phase quadrature counts: ● Up on the rising edge of the clock A input when the clock B input is low ● Down on the falling edge of the clock A input when the clock B input is low S7-1200 Programmable controller System Manual, V4.2, 09/2016, A5E02486680-AK...
Page 577
Technology instructions 10.1 Counting (High-speed counters) A/B counter fourfold A/B phase quadrature fourfold counts: ● Up on the rising edge of the clock A input when the clock B input is low ● Up on the falling edge of the clock A input when the clock B input is high ●...
Technology instructions 10.1 Counting (High-speed counters) 10.1.3.3 Initial values Each time the CPU goes to RUN, it loads initial values. The initial values are only used in count mode: ● Initial counter value: The program sets the current count value to the initial counter value when the CPU goes from STOP to RUN mode or when the program triggers the sync input.
Technology instructions 10.1 Counting (High-speed counters) Capture input The Capture input sets the captured count value to the count value saved at the moment you triggered the Capture input. You can trigger the capture when the input pin is in one of the following states: ●...
Technology instructions 10.1 Counting (High-speed counters) 10.1.3.6 Interrupt events Under the Event configuration section, you can select a hardware interrupt OB from the dropdown menu (or you can create a new OB) and attach it to an HSC event. The priority of the interrupt is in a range from 2 to 26, where 2 is the lowest priority and 26 is the highest priority.
Page 581
Technology instructions 10.1 Counting (High-speed counters) Use the following table and ensure that the CPU and SB input channels that you connect can support the maximum pulse rates in your process signals: Table 10- 9 CPU input: maximum frequency CPU Input channel Operating phase: Single Operating phase: A/B phase or Two phase...
Technology instructions 10.1 Counting (High-speed counters) When possible, avoid assigning multiple input functions of the same HSC to the same input point. For example, assigning I0.3 to the Sync input and the Gate input of HSC 1 to synchronize the count and disable counting at the same time is also a valid configuration. You can make this configuration, but it could produce unintended results.
Technology instructions 10.1 Counting (High-speed counters) 10.1.3.9 HSC input memory addresses Each HSC uses a double word section of I-memory that stores the current count. If you configure the HSC for frequency, then the frequency is stored in that input memory location. The available input address range is I0.0 to I1023.7 (maximum start address is I1020.0).
Technology instructions 10.1 Counting (High-speed counters) 10.1.4 Legacy CTRL_HSC (Control high-speed counter) instruction 10.1.4.1 Instruction overview Table 10- 12 CTRL_HSC instruction (For general purpose counting) LAD / FBD Description "CTRL_HSC_1_DB" ( Each CTRL_HSC (Control high-speed hsc:=W#16#0, counter) instruction uses a structure dir:=False, stored in a DB to maintain counter data.
Page 585
Technology instructions 10.1 Counting (High-speed counters) Table 10- 13 Data types for the parameters Parameter Declaration Data type Description HW_HSC HSC identifier Bool 1 = Request new direction 1, 2 Bool 1 = Request to set new counter value Bool 1= Request to set new reference value PERIOD Bool...
Technology instructions 10.1 Counting (High-speed counters) Table 10- 14 Execution condition codes STATUS (W#16#) Description No error 80A1 HSC identifier does not address a HSC 80B1 Illegal value in NEW_DIR 80B2 Illegal value in NEW_CV 80B3 Illegal value in NEW_RV 80B4 Illegal value in NEW_PERIOD 80C0...
Technology instructions 10.1 Counting (High-speed counters) 10.1.4.3 HSC current count value The CPU stores the current value of each HSC in an input (I) address. The following table shows the default addresses assigned to the current value for each HSC. You can change the I address for the current value by modifying the properties of the CPU in the Device Configuration.
Technology instructions 10.2 PID control 10.2 PID control STEP 7 provides the following PID instructions for the S7-1200 CPU: ● The PID_Compact instruction is used to control technical processes with continuous input- and output variables. ● The PID_3Step instruction is used to control motor-actuated devices, such as valves that require discrete signals for open- and close actuation.
Page 589
Technology instructions 10.2 PID control PID algorithm The PID (Proportional/Integral/Derivative) controller measures the time interval between two calls and then evaluates the results for monitoring the sampling time. A mean value of the sampling time is generated at each mode changeover and during initial startup. This value is used as reference for the monitoring function and is used for calculation.
Technology instructions 10.2 PID control 10.2.1 Inserting the PID instruction and technology object STEP 7 provides two instructions for PID control: ● The PID_Compact instruction and its associated technology object provide a universal PID controller with tuning. The technology object contains all of the settings for the control loop.
Page 591
Technology instructions 10.2 PID control Table 10- 17 (Optional) Creating a technology object from the project navigator You can also create technology objects for your project before inserting the PID instruction. By creating the technology object before inserting a PID instruction into your user program, you can then select the technology object when you insert the PID instruction.
Technology instructions 10.2 PID control 10.2.2 PID_Compact 10.2.2.1 PID_Compact instruction The PID_Compact instruction provides a universal PID controller with integrated self-tuning for automatic and manual mode. Table 10- 18 PID_Compact instruction LAD / FBD Description "PID_Compact_1"( PID_Compact provides a PID controller with Setpoint:=_real_in_, self-tuning for automatic and manual mode.
Page 593
Technology instructions 10.2 PID control Table 10- 19 Data types for the parameters Parameter and type Data type Description Setpoint Real Setpoint of the PID controller in automatic mode. (Default value: 0.0) Input Real A tag of the user program is used as the source of the process value. (Default value: 0.0) If you are using the Input parameter, you must set Con- fig.InputPerOn = FALSE.
Page 594
Technology instructions 10.2 PID control Parameter and type Data type Description Output_PWM Bool Output value for pulse width modulation. (Default value: FALSE) On and Off times form the output value. SetpointLimit_H Bool Setpoint high limit. (Default value: FALSE) If SetpointLimit_H = TRUE, the absolute setpoint upper limit is reached (Setpoint ≥...
Page 595
Technology instructions 10.2 PID control Operation of the PID_Compact controller Figure 10-1 Operation of the PID_Compact controller Figure 10-2 Operation of the PID_Compact controller as a PIDT1 controller with anti-windup S7-1200 Programmable controller System Manual, V4.2, 09/2016, A5E02486680-AK...
Technology instructions 10.2 PID control 10.2.2.2 PID_Compact instruction Process value limits "Process value limits" are normally used in conjunction with the analog input; however, you can use them for other purposes. The Process value limits configuration serves two functions: ● Sets the upper and lower limits for the Setpoint High/Low alarm outputs on the PID block ●...
Technology instructions 10.2 PID control If you enter a setpoint that is out-of-range, the Compact_PID automatically limits the process variable to the configured range. For example, if the Process value high limit is set to 120% (as shown in the figure above), you can still enter a setpoint higher than 120%. As the process variable approaches 120%, the PID reduces the output and controls the process at the high limit of 120%.
Page 598
Technology instructions 10.2 PID control ErrorBit (DW#16#...) Description 10000 Invalid value at the ManualValue parameter: Value has an invalid number format. Note: If ActivateRecoverMode = TRUE before the error occurred, PID_Compact uses SubstituteOutput as the output value. As soon as you assign a valid value in the ManualValue parameter, PID_Compact uses it as the output value.
Technology instructions 10.2 PID control 10.2.2.4 PID_Compact instruction Warning parameters If the PID controller has several warnings pending, it displays the values of the error codes by means of binary addition. The display of error code 0003, for example, indicates that the errors 0001 and 0002 are pending.
Technology instructions 10.2 PID control 10.2.3 PID_3Step 10.2.3.1 PID_3Step instruction The PID_3Step instruction configures a PID controller with self-tuning capabilities that has been optimized for motor-controlled valves and actuators. Table 10- 22 PID_3Step instruction LAD / FBD Description "PID_3Step_1"( PID_3Step configures a PID controller with SetpoInt:=_real_in_, self-tuning capabilities that has been opti- Input:=_real_in_,...
Page 601
Technology instructions 10.2 PID control Table 10- 23 Data types for the parameters Parameter and type Data type Description Setpoint Real Setpoint of the PID controller in automatic mode. (Default value: 0.0) Input Real A tag of the user program is used as the source of the process value. (Default value: 0.0) If you are using the Input parameter, you must set Con- fig.InputPerOn = FALSE.
Page 602
Technology instructions 10.2 PID control Parameter and type Data type Description ManualUP Bool Manual_UP = TRUE: • – The valve is opened even if you use Output_PER or a position feedback. The valve is no longer moved if the high end stop has been reached.
Page 603
Technology instructions 10.2 PID control Parameter and type Data type Description Output_PER Word Analog output value. If Config.OutputPerOn = TRUE, the parameter Output_PER is used. SetpointLimitH Bool Setpoint high limit. (Default value: FALSE) If SetpointLimitH = TRUE, the absolute upper limit of the setpoint is reached (Setpoint ≥...
Page 604
Technology instructions 10.2 PID control Operation of the PID_3Step controller Figure 10-3 Operation of the PID_3Step controller as a PID T1 controller with anti-windup S7-1200 Programmable controller System Manual, V4.2, 09/2016, A5E02486680-AK...
Page 605
Technology instructions 10.2 PID control Figure 10-4 Operation of the PID_3Step controller without position feedback S7-1200 Programmable controller System Manual, V4.2, 09/2016, A5E02486680-AK...
Page 606
Technology instructions 10.2 PID control Figure 10-5 Operation of the PID_3Step controller with position feedback enabled S7-1200 Programmable controller System Manual, V4.2, 09/2016, A5E02486680-AK...
Technology instructions 10.2 PID control 10.2.3.2 PID_3Step instruction ErrorBit parameters If several errors are pending, the values of the error codes are displayed by means of binary addition. The display of error code 0003, for example, indicates that the errors 0001 and 0002 are also pending.
Page 608
Technology instructions 10.2 PID control ErrorBit (DW#16#...) Description 10000 Invalid value at the ManualValue parameter: Value has an invalid number format. The actuator cannot be moved to the manual value and remains in its cur- rent position. Assign a valid value in ManualValue or move the actuator in manual mode with Manual_UP and Manual_DN.
Technology instructions 10.2 PID control 10.2.3.3 PID_3Step instruction Warning parameters If the PID controller has several warnings pending, it displays the values of the error codes by means of binary addition. The display of error code 0003, for example, indicates that the errors 0001 and 0002 are pending.
Technology instructions 10.2 PID control 10.2.4 PID_Temp 10.2.4.1 PID_Temp instruction The PID_Temp instruction provides a universal PID controller that allows handling of the specific requirements of temperature control. Table 10- 26 PID_Temp instruction LAD / FBD Description "PID_Temp_1"( PID_Temp provides these capabilities: Setpoint:=_real_in_, Heating and cooling of the process with •...
Page 611
Technology instructions 10.2 PID control Table 10- 27 Data types for the parameters Parameter and type Data type Description Setpoint Real Setpoint of the PID controller in automatic mode. (Default value: 0.0) Input Real A tag of the user program is used as the source of the process value. (Default value: 0.0) If you are using the Input parameter, you must set Con- fig.InputPerOn = FALSE.
Page 612
Technology instructions 10.2 PID control Parameter and type Data type Description Mode IN/OUT Activated on the leading edge of the Mode Activate input. Operating mode selection (Default value: 0.0): Mode = 0: Inactive • Mode = 1: Pretuning • Mode = 2: Fine tuning •...
Page 613
Technology instructions 10.2 PID control Parameter and type Data type Description OutputCool_PWM Bool Pulse-width-modulated output value for cooling. (Default value: FALSE) This output value is only calculated if selected using the Con- fig.Output.Cool.Select = 1 (default value) parameter. If not selected, this output is always FALSE.
Page 614
Technology instructions 10.2 PID control Operation of the PID_Temp controller Selecting heating and/or cooling control You must first select if you need a cooling device in addition to the heating output at parameter "ActivateCooling". Afterwards, you must define if you want to use two PID- parameter-sets (advanced mode) or only one PID-parameter-set with an additional heating/cooling-factor at parameter "AdvancedCooling".
Page 615
Technology instructions 10.2 PID control PID_Temp controller operations The following block diagrams illustrate the PID_Temp instruction standard and cascade operations: Figure 10-6 PID_Temp_Operation_Block_Diagram S7-1200 Programmable controller System Manual, V4.2, 09/2016, A5E02486680-AK...
Page 616
Technology instructions 10.2 PID control Figure 10-7 PID_Temp_Cascade_Operation_Block_Diagram Cascading controllers You can cascade temperature PID controllers to process more than one temperature that depend on the same actuator. Call order You must call cascaded PID controllers in the same OB cycle. First, you must call the master, then, the next slave(s) in the control signal flow, and finally on to the last slave in the cascade.
Page 617
Technology instructions 10.2 PID control Communication connections When cascading controllers, you must connect the master and slave so that they can share information with each other. You must connect a slave’s “Master” IN/OUT parameter to its master’s “Slave” IN/OUT parameter in the signal flow direction. This shows a connection of PID_Temp controllers in a cascade with two sub-cascades: "PID_Temp1"...
Page 618
Technology instructions 10.2 PID control Autotuning An autotuning for a cascaded master controller must meet these requirements: ● Be commissioned from its inner slave to the first master. ● All slaves of the master have to be in “Automatic mode". ●...
Technology instructions 10.2 PID control Anti-windup A slave in a cascade gets its setpoint from the output of his master. If the slave reaches its own output limits while the master still sees a control deviation (setpoint – input), the master freezes or reduces its integration contribution to prevent a so-called "WindUp".
Page 620
Technology instructions 10.2 PID control ErrorBit (DW#16#...) Description 0200 Invalid value at the Input parameter: Value has an invalid number format. 2, 3 0400 Calculation of the output value failed. Check the PID parameters. 2, 3 0800 Sampling time error: PID_Temp is not called within the sampling time of the 1, 2 cyclic interrupt OB.
Technology instructions 10.2 PID control ErrorBit (DW#16#...) Description 4000000 Error starting fine tuning. “Heat.EnableTuning” and “Cool.EnableTuning” cannot be set at the same time. 8000000 Error during PID parameter calculation resulted in invalid parameters (for example, negative Gain; the current PID parameters remain unchanged and tuning has no effect).
Technology instructions 10.2 PID control Warning (DW#16#...) Description 8000 The specified value for the PIDSelfTune.SUT.AdaptDelayTime parameter is not supported, so the default value "0" is used. 10000 The specified value for the PIDSelfTune.SUT.CoolingMode parameter is not supported, so the default value "0" is used. Note: The PID controller deleted the following warnings automatically as soon as the cause is eliminated or the user action repeated with valid parameters: 0001, 0004, 0008, 0040, and 0100.
Page 623
Technology instructions 10.2 PID control Table 10- 31 Example configuration settings for the PID_3Step instruction Settings Description Basic Controller type Selects the engineering units. Invert the control logic Allows selection of a reverse-acting PID loop. If not selected, the PID loop is in direct-acting mode, and the output of PID loop •...
Page 624
Technology instructions 10.2 PID control Settings Description Reaction to error Defines the behavior of the valve when an error is detected or when the PID loop is reset. If you select to use a substitute position, enter the "Safety position". For analog feedback or analog output, select a value between the upper or lower limit for the out- put.
Technology instructions 10.2 PID control 10.2.6 Configuring the PID_Temp controller The parameters of the technology object determine the operation of the PID control- ler. Use the icon to open the configuration editor. Table 10- 32 Example configuration settings for the PID_Temp instruction Settings Description Basic...
Page 626
Technology instructions 10.2 PID control Controller type Setting TO-DB parameter Data Value range Description type Physical "PhysicalQuantity" Pre-selection for physical General • quantity (Enu unit value Temperature • No multi-value control (=default) and not editable in online mode of functional view. Unit of "PhysicalUnit User unit selection is set...
Page 627
Technology instructions 10.2 PID control Input / output parameters Setting TO-DB parameter Data Value range Description type Setpoint Setpoint Real) Real Only accessible in Prop- erty Page. No multi value control in online mode of function- al view. Selection "Config.InputPerOn" Bool Bool Selects which kind of...
Page 628
Technology instructions 10.2 PID control Setting TO-DB parameter Data Value range Description type Activate "Config.ActivateCooling" Bool Bool Checking this checkbox: output Sets the "Con- • (cooling) fig.Output. Heat.PidLowerLimit = 0.0 once. Sets the • "Con- fig.ActivateCooling" parameter to TRUE, instead of FALSE if unchecked (=default).
Page 629
Technology instructions 10.2 PID control Setting TO-DB parameter Data Value range Description type Selection "Config.Output.Cool.Select" 2 >= Config.Output. Selects which kind of Output (Enu Heat.Select output to use for cooling. (cooling) >= 0 Possible selections: “OutputCool” (Real) • “OutputCool_PWM” • (Bool) (=default) “OutputCool_PER •...
Page 630
Technology instructions 10.2 PID control Cascade parameters The following parameters enable you to select controllers as masters or slaves and to determine the number of slave controllers that receive their setpoint directly from the master controller: Setting TO-DB parameter Data Value range Description type...
Page 631
Technology instructions 10.2 PID control Setting TO-DB parameter Data Value range Description type Number "Config.Cascade.CountSlaves" 255 >= Con- Number of slave control- of slaves fig.Cascade. lers that get their set- CountSlaves point directly from this >= 1 master controller. The PID_Temp instruction processes this value, along with others, for...
Page 632
Technology instructions 10.2 PID control Example: Cascading controllers In the “Basic settings” dialog below, you see the “Input / output parameters” section and the “Cascade” section for slave controller "PID_Temp_2" after selecting "PID_Temp_1" as master. You make the connections between master and slave controller: Network 1: In these networks, you make the connection between the "PID_Temp_1"...
Page 633
Technology instructions 10.2 PID control Network 2: You make the connection between the "PID_Temp_1" master’s “OutputHeat” and "Slave" parameters to the "PID_Temp_2" slave’s “Setpoint” and "Master" parameters, respectively: S7-1200 Programmable controller System Manual, V4.2, 09/2016, A5E02486680-AK...
Page 634
Technology instructions 10.2 PID control Autotuning of temperature processes The PID_Temp instruction provides two modes for auto tuning: ● “Pretuning” (parameter “Mode” = 1) ● “Finetuning” (parameter “Mode” = 2) Depending on the controller configuration, different variants of these tuning methods are available: Configuration Controller with heating...
Page 635
Technology instructions 10.2 PID control Output value limits and scaling Cooling activation disabled If you configure the PID_Temp instruction as master for a cascade “Activate output (cooling)” checkbox in “Basic settings” view is unchecked and disabled, all settings in the “Output settings”...
Page 636
Technology instructions 10.2 PID control Cooling activation enabled The figure below shows the ”Output value limits and scaling” section in “Output settings” view with cooling activated (OutputCool_PER and OutputHeat_PWM selected in “Input / output parameters” view; OutputCool and OutputHeat always enabled): S7-1200 Programmable controller System Manual, V4.2, 09/2016, A5E02486680-AK...
Page 637
Technology instructions 10.2 PID control S7-1200 Programmable controller System Manual, V4.2, 09/2016, A5E02486680-AK...
Page 638
Technology instructions 10.2 PID control Operation modes To change the mode of operation manually, the user needs to set the “Mode” in-out parameter of the controller and activate it by setting “ModeActivate” from FALSE to TRUE (rising edge triggered). You must reset “ModeActivate” before the next mode change; it does not reset automatically.
Page 639
Technology instructions 10.2 PID control "Mode" / Name Description "State" Manual mode In this mode, the PID controller scales, limits, and transfers the value of parameter “Man- ualValue” to the outputs. The PID controller assigns “ManualValue” in the scaling of the PID-algorithm (like“PidOutputSum”), so its value decides if it is effective at the heating or cooling out- puts.
Technology instructions 10.2 PID control 10.2.7 Commissioning the PID_Compact and PID_3Step controllers Use the commissioning editor to configure the PID controller for autotuning at startup and for autotuning during operation. To open the commissioning editor, click the icon on either the instruction or the project navigator. Table 10- 33 Sample commissioning screen (PID_3Step) Measurement: To display the setpoint, the pro- •...
Page 641
Technology instructions 10.2 PID control PID start value control You can edit the actual values of the PID configuration parameters so that the behavior of the PID controller can be optimized in online mode. Open the "Technology objects" for your PID controller and its "Configuration" object. To access the start value control, click the "eyeglasses icon"...
Technology instructions 10.2 PID control Additionally, click the parameter button with the downward arrow to open a small window that shows the project (offline) start value and the PLC (online) start value of each parameter: 10.2.8 Commissioning the PID_Temp controller Use the commissioning editor to configure the PID controller for autotuning at startup and for autotuning during operation.
Page 643
Technology instructions 10.2 PID control PWM limits Actuators that are controlled with the software PWM function of the PID_Temp may need to be protected from too short pulse durations (for example, a thyristor relay needs to be turned on for more than 20 ms before it can react at all); you assign a minimum on time. The actuator can also neglect short impulses and therefore corrupt the control quality.
Page 644
Technology instructions 10.2 PID control Setting TO-DB parameter Data Value range Description type Minimum "Config.Output.Cool. Real 100000.0 A pulse at Out- MinimumOnTime" >= Config.Output. putCool_PWM is nev- Cool. er shorter than this time (cool- MinimumOnTime value. ing) 1,3,4 >= 0.0 Minimum "Config.Output.Cool.
Page 645
Technology instructions 10.2 PID control PID parameters The “Advanced settings” view, "PID Parameters” section is shown below with the cooling and/or “PID parameterswitchover” feature deactivated. Setting TO-DB parameter Data Value range Description type Enable "Retain.CtrlParams. Bool Bool You must check this SetByUser"...
Page 646
Technology instructions 10.2 PID control Setting TO-DB parameter Data Value range Description type Sampling "Retain.CtrlParams. Real 100000.0 Internal call cycle of the time of PID Heat.Cycle" >=Cycle PID controller for heat- algorithm > 0.0 ing. (heating) Rounded to an integer multiple of the FB call cycle time.
Page 647
Technology instructions 10.2 PID control Setting TO-DB parameter Data Value range Description type Controller "PIDSelfTune.SUT. "PIDSelf- You can select the structure TuneRuleHeat", Tune.SUT. tuning algorithm for (heating) TuneRuleHeat" heating. "PIDSelfTune.TIR. = 0..2, TuneRuleHeat" Possible selections: "PIDSelf- PID (Temperature) • Tune.TIR. (=default) TuneRuleHeat"...
Page 648
Technology instructions 10.2 PID control Setting TO-DB parameter Data Value range Description type Proportional "Retain.CtrlParams. Real 1.0 >=PWeighting Weighting of the PID action Cool.PWeighting" >= 0.0 proportional gain for weighting cooling in either the (cooling) direct- or loopback- control path. Derivative Retain.CtrlParams.
Page 649
Technology instructions 10.2 PID control Setting TO-DB parameter Data Value range Description type Control "Retain.CtrlParams. Real ControlZone> 0.0 Width of the control Zone (cool- Cool.ControlZone" deviation zone for cool- ing) ing where PID control is active. If control devia- tion leaves this range, output is switched to maximum output val- ues.
Page 650
Technology instructions 10.2 PID control Setting TO-DB parameter Data Value range Description type Controller "PIDSelfTune.SUT. "PIDSelf- You can select the structure TuneRuleCool", Tune.SUT. tuning algorithm for (cooling) TuneRuleHeat" cooling. "PIDSelfTune.TIR. = 0..2, TuneRuleCool" Possible selections: "PIDSelf- PID (Temperature) • Tune.TIR. (=default) TuneRuleHeat"...
Page 651
Technology instructions 10.2 PID control Setting TO-DB parameter Data Value range Description type The field displays "s" (seconds) as the time units. Only available if you check "Enable manual entry” in PID parameters ("Re- tain.CtrlParams.SetByUser" = TRUE). Unit of measurement is displayed at the end of the field as selected in “Basic settings” view. Only available if you check/select the following items: "Enable manual entry”...
Page 652
Technology instructions 10.2 PID control The figure above shows the PID parameter screen with compare icons showing which values are different between online and offline projects. A green icon indicates that the values are the same; a blue/orange icon indicates that the values are different. Additionally, click the parameter button with the downward arrow to open a small window that shows the project (offline) start value and the PLC (online) start value of each parameter:...
Technology instructions 10.3 Motion control 10.3 Motion control The CPU provides motion control functionality for the operation of stepper motors and servo motors with pulse interface. The motion control functionality takes over the control and monitoring of the drives. ● The "Axis" technology object configures the mechanical drive data, drive interface, dynamic parameters, and other drive properties.
Page 654
Technology instructions 10.3 Motion control 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. Note Pulse-train outputs cannot be used by other instructions in the user program When you configure the outputs of the CPU or signal board as pulse generators (for use with...
Page 655
Technology instructions 10.3 Motion control Table 10- 36 CPU output: maximum frequency CPU output channel Pulse and direction A/B, quadrature, up/down, output and pulse/direction 1211C Qa.0 to Qa.3 100 kHz 100 kHz 1212C Qa.0 to Qa.3 100 kHz 100 kHz Qa.4, Qa.5 20 kHz 20 kHz...
Page 656
Technology instructions 10.3 Motion control Example: CPU 1217C pulse output speed configurations Note The CPU 1217C can generate pulse outputs up to 1 MHz, using the onboard differential outputs. The examples below show four possible output speed combinations: ● Example 1: 4 - 1 MHz PTOs, no direction output ●...
Page 657
Technology instructions 10.3 Motion control Example: CPU 1211C, CPU 1212C, CPU 1214C, and CPU 1215C pulse output speed configurations The examples below show four possible output speed combinations: ● Example 1: 4 - 100 kHz PTOs, no direction output ● Example 2: 2 - 100 kHz PTOs and 2 - 20 kHz PTOs, all with direction output ●...
Technology instructions 10.3 Motion control Note SIMATIC STEP 7 S7-1200 Motion Control V14 Function Manual Refer to the for further information. 10.3.1 Phasing You have four options for the "Phasing" interface to the stepper/servo drive. These options are as follows: ●...
Page 659
Technology instructions 10.3 Motion control ● PTO (A/B phase-shifted): If you select a PTO (A/B phase-shifted) option, then both outputs pulse at the speed specified, but 90 degrees out-of-phase. It is a 1X configuration, meaning one pulse is the amount of time between positive transitions of P0.
Page 660
Technology instructions 10.3 Motion control ● PTO (pulse and direction (direction de-selected)): If you de-select the direction output in a PTO (pulse and direction (direction de-selected)), then output (P0) controls the pulsing. Output P1 is not used and is available for other program uses. Only positive motion commands are accepted by the CPU in this mode.
Technology instructions 10.3 Motion control 10.3.2 Configuring a pulse generator 1. Add a Technology object: – In the Project tree, expand the node "Technology Objects" and select "Add new object". – Select the "Axis" icon (rename if required) and click "OK" to open the configuration editor for the axis object.
Technology instructions 10.3 Motion control Note The CPU calculates motion tasks in "slices" or segments of 10 ms. As one slice is being executed, the next slice is waiting in the queue to be executed. If you interrupt the motion task on an axis (by executing another new motion task for that axis), the new motion task cannot be executed for a maximum of 20 ms (the remainder of the current slice plus the queued slice).
Page 663
Technology instructions 10.3 Motion control Table 10- 39 STEP 7 tools for motion control Tool Description Configuration Configures the following properties of the "Axis" technology object: Selection of the PTO to be used and configuration of the drive interface • Properties of the mechanics and the transmission ratio of the drive (or machine or system) •...
Page 664
Technology instructions 10.3 Motion control The tree selector for the PTO axis does not include the Encoder, Modulo, Position monitoring, and Control loop configuration menus. After you create the technology object for the axis, you configure the axis by defining the basic pa- rameters, such as the PTO and the configuration of the drive interface.
Page 665
Technology instructions 10.3 Motion control Configure the properties for the drive signals, drive mechanics, and position monitoring (hardware and software limit switches). You configure the motion dynamics and the behav- ior of the emergency stop command. You also configure the homing behavior (passive and active). Use the "Commissioning"...
Technology instructions 10.3 Motion control 10.3.3.2 Commissioning "Status and error bits" diagnostic function Use the "Status and error bits" diagnostic function to monitor the most important status and error messages for the axis. The diagnostic function display is available in online mode in "Manual control"...
Page 667
Technology instructions 10.3 Motion control Table 10- 42 Status of the axis motion Status Description Standstill The axis is at a standstill. (Tag of technology object: <Axis name>.StatusBits.StandStill) Accelerating The axis accelerates. (Tag of technology object: <Axis name>.StatusBits.Acceleration) Constant velocity The axis travels at constant velocity.
Page 668
Technology instructions 10.3 Motion control Error Description Configuration error The "Axis" technology object was incorrectly configured or editable configuration data were modified incorrectly during runtime of the user program. (Tag of technology object: <Axis name>.ErrorBits.ConfigFault) General Error An internal error has occurred. (Tag of technology object: <Axis name>.ErrorBits.SystemFault) "Motion status"...
Page 669
Technology instructions 10.3 Motion control Motion start value control You can edit the actual values of the Motion configuration parameters so that the behavior of the process can be optimized in online mode. Open the "Technology objects" for your motion control and its "Configuration" object. To access the start value control, click the "eyeglasses icon"...
Page 670
Technology instructions 10.3 Motion control You can now change the value of any of your motion control configuration parameters as shown in the figure below. You can compare the actual value to the project (offline) start value and the PLC (online) start value of each parameter.
Page 671
Technology instructions 10.3 Motion control Additionally, click the parameter button with the downward arrow to open a small window that shows the project (offline) start value and the PLC (online) start value of each parameter. S7-1200 Programmable controller System Manual, V4.2, 09/2016, A5E02486680-AK...
Technology instructions 10.3 Motion control 10.3.4 Closed loop motion control 10.3.4.1 Configuring the axis You connect the closed loop axis on the PLC and the drive through one of two connections: ● Analog drive: This connection can use onboard, SB, or signal module (SM) analog I/O; it does not use PTOs.
Page 673
Technology instructions 10.3 Motion control Table 10- 47 STEP 7 tools for closed loop motion control Tool Description Configuration Configures the following properties of the "Axis" technology object: Selection of the analog drive connection or PROFIdrive to be used and configuration of the •...
Page 674
Technology instructions 10.3 Motion control After you create the technology object for the axis, you configure the axis by defining the basic parameters, either the Analog drive or the PROFIdrive connection and the configuration of the drive and encoder. The tree selector for the analog drive or PROFIdrive connection includes the Encoder, Modulo, Position monitoring, and Control loop con- figuration menus.
Page 675
Technology instructions 10.3 Motion control Analog drive connection configuration In the General configuration dialog, you select the following parameters: • "Analog drive connection" radio button • Unit of measurement In the Drive configuration dialog, you select the following parameters: • Analog drive hardware outputs •...
Page 676
Technology instructions 10.3 Motion control PROFIdrive configuration In the General configuration dialog, you select the following parameters: • "PROFIdrive" radio button • Unit of measurement In the Drive configuration dialog, you select the following parameters: • PROFIdrive drive • Data exchange with the drive Note: The Maximum speed must be greater than or equal to the Reference (nominal) speed.
Page 677
Technology instructions 10.3 Motion control Extended parameters You can also configure the following properties of the closed loop axis: ● Modulo ● Position limits ● Dynamics ● Homing ● Position monitoring ● Following error ● Standstill signal ● Control loop Modulo: You can configure a "Modulo"...
Page 678
Technology instructions 10.3 Motion control Homing: You can configure the homing behavior (passive and active). "Positioning monitoring": You can configure tolerance time as well as minimum dwell time for the positioning window. The system connects the following three parameters directly with the axis TO-DB: •...
"MC-Servo (OB 91)" for processing the technology objects. The motion control functionality of the technology objects creates its own priority class, and the SIMATIC S7-1200 execution system calls the OB according to the application cycle. The MC-Servo OB is write-protected. You cannot change the contents.
Page 680
Technology instructions 10.3 Motion control The MC-PreServo OB and MC-PostServo OB are instances of the ServoOB, and they are of type ServoOB. These OBs are optional, can only exist if MC-Servo OB is present, and contain user code. All three OBs (MC-PreServo, MC-Servo, and MC-PostServo) have to run in the same runtime level, and the same CyclicServoEvent triggers them.
Technology instructions 10.3 Motion control Overflow MC-Servo (OB 91) The selected application cycle must be long enough to allow all the technology objects for motion control to be processed in one cycle. If the application cycle is not observed, overflows occur. The CPU does not go into STOP at overflow of the MC-Servo (OB 91).
Page 682
Technology instructions 10.3 Motion control MC_Power With the MC_Power instruction, you can enable the axis with the "speed controlled" mode. You can do this if no valid sensor values are available or the axis cannot change to "position controlled" mode. You can only use StartModes "0"...
Page 683
Technology instructions 10.3 Motion control Other motion commands The speed controlled mode remains active until one of the following commands becomes active: ● MC_MoveAbsolute ● MC_MoveRelative ● MC_MoveVelocity (PositionControlled = TRUE) ● MC_MoveJog (PositionControlled = TRUE) ● MC_Home: – Active homing (Mode 3) –...
Technology instructions 10.3 Motion control 10.3.4.4 Telegram 4 support The PROFdrive Telegram 4 contains actor values and two values from different encoders. The first sensor value comes from the encoder on the motor. The second sensor value is provided by an additional encoder on the machine. The machine encoder is connected directly to a SINAMICS CU, and the CU provides both sensor values within the Telegram 4.
Page 685
Use the hardware catalog to add a SINAMICS S120 CU310-2 PN V4.7 drive. To do so, expand the following containers: – Other field devices – PROFINET IO – Drives – SIEMENS AG – SINAMICS Insert the drive as shown in the figures below: Configure your PROFINET network. 2. Selecting the DO SERVO: –...
Page 686
Technology instructions 10.3 Motion control 3. Selecting the Telegram 4: – In the hardware catalog, expand the Submodules container. – Double-click or drag the "Standard telegram 4, PZD-6/15;SERVO" to insert it in the second blank row. – You must skip a blank row to insert the Telegram 4, as shown in the figure below: S7-1200 Programmable controller System Manual, V4.2, 09/2016, A5E02486680-AK...
Page 687
Technology instructions 10.3 Motion control 4. Selecting the encoder in the Drive configuration dialog: – Navigate to the axis configuration dialog, and the Basic parameters, Drive configuration dialog. – Move to the Select PROFIdrive drive, Drive: field. – Click the ellipsis button. –...
Page 688
Technology instructions 10.3 Motion control 5. Configuring the encoder: – Since you selected Telegram 4 in the axis Drive configuration dialog, the Encoder drive configuration dialog provides a new "Encoder in telegram" entry in the navigation tree. When you select the "Encoder in telegram" entry, the right pane displays two entries, Encoder 1 and Encoder 2, with encoder values.
Technology instructions 10.3 Motion control 10.3.4.5 Simulation axis You use Simulation Mode when you want to work with the PROFIdrive or the Analog drive axis on a PLC without a connected drive. Simulation Mode is required when you want to do one of the following tasks: ●...
Page 690
Technology instructions 10.3 Motion control Mode 1: "Simulate drive and encoder": ● In this mode, the axis in your program executes and works on a PLC without real connected hardware regarding a PROFIdrive drive and sensor. ● You do not require the logical I/O addresses in the Technology Objects data block (TODB).
Technology instructions 10.3 Motion control 10.3.4.6 Data adaptation Overview You can adapt actor and sensor data that are readable from the drive or sensor module and have been configured the same in both the PLC and the drive/sensor device. Configuring Adaptation RT The CPU configures the Adaptation RT in the TO-DB for the specific actor and sensor: ●...
Page 692
Technology instructions 10.3 Motion control ● If a SINAMICS drive is connected: – The check box is selected by default. – The controls following the check box, "Reference speed’ and "Maximum speed", are grayed out. – Adaptation RT for actor data is activated. –...
Page 693
Technology instructions 10.3 Motion control The following figure shows the axis configuration Encoder dialog: S7-1200 Programmable controller System Manual, V4.2, 09/2016, A5E02486680-AK...
Page 694
Technology instructions 10.3 Motion control ● If a PROFIdrive encoder is connected: – The check box is selected by default. – The controls following the check box, "Encoder type" ("Steps per revolution" only) and "Fine resolution", are grayed out. – Adaptation RT for encoder data is activated. –...
Page 695
Technology instructions 10.3 Motion control Displaying adaptation status and adaption errors Motion control displays the Adaptation RT status and errors in parameters and ErrorIDs/ErrorInfos: ● Motion control displays the adaptation status at the axis: If the adaptation does not operate or operates with errors, motion control displays an error at the axis and the ErrorID / ErrorInfo of the MC_Power instruction.
Page 696
Technology instructions 10.3 Motion control Selected current data record from the drive A SINAMICS drive supports different data sets for the encoder and actor. The SINAMICS drive adapts the current data record at the moment of adaptation. Therefore, "p51" (current data record of drive) is readout: ●...
Page 697
Technology instructions 10.3 Motion control The values of each parameter are listed in the following tables: TO-DB actor parameter Value Actor.type 0 = Analog • 1 = PROFIdrive • 2 = PTO • Note: The TIA Portal only supports the rotary drive.
Page 698
Technology instructions 10.3 Motion control Consistency check Motion control executes a consistency check during the first startup or restart of the TO axis. Motion control also displays an ErrorID if the data adaptation of the actor is activated. A consistency check involves the telegram, motor type, and maximum speed: ●...
Page 699
Technology instructions 10.3 Motion control Parameters Motion control adapts the following prarmeters: TO-DB sensor parameter SINAMICS/PROFIdrive parameter Sensor[i].System P979.[1] or P979.[11] • Bit 0 = 0: rotary encoder • Bit 0 = 1: linear encoder • Incremental rotary sensor Sensor[i].Parameter.StepsPerRevolution P979.[2] or P979.[12] Sensor[i].Parameter.FineResolutionXist1 P979.[3] or P979.[13]...
Page 700
Technology instructions 10.3 Motion control Consistency check Motion control executes a consistency check during the first startup or restart of the TO axis. Motion control also displays an ErrorID if the data adaptation of the sensor is activated. A consistency check involves the telegram and sensor type: ●...
Page 701
Technology instructions 10.3 Motion control Sensor Type Default Changeable Comment Sen- DINT R (with restart) Adaptation acti- sor.DataAdaptation vate: 0: NO • 1: YES • StatusSensor Type Comment StatusSensor.AdaptationState DINT Adaptation status: 0: NOT_ADAPTED: Cannot take • over data. 1: IN_ADAPTATION: Data adapta- •...
Technology instructions 10.3 Motion control 10.3.4.7 Axis control using the TM Pulse module The TM Pulse Module is an ET 200SP two-channel pulse output module for use with valves and motors. The module can support either two 24 V DC channels at 2 A or one 24 V DC channel at 4 A.
Page 703
Technology instructions 10.3 Motion control Follow these steps to configure the TM Pulse module: 1. Configure your S7-1200 CPU. 2. Select the required ET 200SP Interface module and place it in the Device View: 3. Add the ET 200SP TM Pulse module: 4.
Page 704
Technology instructions 10.3 Motion control Follow these steps to configure the Axis of Motion with position feedback: 1. When configuring your interface with a Closed Loop Motion Control System, you use analog control, not PROFIdrive or PTO. You configure the axis to be controlled in the same way that you configure an axis that uses an analog output as the input to a servo drive.
Page 705
Technology instructions 10.3 Motion control 2. In the General configuration dialog for the axis configuration, select "Analog drive connection": S7-1200 Programmable controller System Manual, V4.2, 09/2016, A5E02486680-AK...
Page 706
Technology instructions 10.3 Motion control 3. You now need analog outputs and a drive enable for your drive configuration. Go to the Device View of the ET 200SP interface module and the Device Overview entry for the TM Pulse module. Using the starting Q address for the TM Pulse module and the Control SIMATIC ET 200SP Technology module interface and Feedback interface tables in the TM Pulse 2x24V (6ES7138-6DB00-0BB1) Manual...
Page 707
Technology instructions 10.3 Motion control 4. In the Encoder configuration dialog for the axis configuration, complete the configuration by selecting one of the following encoders: ● TM Count module ● TM Pulse module ● High-Speed Counter (HSC) S7-1200 Programmable controller System Manual, V4.2, 09/2016, A5E02486680-AK...
Technology instructions 10.3 Motion control 10.3.5 Configuring the TO_CommandTable_PTO You can configure a MC_CommandTable instruction using the Technology objects. The following example demonstrates how this is done. Adding a Technology object 1. In the Project tree, expand the node "Technology Objects" and select "Add new object". 2.
Page 709
Technology instructions 10.3 Motion control Planning the steps for your application You can create the desired movement sequence in the "Command Table" configuration window, and check the result against the graphic view in the trend diagram. You can select the command types that are to be used for processing the command table. Up to 32 steps can be entered.
Page 710
Technology instructions 10.3 Motion control In the figure below, "Blending motion" is used as the transition to the next step. This type of transition allows your device to maintain its velocity into the start of the next step, resulting in a smooth transition for the device from one step to the next.
Technology instructions 10.3 Motion control 10.3.6 Operation of motion control for S7-1200 10.3.6.1 CPU outputs used for motion control The CPU provides four pulse output generators. Each pulse output generator provides one pulse output and one direction output for controlling a stepper motor drive or a servo motor drive with pulse interface.
Page 712
Technology instructions 10.3 Motion control Table 10- 49 Default address assignments of the pulse and direction outputs Usage of outputs for motion control Pulse Direction PTO1 Built-in I/O Q0.0 Q0.1 SB I/O Q4.0 Q4.1 PTO2 Built-in I/O Q0.2 Q0.3 SB I/O Q4.2 Q4.3 PTO3...
Technology instructions 10.3 Motion control 10.3.6.2 Hardware and software limit switches for motion control Use the hardware and software limit switches to limit the "allowed travel range" and the "working range" of your axis. ① Mechanical stop Allowed travel range for the axis ②...
Page 714
Technology instructions 10.3 Motion control When the hardware limit switches are approached, the axis brakes to a standstill at the configured emergency deceleration. The specified emergency deceleration must be sufficient to reliably stop the axis before the mechanical stop. The following diagram presents the behavior of the axis after it approaches the hardware limit switches.
Page 715
Technology instructions 10.3 Motion control Software limit switches Software limit switches limit the "working range" of the axis. They must fall inside the hardware limit switches relative to the travel range. Because the positions of the software limit switches can be set flexibly, the working range of the axis can be restricted on an individual basis depending on the current traversing profile.
Page 716
Technology instructions 10.3 Motion control Edge detection configuration on address change If you configure a position limit or input homing switch to an input address in a TO PositionAxis, motion control configures it with edge interrupts automatically. If, then, you change the position limit or input homing switch to another address, the configuration with edge detection for the old address remains active.
Page 717
Technology instructions 10.3 Motion control Example: Changing to a new HW limit switch address with edge detection and deactivating edge detection on the old address 1. Current state: You have connected an "Input low HW limit switch" to I0.2. This configuration automatically enabled edge detection on I0.2.
Page 718
Technology instructions 10.3 Motion control 3. The CPU accepts the new I0.6 address and activates edge detection on the I0.6. The edge detection of I0.2 in the CPU Properties, Digital Inputs is automatically deactivated: S7-1200 Programmable controller System Manual, V4.2, 09/2016, A5E02486680-AK...
Page 719
Technology instructions 10.3 Motion control Example: Changing to a new HW limit switch address with edge detection and maintaining edge detection on the old address 1. Current state: You have connected an "Input low HW limit switch" to I0.2. This configuration automatically enabled edge detection on I0.2.
Page 720
Technology instructions 10.3 Motion control 3. The CPU accepts the new I0.6 address and activates edge detection on the I0.6. The edge detection of I0.2 in the CPU Properties, Digital Inputs is kept activated: S7-1200 Programmable controller System Manual, V4.2, 09/2016, A5E02486680-AK...
Page 721
Technology instructions 10.3 Motion control Example: Canceling change to a new HW limit switch address with edge detection 1. Current state: You have connected an "Input low HW limit switch" to I0.2. This configuration automatically enabled edge detection on I0.2. This configuration is also shown in the CPU Properties, Digital Inputs: 2.
Page 722
Technology instructions 10.3 Motion control 3. The "Input low HW limit switch" remains configured to I0.2 and edge detection on I0.2 remains activated: Additional information Your user program can override the hardware or software position limits by enabling or disabling both hardware and software limits functionality. The selection is made from the Axis DB.
Technology instructions 10.3 Motion control 10.3.6.3 Homing Homing refers to the matching of the axis coordinates to the real, physical drive position. (If the drive is currently at position x, the axis will be adjusted to be in position x.) For position- controlled axes, the entries and displays for the position refer exactly to these axis coordinates.
Page 724
Technology instructions 10.3 Motion control ● Mode 3 - Active Referencing: This mode is the most precise method of Homing the Axis. The initial direction and velocity of movement is configured in the Technology Object Configuration Extended Parameters-Homing. This is dependent upon machine configuration.
Page 725
Technology instructions 10.3 Motion control Table 10- 51 Configuration parameters for homing the axis Parameter Description Input reference point switch Select the digital input for the reference point switch from the drop-down list box. The input must be interrupt-capable. The onboard CPU inputs and inputs of an inserted (Active and passive homing) signal board can be selected as inputs for the reference point switch.
Page 726
Technology instructions 10.3 Motion control Parameter Description Homing velocity Specify the velocity at which the axis approaches the reference point switch for hom- ing. (Active homing only) Limit values (independent of the selected user unit): Start/stop velocity ≤ homing velocity ≤ maximum velocity Home position offset If the desired reference position deviates from the position of the reference point switch, the home position offset can be specified in this field.
Page 727
Technology instructions 10.3 Motion control Example: Selecting the passive reference point switch level 1. You have configured an S7-1200 project with an Analog/PROFIdrive axis using passive homing. Depending on your application, you select "High level" or "Low level" for the passive homing switch level: 2.
Page 728
Technology instructions 10.3 Motion control Example: Selecting the active reference point switch level 1. You have configured an S7-1200 project with an Analog/PROFIdrive axis using active homing. Depending on your application, you select "High level" or "Low level" for the active homing switch level: 2.
Page 729
Technology instructions 10.3 Motion control Sequence for active homing You start active homing with motion control instruction "MC_Home" (input parameter Mode = 3). Input parameter "Position" specifies the absolute reference point coordinates in this case. Alternatively, you can start active homing on the control panel for test purposes. The following diagram shows an example of a characteristic curve for an active reference point approach with the following configuration parameters: ●...
Technology instructions 10.3 Motion control Note If the homing search does not function as you expected, check the inputs assigned to the hardware limits or to the reference point. These inputs may have had their edge interrupts disabled in device configuration. Examine the configuration data for the axis technology object of concern to see which inputs (if any) are assigned for "HW Low Limit Switch Input", "HW High Limit Switch Input", and "Input reference point switch".
Technology instructions 10.3 Motion control 10.3.7 Motion control instructions 10.3.7.1 MC instruction overview The motion control instructions use an associated technology data block and the dedicated PTO (pulse train outputs) of the CPU to control the motion on an axis. ●...
Page 732
Technology instructions 10.3 Motion control CPU firmware levels If you have an S7-1200 CPU with V4.1 or later firmware, select the V5.0 version of each motion instruction. If you have an S7-1200 CPU with V4.0 or earlier firmware, select the applicable V4.0, V3.0, V2.0, or V1.0 version of each motion instruction.
Technology instructions 10.3 Motion control 10.3.7.2 MC_Power (Release/block axis) Note If the axis is switched off due to an error, it will be enabled again automatically after the error has been eliminated and acknowledged. This requires that the Enable input parameter has retained the value TRUE during this process.
Page 734
Technology instructions 10.3 Motion control Table 10- 56 Parameters for the MC_Power instruction Parameter and type Data type Description Axis IN_OUT TO_Axis Axis technology object Enable Bool FALSE (default): All active tasks are aborted according to the pa- • rameterized "StopMode" and the axis is stopped. TRUE: Motion control attempts to enable the axis.
Page 735
Technology instructions 10.3 Motion control ① An axis is enabled and then disabled again. After the drive has signaled "Drive ready" back to the CPU, the suc- cessful enable can be read out via "Status_1". ② Following an axis enable, an error has occurred that caused the axis to be disabled. The error is eliminated and acknowledged with "MC_Reset".
Technology instructions 10.3 Motion control 10.3.7.3 MC_Reset (Confirm error) Table 10- 57 MC_Reset instruction LAD / FBD Description "MC_Reset_DB"( Use the MC_Reset instruction to acknowledge Axis:=_multi_fb_in_, "Operating error with axis stop" and "Configura- Execute:=_bool_in_, tion error". The errors that require acknowl- edgement can be found in the "List of ErrorIDs Restart:=_bool_in_, and ErrorInfos"...
Technology instructions 10.3 Motion control 10.3.7.4 MC_Home (Home axis) Table 10- 59 MC_Home instruction LAD / FBD Description "MC_Home_DB"( Use the MC_Home instruction to match Axis:=_multi_fb_in_, the axis coordinates to the real, physical Execute:=_bool_in_, drive position. Homing is required for absolute positioning of the axis: Position:=_real_in_, Mode:=_int_in_,...
Page 738
Technology instructions 10.3 Motion control Table 10- 60 Parameters for the MC_Home instruction Parameter and type Data type Description Axis IN_OUT TO_Axis Axis technology object Execute Bool Start of the task with a positive edge Position Real Mode = 0, 2, and 3 (Absolute position of axis after comple- •...
Page 739
Technology instructions 10.3 Motion control Parameter and type Data type Description ErrorInfo Word Error info ID for parameter "ErrorID" ReferenceMarkPosition Real Position of the axis at the reference mark in the previous co- ordinate system. "ReferenceMarkPosition" output parameter: The homing function saves the old position before execution and provides this value in the ReferenceMarkPosition output parameter.
Technology instructions 10.3 Motion control Table 10- 61 Override response Mode Description 0 or 1 The MC_Home task cannot be aborted by any other motion control task. The new MC_Home task does not abort any active motion control tasks. Position-related motion tasks are resumed after homing according to the new homing position (value at the Position input parameter).
Page 741
Technology instructions 10.3 Motion control Table 10- 63 Parameters for the MC_Halt instruction Parameter and type Data type Description Axis TO_Axis_1 Axis technology object Execute Bool Start of the task with a positive edge Done Bool TRUE = Zero velocity reached Busy Bool TRUE = The task is being executed.
Technology instructions 10.3 Motion control Override response The MC_Halt task can be aborted by the The new MC_Halt task aborts the following following motion control tasks: active motion control tasks: • MC_Home Mode = 3 • MC_Home Mode = 3 •...
Page 743
Technology instructions 10.3 Motion control Table 10- 65 Parameters for the MC_MoveAbsolute instruction Parameter and type Data type Description Axis TO_Axis_1 Axis technology object Execute Bool Start of the task with a positive edge (Default value: False) Position Real Absolute target position (Default value: 0.0) Limit values: -1.0e ≤...
Page 744
Technology instructions 10.3 Motion control The following values were configured in the "Dynamics > General" configuration window: Acceleration = 10.0 and Decelera- tion = 10.0 ① An axis is moved to absolute position 1000.0 with a MC_MoveAbsolute task. When the axis reaches the target position, this is signaled via "Done_1".
Technology instructions 10.3 Motion control 10.3.7.7 MC_MoveRelative (Position axis relatively) Table 10- 66 MC_MoveRelative instruction LAD / FBD Description "MC_MoveRelative_DB"( Use the MC_MoveRelative instruc- Axis:=_multi_fb_in_, tion to start a positioning motion Execute:=_bool_in_, relative to the start position. Distance:=_real_in_, In order to use the Velocity:=_real_in_, MC_MoveRelative instruction, the Done=>_bool_out_,...
Page 746
Technology instructions 10.3 Motion control The following values were configured in the "Dynamics > General" configuration window: Acceleration = 10.0 and Decelera- tion = 10.0 ① The axis is moved by an MC_MoveRelative task by the distance ("Distance") 1000.0. When the axis reaches the target position, this is signaled via "Done_1".
Technology instructions 10.3 Motion control 10.3.7.8 MC_MoveVelocity (Move axis at predefined velocity) Table 10- 68 MC_MoveVelocity instruction LAD / FBD Description "MC_MoveVelocity_DB"( Use the MC_MoveVelocity instruc- Axis:=_multi_fb_in_, tion to move the axis constantly at Execute:=_bool_in_, the specified velocity. Velocity:=_real_in_, In order to use the Direction:=_int_in_, MC_MoveVelocity instruction, the Current:=_bool_in_,...
Page 748
Technology instructions 10.3 Motion control Parameter and type Data type Description PositionControlled Bool 0: speed controlled • 1: position controlled (Default value: True) • InVelocity Bool TRUE: If "Current" = FALSE: The velocity specified in parameter "Ve- • locity" was reached. If "Current"...
Technology instructions 10.3 Motion control Override response The MC_MoveVelocity task can be aborted The new MC_MoveVelocity task aborts the by the following motion control tasks: following active motion control tasks: • MC_Home Mode = 3 • MC_Home Mode = 3 •...
Page 750
Technology instructions 10.3 Motion control Table 10- 71 Parameters for the MC_MoveJog instruction Parameter and type Data type Description Axis TO_SpeedAxis Axis technology object JogForward Bool As long as the parameter is TRUE, the axis moves in the positive direction at the velocity specified in parameter "Velocity". The sign of the value in parameter "Velocity"...
Technology instructions 10.3 Motion control Override response The MC_MoveJog task can be aborted by The new MC_MoveJog task aborts the the following motion control tasks: following active motion control tasks: • MC_Home Mode = 3 • MC_Home Mode = 3 •...
Page 752
Technology instructions 10.3 Motion control Table 10- 73 Parameters for the MC_CommandTable instruction Parameter and type Data type Initial value Description Axis TO_Axis_1 Axis technology object Table TO_CommandTable_1 Command table technology object Execute Bool FALSE Start job with rising edge StartIndex Start command table processing with this step Limits: 1 ≤...
Page 753
Technology instructions 10.3 Motion control Table 10- 74 MC_CommandTable command types Command type Description Empty The empty serves as a placeholder for any commands to be added. The empty entry is ignored when the command table is processed Halt Pause axis. Note: The command only takes place after a "Velocity setpoint"...
Technology instructions 10.3 Motion control 10.3.7.11 MC_ChangeDynamic (Change dynamc settings for the axis) Table 10- 75 MC_ChangeDynamic instruction LAD / FBD Description "MC_ChangeDynamic_DB"( Changes the dynamic settings of Execute:=_bool_in_, a motion control axis: ChangeRampUp:=_bool_in_, Change the ramp-up time • RampUpTime:=_real_in_, (acceleration) value ChangeRampDown:=_bool_in_, Change the ramp-down time...
Page 755
Technology instructions 10.3 Motion control Table 10- 76 Parameters for the MC_ChangeDynamic instruction Parameter and type Data type Description Axis TO_Axis_1 Axis technology object Execute Bool Start of the command with a positive edge. Default value: FALSE ChangeRampUp Bool TRUE = Change ramp-up time in line with input parameter "RampUpTime".
Technology instructions 10.3 Motion control Note You can only use the MC_ChangeDynamic instruction for a drive connection using PTO (Pulse Train Output). Override response An MC_ChangeDynamic command cannot be aborted by any other motion control command. A new MC_ChangeDynamic command does not abort any active motion control jobs. Note The input parameters "RampUpTime", "RampDownTime", "EmergencyRampTime"...
Page 757
Technology instructions 10.3 Motion control You can write to the parameters that are public. You cannot write to "MotionStatus" and "StatusBits". The valid parameters are listed in the table below: Writeable parameter name Writeable parameter name Actor.InverseDirection DynamicDefaults.Acceleration Actor.DirectionMode DynamicDefaults.Deceleration Actor.DriveParameter.PulsesPerDriveRevolution DynamicDefaults.Jerk Sensor[1].ActiveHoming.Mode...
Technology instructions 10.3 Motion control Table 10- 79 Condition codes for ERRORID and ERRORINFO ERRORID ERRORINFO Description (W#16#...) (W#16#...) Successful change of an Axis TO-DB parameter 8410 0028 Set an invalid parameter (Axis TO-DB parameter with incorrect length) 8410 0029 Set an invalid parameter (no Axis TO-DB parameter) 8410 002B...
Page 759
Technology instructions 10.3 Motion control The MC_ReadParam instruction works on an enable behavior. As long as the input "Enable" is true the instruction reads the specified "Parameter" to the "Value" storage location. The "MotionStatus" "Position" value updates at each Cycle Control Point (CCP) based upon the current HSC value.
Technology instructions 10.3 Motion control 10.3.8 Monitoring active commands 10.3.8.1 Monitoring MC instructions with a "Done" output parameter Motion control instructions with the output parameter "Done" are started by the input parameter "Execute" and have a defined conclusion (for example, with motion control instruction "MC_Home": Homing was successful).
Page 761
Technology instructions 10.3 Motion control The behavior of the status bits is presented below for various example situations. ● The first example shows the behavior of the axis for a completed task. If the motion control task has been completely executed by the time of its conclusion, this is indicated by the value TRUE in output parameter "Done".
Page 762
Technology instructions 10.3 Motion control Table 10- 84 Example 2 - Aborting the task If "Execute" = FALSE after the task is aborted If "Execute" = FALSE before the task is aborted ① The task is started with a positive edge at the input parameter "Execute". Depending on the programming, "Execute" can still be reset to the value FALSE during the task, or the value TRUE can be retained until after completion of the task.
Page 763
Technology instructions 10.3 Motion control Table 10- 85 Example 3 - Error during task execution If "Execute" = FALSE before the error occurs If "Execute" = FALSE after the error occurs ① The task is started with a positive edge at the input parameter "Execute". Depending on the programming, "Execute" can still be reset to the value FALSE during the task, or the value TRUE can be retained until after completion of the task.
Technology instructions 10.3 Motion control 10.3.8.2 Monitoring the MC_Velocity The tasks of the motion control instruction "MC_MoveVelocity" implement a move at the specified velocity: ● The tasks of motion control instruction "MC_MoveVelocity" do not have a defined end. The task objective is fulfilled when the parameterized velocity is reached for the first time and the axis travels at constant velocity.
Page 765
Technology instructions 10.3 Motion control Table 10- 86 Example 1 - If the parameterized velocity is reached If "Execute" = FALSE before the configured velocity is If "Execute" = FALSE after the configured velocity is reached reached ① The task is started with a positive edge at the input parameter "Execute". Depending on the programming, "Execute" can be reset to the value FALSE event before the parameterized velocity is reached, or alternatively only after it has been reached.
Page 766
Technology instructions 10.3 Motion control Table 10- 87 Example 2 - If the task is aborted prior to reaching the parameterized velocity If "Execute" = FALSE before the task is aborted If "Execute" = FALSE after the task is aborted ①...
Page 767
Technology instructions 10.3 Motion control Table 10- 88 Example 3 - If an error occurs prior to reaching the parameterized velocity If "Execute" = FALSE before the error occurs If "Execute" = FALSE after the error occurs ① The task is started with a positive edge at the input parameter "Execute". Depending on the programming, "Execute" can still be reset to the value FALSE during the task, or the value TRUE can be retained until after the error has occurred.
Technology instructions 10.3 Motion control 10.3.8.3 Monitoring the MC_MoveJog The tasks of motion control instruction "MC_MoveJog" implement a jog operation. ● The motion control tasks "MC_MoveJog" do not have a defined end. The task objective is fulfilled when the parameterized velocity is reached for the first time and the axis travels at constant velocity.
Page 769
Technology instructions 10.3 Motion control Table 10- 89 Example 1 - If the parameterized velocity is reached and maintained JogForward JogBackward ① The task is started with a positive edge at the input parameter "JogForward" or "JogBackward". ② While the task is active, the output parameter "Busy" indicates the value TRUE. ③...
Page 770
Technology instructions 10.3 Motion control Table 10- 90 Example 2 - If the task is aborted during execution JogForward JogBackward ① The task is started with a positive edge at the input parameter "JogForward" or "JogBackward". ② While the task is active, the output parameter "Busy" indicates the value TRUE. ③...
Page 771
Technology instructions 10.3 Motion control Table 10- 91 Example 3 - If an error has occurred during task execution JogBackward JogForward ① The task is started with a positive edge at the input parameter "JogForward" or "JogBackward". ② While the task is active, the output parameter "Busy" indicates the value TRUE. ③...
Technology instructions 10.3 Motion control 10.3.9 ErrorIDs and ErrorInfos for motion control The following table lists all ErrorIDs and ErrorInfos that can be indicated in motion control instructions and data adaptation. In addition to the cause of the error, remedies for eliminating the error are also listed.
Page 773
Technology instructions 10.3 Motion control ErrorID ErrorInfo Description Remedy Error reaction 16#8003 Low HW limit switch was reached For drive connec- tion via PTO 16#000E The low HW limit switch was Acknowledge the error for an enabled (Pulse Train Out- reached.
Page 774
Technology instructions 10.3 Motion control ErrorID ErrorInfo Description Remedy Error reaction 16#8008 Invalid direction of motion 16#002E The selected motion direction is not Adjust the motion direction and • allowed. restart the command. 16#002F A reversing motion is not possible Adjust the allowed direction of rota- •...
Page 775
Technology instructions 10.3 Motion control ErrorID ErrorInfo Description Remedy Error reaction 16#800C Alarm message from drive Remove enable. 16#0001 Check the device with regard to func- tion, connections and I/Os. 16#003C PROFIdrive: Drive signal "Control requested" failed 16#003D PROFIdrive: Drive has shut down 16#003E PROFIdrive: Drive at bus failed (sta- tion failure) 16#003F...
Page 776
Technology instructions 10.3 Motion control ErrorID ErrorInfo Description Remedy Error reaction 16#8010 Position of the low SW limit switch is greater than that of the high SW limit Remove enable. switch when the axis is not a modulo axis 16#0001 Change the position of the software limit switches.
Page 777
Technology instructions 10.3 Motion control ErrorID ErrorInfo Description Remedy 16#0052 The specified position exceeds the numerical Enter a valid position value at the motion control limit. instruction. 16#0053 The axis is ramping up. Wait until the axis is ready for operation. 16#0054 Actual value is invalid To execute a "MC_Home"...
Page 778
Technology instructions 10.3 Motion control Block parameter error ErrorID ErrorInfo Description Remedy 16#8400 Invalid value at parameter "Position" of the motion control instruction 16#0002 Value is not a valid number Correct the value; restart the command. 16#0005 Value is outside the number range (greater than 1E+12) 16#0006 Value is outside the number range (less than...
Page 779
Technology instructions 10.3 Motion control ErrorID ErrorInfo Description Remedy 16#8406 Simultaneous forward and backward jogging is not allowed 16#0001 Take steps to ensure that parameters "JogFor- ward" and "JogBackward" do not have signal status TRUE simultaneously; restart the com- mand. 16#8407 Switching to another axis with instruction "MC_Power"...
Page 780
Technology instructions 10.3 Motion control ErrorID ErrorInfo Description Remedy 16#8410 Invalid value at parameter "Parameter" of the motion control instruction 16#0002 Value is not a valid number Correct the value; restart the command. 16#000B Address is invalid Download error-free configuration to the controller; enable the axis again with instruction "MC_Power".
Page 781
Technology instructions 10.3 Motion control ErrorID ErrorInfo Description Remedy 16#8605 Invalid "Distance per revolution" value 16#0002 Value is not a valid number Download error-free configuration to the controller; enable the axis again with instruction 16#0005 Value is outside the number range (greater "MC_Power".
Page 782
Technology instructions 10.3 Motion control ErrorID ErrorInfo Description Remedy 16#8609 Invalid "Deceleration" value 16#0002 Value is not a valid number Download error-free configuration to the con- • troller; enable the axis again with instruction 16#0003 Value is higher than the high hardware limit "MC_Power".
Page 783
Technology instructions 10.3 Motion control ErrorID ErrorInfo Description Remedy 16#860C Value for position of the high SW limit switch is invalid 16#0002 Value is not a valid number Download error-free configuration to the con- • troller; enable the axis again with instruction 16#0005 Value is outside the number range (greater than 1E+12)
Page 784
Technology instructions 10.3 Motion control ErrorID ErrorInfo Description Remedy 16#8610 Invalid "approach velocity" value 16#0002 Value is not a valid number Download error-free configuration to the con- • troller; enable the axis again with instruction 16#0008 The velocity is greater than the maximum velocity "MC_Power".
Page 785
Technology instructions 10.3 Motion control ErrorID ErrorInfo Description Remedy 16#8614 Invalid "Jerk" value 16#0002 Value is not a valid number Download error-free configuration to the con- • troller; enable the axis again with instruction 16#001F Value is greater than the maximum jerk "MC_Power".
Page 786
Technology instructions 10.3 Motion control ErrorID ErrorInfo Description Remedy 16#8619 Value of tag <Axis name>.Actor.Type is invalid 16#0011 The selection value is invalid Download error-free configuration to the con- • (Valid value: 2 = Connection via pulse inter- troller; enable the axis again with instruction face) "MC_Power".
Page 787
Technology instructions 10.3 Motion control ErrorID ErrorInfo Description Remedy 16#861F The configuration for the resolution of the linear encoder is faulty. Invalid value in <Axis name>.Sensor.Sensor[1].Parameter.Resolution 16#0030 Value has an incorrect number format or is Download error-free configuration to the con- •...
Page 788
Technology instructions 10.3 Motion control ErrorID ErrorInfo Description Remedy 16#8625 Parameter of position monitoring is faulty. Invalid value in <Axis name>.PositioningMonitoring.MinDwellTime 16#0030 Value has an incorrect number format or is Download error-free configuration to the con- • outside the valid number range troller;...
Page 789
Technology instructions 10.3 Motion control ErrorID ErrorInfo Description Remedy 16#862A Parameter of position monitoring is faulty. Invalid value in <Axis name>.PositioningMonitoring.ToleranceTime 16#0030 Value has an incorrect number format or is outside the valid number range Download error-free configuration to the con- •...
Page 790
Technology instructions 10.3 Motion control ErrorID ErrorInfo Description Remedy 16#8630 Invalid value for the configuration date <Axis name>.Actor.DriveParameter.ReferenceSpeed 16#0030 Value has an incorrect number format or is Download error-free configuration to the con- • outside the valid number range troller; enable the axis again with instruction "MC_Power".
Page 791
Technology instructions 10.3 Motion control ErrorID ErrorInfo Description Remedy 16#8636 Controller factor is incorrect. Invalid value of the precontrol factor <Axis name>.PositionControl.Kpc 16#0030 Value has an incorrect number format or is Download error-free configuration to the con- • outside the valid number range troller;...
Page 792
Technology instructions 10.3 Motion control ErrorID ErrorInfo Description Remedy 16#863B Error at encoder 16#0049 Configuration error at device Download error-free configuration to the controller; enable the axis again with instruction "MC_Power". 16#004A The technology needs a smaller servo clock. Internal system error. Check the project for consistency and reload it into the controller.
Page 793
Technology instructions 10.3 Motion control Data adaptation errors ErrorID ErrorInfo Description Remedy Error reaction 16#8640 Errors when adapting actuator configuration 16#0030 Value has the wrong numerical for- Restart Adaptation Error mat or is outside the valid number range. 16#0059 The device is not assigned to any Restart Adaptation Error SINAMICS drive unit or does not...
Page 794
Technology instructions 10.3 Motion control ErrorID ErrorInfo Description Remedy Error reaction 16#8041 Errors when adapting the encoder configuration 16#0030 Value has the wrong numerical for- Restart Adaptation Error mat or is outside the valid number range. 16#005A Adaptation was cancelled because of Restart Adaptation Error a lack of resources.
Page 795
Technology instructions 10.3 Motion control ErrorID ErrorInfo Description Remedy Error reaction 16#8642 Configuration is adapted internally 16#0067 1: Impermissible value for Ac- Reset Configuration tor.MaxSpeed (Actor.MaxSpeed error larger than 2*Actor.ReferenceSpeed); Remedy: in drive, set P2000 = P1082 for example. 16#8643 Inconsistency between TO and drive configuration 16#0068 The configured telegram type is not Reset...
Page 796
Technology instructions 10.3 Motion control Configuration error of the command table ErrorID ErrorInfo Description Remedy 16#8700 Value for "Command type" in the command table is invalid 16#0001 Download error-free configuration to the con- • troller; enable the axis again with instruction "MC_Power".
Page 797
Technology instructions 10.3 Motion control Internal errors ErrorID ErrorInfo Description Remedy 16#8FFF Internal error 16#F0** POWER OFF and POWER ON the CPU If this does not work, contact Customer Support. Have the following information ready: ErrorID • ErrorInfo • Diagnostic buffer entries •...
Page 798
Technology instructions 10.3 Motion control S7-1200 Programmable controller System Manual, V4.2, 09/2016, A5E02486680-AK...
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: ●...
Page 800
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.
Communication 11.1 Asynchronous communication connections 11.1 Asynchronous communication connections Overview of communication services The CPU supports the following communication services: Communication ser- Functionality Using PROFIBUS DP Using vice Ethernet CM 1243-5 CM 1242-5 DP master DP slave module module PG communication Commissioning, testing, diagnos- tics HMI communication...
Page 802
Communication 11.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"...
Page 803
Communication 11.1 Asynchronous communication connections This is only an example. The actual number of connections used can vary by HMI type and version. Example HMI 1 HMI 2 HMI 3 HMI 4 HMI 5 Total con- nection resources available Connection resources used Note...
11.2 PROFINET The CPU can communicate with other CPUs, with programming devices, with HMI devices, and with non-Siemens devices using standard TCP communications protocols. Programming device connected to the HMI connected to the CPU A CPU connected to another CPU S7-1200 Programmable controller System Manual, V4.2, 09/2016, A5E02486680-AK...
Page 805
Communication 11.2 PROFINET Ethernet switching The CPU 1211C, 1212C, and 1214C have a single Ethernet port and do not include a integrated Ethernet Switch. A direct connection between a programming device or HMI and a CPU does not require an Ethernet switch. However, a network with more than two CPUs or HMI devices requires an Ethernet switch.
Communication 11.2 PROFINET 11.2.1 Creating a network connection Use the "Network view" of Device configuration to create the network connections between the devices in your project. After creating the network connection, use the "Properties" tab of the inspector window to configure the parameters of the network. Table 11- 1 Creating a network connection Action...
Communication 11.2 PROFINET 11.2.2 Configuring the Local/Partner connection path A Local / Partner (remote) connection defines a logical assignment of two communication partners to establish communication services. A connection defines the following: ● Communication partners involved (One active, one passive) ●...
Page 808
Communication 11.2 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"...
Page 809
Communication 11.2 PROFINET Table 11- 4 Parameters for the multiple CPU connection 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 S7 communication only Interface type : Type of interface...
Enabling the Web server allows authorized users to perform operating mode changes, writes to PLC data, and firmware updates, Siemens recommends that you observe the following security practices: • Enable access to the Web server only with the HTTPS protocol.
Page 811
Communication 11.2 PROFINET Assigning or checking the IP address of your programming device using "My Network Places" (on your desktop) If you are using Windows 7, you can assign or check your programming device's IP address with the following menu selections: ●...
Communication 11.2 PROFINET 11.2.3.2 Checking the IP address of your programming device You can check the MAC and IP addresses of your programming device with the following menu selections: 1. In the "Project tree", expand "Online access". 2. Right-click the required network, and select "Properties". 3.
Communication 11.2 PROFINET 11.2.3.3 Assigning an IP address to a CPU online You can assign an IP address to a network device online. This is particularly useful in an initial device configuration. 1. In the "Project tree," verify that no IP address is assigned to the CPU, with the following menu selections: •...
Communication 11.2 PROFINET 4. In the "IP address" field, enter your new IP address, and click the "Assign IP address" button. 5. In the "Project tree," verify that your new IP address has been assigned to the CPU, with the following menu selections: •...
Page 815
Communication 11.2 PROFINET Configuring the IP address Ethernet (MAC) address: In a PROFINET network, each device is assigned a Media Access Control address (MAC address) by the manufacturer for identification. A MAC address consists of six groups of two hexadecimal digits, separated by hyphens (-) or colons (:), in transmission order, (for example, 01-23-45-67-89-AB or 01:23:45:67:89:AB).
Page 816
Communication 11.2 PROFINET Table 11- 5 Parameters for the IP address 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"...
Page 817
Communication 11.2 PROFINET WARNING Condition in which PROFINET network might stop When changing the IP address of a CPU online or from the user program, it is possible to create a condition in which the PROFINET network might stop. If the IP address of a CPU is changed to an IP address outside the subnet, the PROFINET network will lose communication, and all data exchange will stop.
Page 818
Communication 11.2 PROFINET 3. Monitor: When you select this check box, a message is placed in the diagnostic buffer if any of the following occur at the port: – A link cannot be established at the port – An established link fails –...
Communication 11.2 PROFINET 11.2.4 Testing the PROFINET network After completing the configuration, download the project (Page 216) to the CPU. All IP addresses are configured when you download the project. Assigning an IP address to a device online The S7-1200 CPU does not have a pre-configured IP address. You must manually assign an IP address for the CPU: ●...
Communication 11.2 PROFINET Using the "Extended download to device" dialog to test for connected network devices The S7-1200 CPU "Download to device" function and its "Extended download to device" dialog can show all accessible network devices and whether or not unique IP addresses have been assigned to all devices.
Page 821
Communication 11.2 PROFINET The MAC address is printed on the front, lower-left corner of the CPU. Note that you have to lift the lower door to see the MAC address information. ① MAC address Initially, the CPU has no IP address, only a factory-installed MAC address. PROFINET communications requires that all devices be assigned a unique IP address.
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. The Network Time Protocol (NTP) is widely used to synchronize the clocks of computer systems to Internet time servers. In NTP mode, the CPU sends time-of-day queries at regular intervals (in the client mode) to the NTP server in the subnet (LAN).
Page 823
Communication 11.2 PROFINET In the Properties window, select the "Time synchronization" configuration entry. STEP 7 displays the Time synchronization configuration dialog: Note All IP addresses are configured when you download the project. Table 11- 6 Parameters for time synchronization Parameter Definition Enable time synchronization via NTP Select the checkbox to enable time synchronization via NTP...
Communication 11.2 PROFINET 11.2.7 PROFINET device start-up time, naming, and address assignment PROFINET IO can extend the start-up time for your system (configurable time-out). More devices and slow devices impact the amount of time it takes to switch to RUN. In V4.0 and later, you can have a maximum of 16 PROFINET IO devices on your S7-1200 PROFINET network.
Communication 11.2 PROFINET 11.2.8 Open user communication 11.2.8.1 Protocols The integrated PROFINET port of the CPU supports multiple communications standards over an Ethernet network: ● Transport Control Protocol (TCP) ● ISO on TCP (RFC 1006) ● User Datagram Protocol (UDP) Table 11- 7 Protocols and communication instructions for each Protocol...
Communication 11.2 PROFINET 11.2.8.2 TCP and ISO on TCP Transport Control Protocol (TCP) is a standard protocol described by RFC 793: Transmission Control Protocol. The primary purpose of TCP is to provide reliable, secure connection service between pairs of processes. This protocol has the following features: ●...
Communication 11.2 PROFINET 11.2.8.3 Communication services and used port numbers The S7-1200 CPU supports the protocols listed in the table below. For each protocol, the CPU assigns the address parameters, the respective communications layer as well as the communications role, and the communications direction. This information makes it possible to match the security measures for protection of the automation system to the used protocols (for example, firewall).
Communication 11.2 PROFINET 11.2.8.4 Ad hoc mode Typically, TCP and ISO-on-TCP receive data packets of a specified length, ranging from 1 to 8192 bytes. However, the TRCV_C and TRCV communication instructions also provide an "ad hoc" communications mode that can receive data packets of a variable length from 1 to 1472 bytes.
Page 829
Communication 11.2 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). ●...
Page 830
Communication 11.2 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.
Page 831
Communication 11.2 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 you must use the DB and connection ID that was created by a TSEND_C, TRCV_C or TCON instruction.
Communication 11.2 PROFINET 11.2.8.6 Parameters for the PROFINET connection The TSEND_C, TRCV_C and TCON instructions require connection-related parameters in order to connect to the partner device. The TCON_Param structure assigns these parameters for the TCP, ISO-on-TCP, and UDP protocols. Typically, you use the "Configuration"...
Page 833
Communication 11.2 PROFINET Byte Parameter and data type Description next_staddr_len USInt This parameter is not used. 12 … 27 local_tsap_id Array [1..16] of Local address component of connection: Byte TCP and ISO-on-TCP: local port no. (possible values: 1 to • 49151;...
Page 834
Communication 11.2 PROFINET TCON_IP_V4 Table 11- 9 Structure of the connection description (TCON_IP_V4): For use with TCP Byte Parameter and data type Description 0 … 1 InterfaceId HW_ANY HW-identifier of the IE-interface submodule 2 … 3 CONN_OUC Reference to this connection: Range of values: 1 (default) to 4095. (Word) Specify the value of this parameter for the TSEND_C, TRCV_C, or TCON instruction under ID.
Page 835
Character array for TSAP name Byte Local transport selector 46 ... 47 TSelLength UInt Length of TSelector 48 ... 79 TSel array [1..32] of Character array for TSAP name Byte See also S7-1200 CM/CPs (https://support.industry.siemens.com/cs/us/en/ps) S7-1200 Programmable controller System Manual, V4.2, 09/2016, A5E02486680-AK...
Communication 11.2 PROFINET 11.2.8.7 TSEND_C and TRCV_C instructions As of version V4.1 of the S7-1200 CPU together with STEP 7 V13 SP1, the CPU extends the capability of the TSEND_C and TRCV_C instructions to use connection parameters with structures according to "TCON_IP_v4" and "TCON_IP_RFC". For this reason, the S7-1200 supports two sets of TSEND_C and TRCV_C instructions: ●...
Page 837
Communication 11.2 PROFINET TSEND_C and TRCV_C (Send and receive data using Ethernet) The TSEND_C instruction combines the functions of the TCON, TDISCON and TSEND instructions. The TRCV_C instruction combines the functions of the TCON, TDISCON, and TRCV instructions. (Refer to "TCON, TDISCON, TSEND, AND TRCV (Page 857)" for more information on these instructions.) The minimum size of data that you can transmit (TSEND_C) or receive (TRCV_C) is one byte;...
Page 838
Communication 11.2 PROFINET Table 11- 12 TSEND_C and TRCV_C data types for the parameters Parameter and type Data type Description Bool Starts the send job on a rising edge (TSEND_C) EN_R Bool Receive enable (TRCV_C) CONT Bool Controls the communication connection: 0: Disconnect the communication connection after data is •...
Page 839
Communication 11.2 PROFINET Parameter and type Data type Description COM_RST IN_OUT Bool Optional parameter (hidden) Restarts the instruction: 0: Irrelevant • 1: Completely restarts the instruction; the existing connec- • tion is either terminated or reset and established again in accordance with CONT.
Page 840
Communication 11.2 PROFINET Note The default setting of the LEN parameter (LEN = 0) uses the DATA parameter to determine the length of the data being transmitted. It is recommended that the data transmitted by the TSEND_C instruction be the same size as the DATA parameter of the TRCV_C instruction. If using the default setting of the LEN parameter and it is necessary to send the data in segments smaller than the DATA parameter size, the following applies.
Page 841
Communication 11.2 PROFINET TSEND_C operations The TSEND_C instruction is executed asynchronously and implements the following functions in sequence: 1. Setting up and establishing a communications connection: TSEND_C sets up a communication connection and establishes this connection if a rising edge is detected at the REQ parameter and no communication connection is in place yet. Once the connection has been set up and established, it is automatically maintained and monitored by the CPU.
Page 842
Communication 11.2 PROFINET The following scenarios are possible depending on the CONT parameter: ● CONT = "0": An existing communications connection is established. ● CONT = "1" and a communications connection was established: An existing communications connection is reset and established again. ●...
Page 843
Communication 11.2 PROFINET TRCV_C operations The TRCV_C instruction is executed asynchronously and implements the following functions in sequence: 1. Setting up and establishing a communications connection: TRCV_C sets up a communication connection and establishes this connection if the EN_R parameter = "1" and there is no communication connection. Once the connection has been set up and established, it is automatically maintained and monitored by the CPU.
Page 844
Communication 11.2 PROFINET TRCV_C is reset when the COM_RST parameter is set. If data is being received when it executes again, this can lead to a loss of data. The following scenarios are possible depending on the CONT parameter: ● CONT = "0": An existing communications connection is established.
Page 845
Communication 11.2 PROFINET Note TCP (data receipt with specified length) You use the value of the LEN parameter to specify the length for the data receipt. The data specified at the DATA parameter is available in the receive area as soon as the length specified at the LEN parameter has been completely received.
Page 846
Communication 11.2 PROFINET Error and Status parameters Table 11- 14 TSEND_C and TRCV_C condition codes for ERROR and STATUS ERROR STATUS Description (W#16#...) 0000 Send (TSEND_C) or receive (TRCV_C) job executed without errors. 7000 No active send job execution; no communications connection established. 7001 Start send (TSEND_C) or receive (TRCV_C) job execution.
Page 847
Communication 11.2 PROFINET ERROR STATUS Description (W#16#...) 8085 The LEN parameter is larger than the highest permitted value. • The value at the LEN or DATA parameter was changed after the first call. • 8086 The ID parameter within the CONNECT parameter is outside the permitted range. 8087 Maximum number of connections reached;...
Communication 11.2 PROFINET Note Error messages of the instructions TCON, TSEND, TRCV, and TDISCON Internally, the TSEND_C instruction uses the TCON, TSEND, and TDISCON instructions; and the TRCV_C instruction uses the TCON, TRCV, and TDISCON instructions. Refer to "TCON, TDISCON, TSEND, AND TRCV (Page 857)" for more information on error messages of these instructions.
Page 849
Communication 11.2 PROFINET When you use the instruction tree to place a TSEND_C or TRCV_C instruction in your program, a new FB or FC instance, depending on the TSEND_C or TRCV_C instruction selected, is created in the project tree. You can see new FB or FC instance in the project tree under PLC_x >...
Page 850
Communication 11.2 PROFINET Table 11- 15 TSEND_C and TRCV_C instructions LAD / FBD Description "TSEND_C_DB"( TSEND_C establishes a TCP or ISO on TCP req:=_bool_in_, communication connection to a partner station, cont:=_bool_in_, sends data, and can terminate the connection. After the connection is set up and established, it len:=_uint_in_, is automatically maintained and monitored by done=>_bool_out_,...
Page 851
Communication 11.2 PROFINET Table 11- 16 TSEND_C and TRCV_C data types for the parameters Parameter and type Data type Description Bool REQ = 1 starts the TSEND_C send job on a rising edge with the connection descricribed in CONNECT parameter. (CONT = 1 is (TSEND_C) also required to establish and maintain the communication con- nection.
Page 852
Communication 11.2 PROFINET Note The TSEND_C instruction requires a low-to-high transition at the REQ input parameter to start a send job. The BUSY parameter is then set to 1 during processing. Completion of the send job is indicated by either the DONE or ERROR parameters being set to 1 for one scan. During this time, any low-to-high transition at the REQ input parameter is ignored.
Page 853
Communication 11.2 PROFINET TRCV_C operations The following functions describe the operation of the TRCV_C instruction: ● To establish a connection, execute TRCV_C with parameter CONT = 1. ● To receive data, execute TRCV_C with parameter EN_R = 1. TRCV_C receives the data continuously when parameters EN_R = 1 and CONT = 1.
Page 854
Communication 11.2 PROFINET Note Must keep the data in the sender area consistent until the DONE parameter or the ERROR parameter assumes the value TRUE Due to the asynchronous processing of TSEND_C, you must keep the data in the sender area consistent until the DONE parameter or the ERROR parameter assumes the value TRUE.
Page 855
Communication 11.2 PROFINET ERROR STATUS Description 80A1 Communications error: The specified connection was not yet established • The specified connection is currently being terminated; transmission over this con- • nection is not possible The interface is being reinitialized • 80A3 Attempt being made to terminate a nonexistent connection 80A4 IP address of the remote partner connection is invalid.
Communication 11.2 PROFINET Connection Ethernet protocols Every CPU has an integrated PROFINET port, which supports standard PROFINET communications. The TSEND_C and TRCV_C and TSEND and TRCV instructions all support the TCP and ISO on TCP Ethernet protocols. Refer to "Device Configuration: Configuring the Local/Partner connection path (Page 807)" for more information.
Page 857
Communication 11.2 PROFINET To verify the version of a TCON, TDISCON, TSEND, or TRCV instruction in a program, you must inspect project tree properties and not the properties of a box displayed in the program editor. Select a project tree TCON, TDISCON, TSEND, or TRCV FB or FC instance, right- click, select "Properties", and select the "Information"...
Page 858
Communication 11.2 PROFINET TCON and TDISCON Note Initializing the communication parameters After you insert the TCON instruction, use the "Properties" of the instruction (Page 807) to configure the communication parameters (Page 832). As you enter the parameters for the communication partners in the inspector window, STEP 7 enters the corresponding data in the instance DB for the instruction.
Page 859
Communication 11.2 PROFINET Table 11- 21 Data types for the parameters of TCON and TDISCON Parameter Declaration Data type Description Bool Starts the job to establish the connection specified in the ID upon a rising edge. CONN_OUC (Word) Reference to the assigned connection. Range of values: W#16#0001 to W#16#0FFF CONNECT IN_OUT...
Page 860
Communication 11.2 PROFINET Table 11- 22 ERROR and STATUS condition codes for TCON and TDISCON ERROR STATUS Explanation (W#16#...) 0000 Connection successfully established. 7000 No job processing active 7001 Start job execution; establish connection (TCON) or terminate connection (TDISCON). 7002 Connection is being established (REQ irrelevant);...
Page 861
Communication 11.2 PROFINET ERROR STATUS Explanation (W#16#...) 80B7 TCON: With TCON_IP_v4: TCP (active connection establishment): Remote port is "0". • TCP (passive connection establishment): Local port is "0". • UDP: Local port is "0". • TCON: With TCON_IP_RFC: Local (local_tselector) or remote (remote_tselector) T selector was specified with a length •...
Page 862
Communication 11.2 PROFINET TSEND and TRCV Note When using PROFINET Open User communication, if you execute a TSEND instruction without a corresponding TRCV instruction executing on the remote device, then the TSEND instruction may reside indefinitely in a "Busy State", waiting for the TRCV instruction to receive the data.
Page 863
Communication 11.2 PROFINET Table 11- 24 Data types for the parameters of TSEND and TRCV Parameter and type Data type Description Bool TSEND: Starts the send job on a rising edge. The data is trans- ferred from the area specified by DATA and LEN. EN_R Bool TRCV: Enables the CPU to receive;...
Page 864
Communication 11.2 PROFINET TRCV Operations The TRCV instruction writes the received data to a receive area that is specified by the following two variables: ● Pointer to the start of the area ● Length of the area or the value supplied at the LEN input if not 0 Note The default setting of the LEN parameter (LEN = 0) uses the DATA parameter to determine the length of the data being transmitted.
Page 865
Communication 11.2 PROFINET Note Ad hoc mode The "ad hoc mode" exists with the TCP and ISO on TCP protocol variants. To configure the TRCV instruction for ad hoc mode, set the ADHOC instruction input parameter. The receive area is identical to the area formed by DATA. The length of the received data will be output to the parameter RCVD_LEN.
Page 866
Communication 11.2 PROFINET ERROR STATUS Description 80A1 Communications error: The specified connection has not yet established (TSEND and TRCV). • The specified connection is currently being terminated. Transmission or a receive • job over this connection is not possible (TSEND and TRCV). The interface is being reinitialized (TSEND).
Communication 11.2 PROFINET 11.2.8.10 Legacy TCON, TDISCON, TSEND, and TRCV instructions Prior to the release of STEP 7 V13 SP1 and the S7-1200 V4.1 CPUs, the TCON, TDISCON, TSEND, and TRCV instructions could only work with connection parameters with structures according to "TCON_Param".
Page 868
Communication 11.2 PROFINET Legacy TCON, TDISCON, TSEND, and TRCV (TCP communication) instructions Ethernet communication using TCP and ISO on TCP protocols Note TSEND_C and TRCV_C instructions To help simplify the programming of PROFINET/Ethernet communication, the TSEND_C instruction and the TRCV_C instruction combine the functionality of the TCON, TDISCON. TSEND and TRCV instructions: •...
Page 869
Communication 11.2 PROFINET TCON and TDISCON Note Initializing the communication parameters After you insert the TCON instruction, use the "Properties" of the instruction (Page 807) to configure the communication parameters (Page 832). As you enter the parameters for the communication partners in the inspector window, STEP 7 enters the corresponding data in the instance DB for the instruction.
Page 870
Communication 11.2 PROFINET Table 11- 29 Data types for the parameters of TCON and TDISCON Parameter and type Data type Description Bool Control parameter REQ starts the job by establishing the connection specified by ID. The job starts at rising edge. CONN_OUC (Word) Reference to the connection to be established (TCON) or terminated (TDISCON) to the remote partner, or between...
Page 871
Communication 11.2 PROFINET Table 11- 30 ERROR and STATUS condition codes for TCON and TDISCON ERROR STATUS Description 0000 Connection was established successfully. 7000 No job processing active 7001 Start job processing; establishing connection (TCON) or terminating connection (TDISCON) 7002 Follow-on call (REQ irrelevant);...
Page 872
Communication 11.2 PROFINET ERROR STATUS Description 80B7 TCON: Error in one of the following parameters of the data block for connection de- scription: block_length • local_tsap_id_len • rem_subnet_id_len • rem_staddr_len • rem_tsap_id_len • next_staddr_len • Note: When operating TCON in TCP passive mode, the LOCAL_TSAP_ID_LEN must be "2"...
Page 873
Communication 11.2 PROFINET TSEND and TRCV Note When using PROFINET Open User communication, if you execute a TSEND instruction without a corresponding TRCV instruction executing on the remote device, then the TSEND instruction may reside indefinitely in a "Busy State", waiting for the TRCV instruction to receive the data.
Page 874
Communication 11.2 PROFINET Table 11- 32 Data types for the parameters of TSEND and TRCV Parameter and type Data type Description Bool TSEND: Starts the send job on a rising edge. The data is trans- ferred from the area specified by DATA and LEN. EN_R Bool TRCV: Enables the CPU to receive;...
Page 875
Communication 11.2 PROFINET TRCV Operations The TRCV instruction writes the received data to a receive area that is specified by the following two variables: ● Pointer to the start of the area ● Length of the area or the value supplied at the LEN input if not 0 Note The default setting of the LEN parameter (LEN = 0) uses the DATA parameter to determine the length of the data being transmitted.
Page 876
Communication 11.2 PROFINET Note Ad hoc mode The "ad hoc mode" exists with the TCP and ISO on TCP protocol variants. You set "ad hoc mode" by assigning "65535" to the LEN parameter. The receive area is identical to the area formed by DATA.
Page 877
Communication 11.2 PROFINET ERROR STATUS Description 80A1 Communications error: The specified connection has not yet established (TSEND and TRCV). • The specified connection is currently being terminated. Transmission or a receive • job over this connection is not possible (TSEND and TRCV). The interface is being reinitialized (TSEND).
Communication 11.2 PROFINET 11.2.8.11 T_RESET (Terminate and re-establish an existing connection) instruction The "T_RESET" instruction terminates and then re-establishes an existing connection: Table 11- 34 T_RESET instruction LAD / FBD Description "T_RESET_DB"( Use the T_RESET instruction to terminate and req:=_bool_in_, then re-establish an existing connection.
Page 879
Communication 11.2 PROFINET Data types for the parameters The following table shows the parameters of the "T_RESET" instruction: Parameter Declaration Data type Memory area Description Input BOOL I, Q, M, D, L, T, C or Control parameter REQUEST starts the job constant for terminating the connection specified by ID.
Communication 11.2 PROFINET 11.2.8.12 T_DIAG (Checks the status of connection and reads information) instruction The "T_DIAG" instruction checks the status of a connection and reads further information on the local end point of this connection: Table 11- 35 T_DIAG instruction LAD / FBD Description "T_DIAG_DB"(...
Page 881
Communication 11.2 PROFINET Data types for the parameters The following table shows the parameters of the "T_DIAG" instruction: Parameter Declaration Data type Memory area Description Input BOOL I, Q, M, D, L, T, C or Starts the instruction to check the connection constant specified in the ID parameter when there is a positive edge.
Page 882
Communication 11.2 PROFINET STATUS parameter The following table shows the meaning of the values at the STATUS parameter: Error bit STATUS* Description (W#16#...) 0000 The instruction "T_DIAG" has been executed successfully. The data in the structure referenced at the RESULT parameter can be evaluated. 7000 No instruction processing active.
Page 883
Communication 11.2 PROFINET TDIAG_Status Structure The table below details the form of the TDIAG_Status structure. The value of each element is only valid if the instruction has been executed without errors. If an error occurs, the content of the parameters will not change: Name Data type Description...
Page 884
Communication 11.2 PROFINET Name Data type Description State BYTE Current status of the connection end point 0x00: Not used. • 0x01: Connection terminated. Temporary status, for example, after the • "T_RESET" instruction is called. The system then automatically attempts to re- establish the connection.
Communication 11.2 PROFINET 11.2.8.13 TMAIL_C (Send an email using the Ethernet interface of the CPU) instruction Overview You use the "TMAIL_C" instruction to send an e-mail using the Ethernet interface of the S7- 1200 CPU. The TMAIL_C instruction has two functionalities: ●...
Page 886
Communication 11.2 PROFINET You define the content of the e-mail, and the connection data, using the following parameters: ● You define the recipient addresses with the parameters TO_S and CC. ● You define the content of the e-mail with the parameters SUBJECT and TEXT. ●...
Page 887
Communication 11.2 PROFINET Data consistency The TO_S, CC, SUBJECT, TEXT, ATTACHMENT and MAIL_ADDR_PARAM parameters are applied by the "TMAIL_C" instruction while it is running, which means that they may only be changed after the job has been completed (BUSY = 0). SMTP authentication Authentication refers here to a procedure for verifying identity, for example, with a password query.
Page 888
Communication 11.2 PROFINET Data types for the parameters The following table shows the parameters of the "TMAIL_C" instruction: Parameter Declaration Data type Memory Description area Input BOOL I, Q, M, D, Control parameter REQUEST: Acti- L, T, C or vates the sending of an e-mail upon a constant rising edge.
Page 889
Communication 11.2 PROFINET Parameter Declaration Data type Memory Description area DONE Output BOOL I, Q, M, D, L Status parameter (Page 892) DONE = 0: Job not yet started or • still executing. DONE = 1: Job was executed with- •...
Page 890
Communication 11.2 PROFINET MAIL_ADDR_PARAM parameter At the MAIL_ADDR_PARAM parameter, you define the connection for sending the e-mail in the structure Tmail_v4 or Tmail_FQDN, and save the e-mail server address and login details. The structure you use at the MAIL_ADDR_PARAM parameter depends on the format in which the e-mail server is to be addressed: ●...
Page 891
Communication 11.2 PROFINET Table 11- 38 Tmail_FQDN: Addressing the mail server by FQDN Parameter Data type Description Tmail_v6 Struct Tmail_FQDN LADDR Hardware identifier of the interface CONN_OUC Connection ID ConnectionType BYTE Connection type. Select 16#22 as the connection type for FQDN.
Page 892
Communication 11.2 PROFINET DONE, BUSY and ERROR parameters The output parameters DONE, BUSY and ERROR are each displayed for only one cycle if the status of the BUSY output parameter changes from "1" to "0". The following table shows the relationship between DONE, BUSY, and ERROR. Using this table, you can determine the current status of the instruction "TMAIL_C and when the sending of the e-mail is complete.
Page 893
Communication 11.2 PROFINET Return val- Explanation Notes STATUS* (W#16#...): 8012 Error receiving the data You will find further information on evaluation in the SFB_STATUS parameter of the instance data block. The error code displayed at the SFB_STATUS parameter is explained in the STATUS parameter description for the TRCV (Page 857) instruction.
Communication 11.2 PROFINET Return val- Explanation Notes STATUS* (W#16#...): 8502 Command unknown or not imple- Check your entries, in particular the FROM mented parameter. It may be incomplete and you may have forgotten the "@" or "." (see also: TO_S and CC parameters (Page 891)).
Communication 11.2 PROFINET 11.2.8.15 TUSEND and TURCV The following instructions control the UDP communication process: ● TCON establishes the communication between the client and server (CPU) PC. ● TUSEND and TURCV send and receive data. ● TDISCON disconnects the communication between the client and server. Refer to TCON, TDISCON, TSEND, and TRCV (Page 857) in the "TCP and ISO-on-TCP"...
Page 896
Communication 11.2 PROFINET Table 11- 40 TUSEND and TURCV data types for the parameters Parameter and type Data type Description Bool Starts the send job on a rising edge. The data is transferred from the area specified by DATA and LEN. (TUSEND) EN_R Bool...
Page 897
Communication 11.2 PROFINET Parameter and type Data type Description DATA IN_OUT Variant Address of the sender area (TUSEND) or receive area (TURCV): The process image input table • The process image output table • A memory bit • A data block •...
Page 898
Communication 11.2 PROFINET Table 11- 42 TUSEND and TURCV condition codes for ERROR and STATUS ERROR STATUS Description 0000 Send job completed without error (TUSEND). • New data were accepted. The current length of the received data is shown in •...
Page 899
Communication 11.2 PROFINET Connection Ethernet protocols Every CPU has an integrated PROFINET port, which supports standard PROFINET communications. The TUSEND and TURCV instructions support the UDP Ethernet protocol. Refer to "Configuring the Local/Partner connection path" (Page 807)" in the "Device configuration"...
Page 900
Communication 11.2 PROFINET The TUSEND instruction sends data through UDP to the remote partner specified in the "TADDR_Param" data type. The TURCV instruction receives data through UDP. After a successful execution of the TURCV instruction, the "TADDR_Param" data type shows the address of the remote partner (the sender), as shown in the figures below.
Communication 11.2 PROFINET 11.2.8.16 T_CONFIG The T_CONFIG instruction can change the Ethernet address, the PROFINET device name, or the IP addresses of the NTP servers for time-of-day synchronization from within the user program. The following features can be adjusted permanently or temporarily: ●...
Page 902
Communication 11.2 PROFINET Table 11- 44 T_CONFIG data types for the parameters Parameter and type Data type Description Input Bool Starts the instruction on the rising edge. INTERFACE Input HW_Interface ID of network interface CONF_DATA Input Variant Reference to the structure of the configuration data; CONF_DATA is defined by a struct containing up to four System Data Types (SDT).
Page 903
Communication 11.2 PROFINET The following table shows the possible values for the parameters STATUS and ERR_LOC: STATUS* ERR_LOC* Explanation 0000_0000 0000_0000 Order processing completed without errors. 0070_0000 0000_0000 No job processing active. 0070_0100 0000_0000 Start of the order processing. 0070_0200 0000_0000 Intermediate call (REQ irrelevant).
Page 904
Communication 11.2 PROFINET STATUS* ERR_LOC* Explanation C080_9500 0001_000x Error in the system data type IF_CONF_V4, IF_CONF_NOS, or IF_CONF_NTP: The values of two parameters are inconsistent. C080_C200 0000_0000 Error at call of the instruction: The configuration data cannot be transferred. Possible cause: The PROFINET interface is not accessible.
Page 905
Communication 11.2 PROFINET Each subfield consists of a header (subfield_type_id, subfield_length, subfield_mode) and the subfield-specific parameters. Each subfield must consist of an even number of bytes. The subfield_mode can support a value of 1 or 2. Please refer to the tables below. Note Only one field (IF_CONF_Header) is currently allowed.
Page 906
Communication 11.2 PROFINET Table 11- 47 Elements of the IF_CONF_NOS data type Name Data type Start value Description UInt subfield_type_id Length UInt subfield_length Mode UInt subfield_mode (1: permanent or 2: temporary) NOS (Name of Array[1..240] of Byte Station name: You must occupy the ARRAY from the first station) byte.
Page 907
Communication 11.2 PROFINET Table 11- 48 Elements of the IF_CONF_NTP data type Name Data type Start value Description UInt subfield_type_id Length UInt subfield_length Mode UInt subfield_mode (2: temporary) NTP_IP Array[1...4] of IP_V4 IP addresses of NTP servers NTP_IP[1] IP_V4 IP addresses of NTP server 1 ADDR Array[1...4] of Byte ADDR[1]...
Page 908
Communication 11.2 PROFINET Example: Using the T_CONFIG instruction to change IP parameters In the following example, in the "addr" subfield, the "InterfaceAddress" (IP address), "SubnetMask", and "DefaultRouter" (IP router) are changed. In the CPU "Properties", "Ethernet address" page, you must select the "IP address is set directly at the device" radio button to enable you to change the IP parameters using the "T_CONFIG"...
Page 909
Communication 11.2 PROFINET S7-1200 Programmable controller System Manual, V4.2, 09/2016, A5E02486680-AK...
Page 910
Communication 11.2 PROFINET Example: Using the T_CONFIG instruction to change IP parameters and PROFINET IO device names In the following example, both the "addr" and "nos" (Name of station) subfields are changed. In the CPU "Properties", "Ethernet address" page, you must select the "PROFINET device name is set directly at the device"...
Page 911
Communication 11.2 PROFINET Example: Using the T_CONFIG instruction to change IP addresses in the NTP servers In the following example, in the "ntp" (Network Time Protocol (NTP) server) subfield, the T_CONFIG instruction changes the IP addresses of up to four NTP servers. In the CPU Properties, PROFINET interface [X1], Time synchronization page, you configure NTP synchronization by selecting the "Enable time synchronization via NTP server"...
Communication 11.2 PROFINET 11.2.8.17 Common parameters for instructions REQ input parameter Many of the Open User Communication instructions use the REQ input to initiate the operation on a low to high transition. The REQ input must be high (TRUE) for one execution of an instruction, but the REQ input can remain TRUE for as long as desired.
Communication 11.2 PROFINET Note Note that DONE, NDR, and ERROR are set for one execution only. Restricted TSAPs and port numbers for passive ISO and TCP communication If you use the "TCON" instruction to set up and establish a passive communications connection, the following port addresses are restricted and should not be used: ●...
Communication 11.2 PROFINET 11.2.9.1 Establishing the hardware communications connection The PROFINET interfaces establish the physical connections between a programming device and a CPU. Since Auto-Cross-Over functionality is built into the CPU, either a standard or crossover Ethernet cable can be used for the interface. An Ethernet switch is not required to connect a programming device directly to a CPU.
Communication 11.2 PROFINET 11.2.9.3 Assigning Internet Protocol (IP) addresses Assigning the IP addresses In a PROFINET network, each device must also have an Internet Protocol (IP) address. This address allows the device to deliver data on a more complex, routed network: ●...
Communication 11.2 PROFINET 11.2.10 HMI-to-PLC communication The CPU supports PROFINET communica- tions connections to HMIs (Page 32). The following requirements must be considered when setting up communications between CPUs and HMIs: Configuration/Setup: ● The PROFINET port of the CPU must be configured to connect with the HMI. ●...
Communication 11.2 PROFINET Table 11- 50 Required steps in configuring communications between an HMI and a CPU Step Task Establishing the hardware communications connection A PROFINET interface establishes the physical connection between an HMI and a CPU. Since Auto- Cross-Over functionality is built into the CPU, you can use either a standard or crossover Ethernet cable for the interface.
Communication 11.2 PROFINET 11.2.11 PLC-to-PLC communication A CPU can communicate with another CPU on a network by using the TSEND_C and TRCV_C in- structions. Consider the following when setting up communications between two CPUs: ● Configuration/Setup: Hardware configuration is required. ●...
Communication 11.2 PROFINET 11.2.11.1 Configuring logical network connections between two devices After you configure the rack with the CPU, you are now ready to configure your network connections. In the Devices and Networks portal, use the "Network view" to create the network connections between the devices in your project.
Page 920
Communication 11.2 PROFINET Configuring the TSEND_C instruction transmit (send) parameters TSEND_C instruction The TSEND_C instruction (Page 837) creates a communications connection to a partner station. The connection is set up, established, and automatically monitored until it is commanded to disconnect by the instruction. The TSEND_C instruction combines the functions of the TCON, TDISCON and TSEND instructions.
Page 921
Communication 11.2 PROFINET Configuring General parameters You specify the parameters in the Properties configuration dialog of the TSEND_C instruction. This dialog appears near the bottom of the page whenever you have selected any part of the TSEND_C instruction. Configuring the TRCV_C instruction receive parameters TRCV_C instruction The TRCV_C instruction (Page 837) creates a communications connection to a partner station.
Communication 11.2 PROFINET You can assign tag memory locations to the inputs and outputs, as shown in the following figure: Configuring the General parameters You specify the parameters in the Properties configuration dialog of the TRCV_C instruction. This dialog appears near the bottom of the page whenever you have selected any part of the TRCV_C instruction.
Communication 11.2 PROFINET You can now connect the PROFINET IO device to the CPU: 1. Right-click the "Not assigned" link on the device and select "Assign new IO controller" from the context menu to display the "Select IO controller" dialog. 2.
Communication 11.2 PROFINET 11.2.12.3 Assigning Internet Protocol (IP) addresses Assigning the IP addresses In a PROFINET network, each device must also have an Internet Protocol (IP) address. This address allows the device to deliver data on a more complex, routed network: ●...
Page 925
Communication 11.2 PROFINET Table 11- 53 Configuring the ET 200SP PROFINET IO cycle time ET 200SP PROFINET IO device ET 200SP PROFINET IO cycle dialog ① PROFINET port S7-1200 Programmable controller System Manual, V4.2, 09/2016, A5E02486680-AK...
Communication 11.2 PROFINET 11.2.13 Configuring a CPU and PROFINET I-device 11.2.13.1 I-device functionality The "I-device" (intelligent IO device) functionality of a CPU facilitates data exchange with an IO controller and operation of the CPU as intelligent preprocessing unit of sub processes, for example.
Communication 11.2 PROFINET 11.2.13.2 Properties and advantages of the I-device Fields of application Fields of application of the I-device: ● Distributed processing: A complex automation task can be divided into smaller units/subprocesses. This results in manageable processes which lead to simplified subtasks. ●...
Communication 11.2 PROFINET 11.2.13.3 Characteristics of an I-device An I-device is included in an IO system like a standard IO device. I-device without lower-level PROFINET IO system The I-device does not have its own distributed I/O. The configuration and parameter assignment of the I-devices in the role of an IO device is the same as for a distributed I/O system (for example, ET 200).
Page 929
Communication 11.2 PROFINET I-device with lower-level PROFINET IO system Depending on the configuration, an I-device can also be an IO controller on a PROFINET interface in addition to having the role of an IO device. This means that the I-device can be part of a higher-level IO system through its PROFINET interface and as an IO controller can support its own lower-level IO system.
Page 930
Communication 11.2 PROFINET Example: I-device as IO device and IO controller The I-device as IO device and IO controller is explained based on the example of a print process. The I-device controls a unit (a subprocess). One unit is used, for example, to insert additional sheets such as flyers or brochures in a package of printed material.
Communication 11.2 PROFINET 11.2.13.4 Data exchange between higher- and lower-level IO system Transfer areas are an interface to the user program of the I-device CPU. Inputs are processed in the user program and outputs are the result of the processing in the user program.
Page 932
Communication 11.2 PROFINET ① Data exchange between higher-level IO controller and normal IO-device In this way, the IO controller and IO devices exchange data through PROFINET. ② Data exchange between higher-level IO controller and I-device In this way, the IO controller and the I-device exchange data through PROFINET. The data exchange between a higher-level IO controller and an I-device is based upon the conventional IO controller / IO device relationship.
Communication 11.2 PROFINET ⑤ Data exchange between the I-device and a lower-level IO device In this way, the I-device and its IO devices exchange data. The data transfer is through PROFINET. 11.2.13.5 Configuring the I-device There are basically two possibilities for configuration: ●...
Page 934
Communication 11.2 PROFINET Configuration of an I-device within a project 1. Drag-and-drop a PROFINET CPU from the hardware catalog into the network view. 2. Drag-and-drop a PROFINET CPU, which can also be configured as an IO device, from the hardware catalog into the network view. This device is configured as an I-device (for example, CPU 1215C).
Page 935
Communication 11.2 PROFINET 7. Configure the transfer areas. The transfer areas are found in the area navigation section "I-device communication": – Click in the first field of the "Transfer area" column. STEP 7 assigns a default name which you can change. –...
Communication 11.2 PROFINET 11.2.14 Shared devices 11.2.14.1 Shared device functionality Numerous IO controllers are often used in larger or widely distributed systems. Without the "Shared Device" function, each I/O module of an IO device is assigned to the same IO controller. If sensors that are physically close to each other must provide data to different IO controllers, several IO devices are required.
Page 937
Communication 11.2 PROFINET Requirement (GSD configuration) ● STEP 7 V12 Service Pack 1 or higher ● S7-1200 CPU with firmware of V4.1 or later as IO controller ● IO device supports the shared device function, e.g. interface module IM 155-5 PN ST ●...
Page 938
Communication 11.2 PROFINET Setting of the real-time properties STEP 7 calculates the communication load and thus the resulting update times. You must enter the number of project-external IO controllers in the project in which the PROFINET interface of the shared device is assigned to the IO controller so that a calculation is possible with shared device configurations.
Communication 11.2 PROFINET Boundary conditions The following boundary conditions result because a shared device configuration is distributed across several projects: ● The addresses of modules or submodules that are not assigned to this IO controller are missing in the address overview of each IO controller that has access to a shared device. ●...
Page 940
Communication 11.2 PROFINET Procedure: Creating project 1 To create the first project with a shared device, follow these steps: 1. Start STEP 7. 2. Create a new project with the name "Controller1". 3. Insert a CPU 1215C from the hardware catalog in the network view. Name it "Controller1".
Page 941
Communication 11.2 PROFINET Procedure: Creating project 2 To create the second project with a shared device, follow these steps: 1. Start STEP 7 once again. A new instance of STEP 7 opens. 2. In the new instance, create a new project with the name "Controller2". 3.
Page 942
Communication 11.2 PROFINET Procedure: Configuring access to the shared device The modules and submodules you insert in the shared device are automatically assigned to the local CPU. To change the assignment, follow these steps: 1. Select the interface module in the network or device view of project "Controller1". 2.
Page 943
Communication 11.2 PROFINET 6. Select the setting "---" for all modules and submodules that are to be located in the address range of the CPU from the "Controller1" project (Controller1). 7. Finally, check whether the settings for access are "complementary" for each module or submodule in both projects.
Page 944
Communication 11.2 PROFINET Procedure: Adjusting the real-time settings To ensure that all IO controllers and shared devices are operated with the appropriate send clock and that the update times are calculated correctly based on the communication load, you must adjust and check the following settings: 1.
Communication 11.2 PROFINET 11.2.14.3 Example: Configuring an I-device as a shared device This example describes how to configure an S7-1200 as an I-device with STEP 7 Version V13 SP1 or higher and then use it in two projects as a shared device. A "distributed"...
Page 946
Communication 11.2 PROFINET I-device You assign the following parameters for an S7-1200 CPU as an I-device: ● Centralized and distributed I/O ● Desired transfer areas ● Number of IO controllers having access to this I-device (always greater than 1 for a shared device) Note You configure the I-device without a higher-level IO controller.
Page 947
Communication 11.2 PROFINET Procedure: Creating the S7-1200-I-device project To create the project with a shared I-device, follow these steps: 1. Start STEP 7. 2. Create a new project with the name "S7-1200-I-device". 3. Insert a CPU 1215C from the hardware catalog in the network view. Assign the name "S7-1200-I-device".
Page 948
7. Click the "Export" button ("Mode" > "I-device configuration" area, "Export general station description file (GSD)" section). If you do not change the name in the Export dialog, the GSD file uses an assigned format name (for example, "GSDML-V2.31-#Siemens- PreConf_S7-1200-I-Device-20130925-123456").
Page 949
Communication 11.2 PROFINET Procedure: Creating the Controller1 project To create the first project with a shared I-device, follow these steps: 1. Start STEP 7. 2. Install the PROFINET GSD file from the export of the I-device CPU (S7-1200-I-Device). 3. Create a new project with the name "Controller1". 4.
Page 950
Communication 11.2 PROFINET 7. Select the "Shared device" area in the properties of the I-device: – In the table, all transfer areas and the PROFINET interface are assigned to the local IO controller (Controller1). – Define the transfer areas to which the Controller1 CPU should not have access. Select the "---"...
Page 951
Communication 11.2 PROFINET 8. You can adapt the addresses from the Device view of the IO controller in the Device overview. To open the device overview, double-click the I-device. 9. Save the project. Procedure - Creating the Controller2 project To create the second project with a shared device, follow these steps: 1.
Page 952
Communication 11.2 PROFINET Summary - Assigning parameters for access to the shared device The transfer areas are automatically assigned to the local IO controller. To change the assignment, follow these steps: 1. Click the "S7-1200-I-Device" device in the network view of the "Controller1" project, and select the "Shared device"...
Page 953
Communication 11.2 PROFINET Procedure - Adjusting the real-time settings To ensure that all IO controllers and shared devices are operated with the appropriate send clock and that the update times are calculated correctly based on the communication load, you must adjust and check the following settings: 1.
Communication 11.2 PROFINET 11.2.15 Media Redundancy Protocol (MRP) The following V4.2 S7-1200 CPUs support operations as an MRP client, but do not fulfill the MRP manager role: ● CPU 1215C ● CPU 1217C ● CPU 1215FC The three S7-1200 CPUs all have two PN ports which are required to support the MRP protocol and the configuration parameters used to initialize MRP client operation.
Page 955
Communication 11.2 PROFINET How media redundancy works in a ring topology The data paths between the individual devices are automatically reconfigured if the ring is interrupted at any point. The devices are available again after reconfiguration. In the MRP manager, one of the two ring ports is blocked in uninterrupted network operation for normal communication so that no data frames are circulated.
Communication 11.2 PROFINET 11.2.15.2 Using Media Redundancy Protocol (MRP) The "MRP" process works in conformity with Media Redundancy Protocol (MRP), which is specified in IEC 61158 Type 10 "PROFINET". Requirements The following requirements must be met for error-free operation with MRP: ●...
Page 957
Communication 11.2 PROFINET The following rules apply to a ring topology with media redundancy using MRP: ● All devices in the ring belong to the same redundancy domain. ● One device in the ring has the role of a MRP manager. ●...
Page 958
Communication 11.2 PROFINET Watchdog time The watchdog time is the time interval that an IO controller or IO device permits, without receiving IO data. If the IO device is not supplied by the IO controller with data within the watchdog time, the device detects the missing frames and outputs substitute values. This is reported in the IO controller as a station failure.
Communication 11.2 PROFINET 11.2.15.3 Configuring media redundancy All of the components in your application must support Media Redundancy Protocol (MRP). Procedure To configure media redundancy, proceed as follows: 1. Establish a ring by means of appropriate port interconnections (for example, in the topology view).
Page 960
Communication 11.2 PROFINET 3. Navigate to the device of the required MRP domain in the inspector window. 4. For the PROFINET devices, set the "Manager (Auto)", "Client", or "Not device in the ring" role. Note You cannot assign the "Manager (Auto)" MRP role to the S7-1200 CPU. "Media redundancy"...
Page 961
Communication 11.2 PROFINET "Media redundancy" setting option: Ring port 1 and Ring port 2 Select one at a time those ports you want to configure as ring port 1 or ring port 2. The drop- down list box shows the selection of possible ports for each device type. If the ports are set at the factory, then the fields are unavailable.
● Routing between the CPU and a CP ● Routing from one CP to another CP Refer to S7-1200 CPs at Siemens Industry Online Support, Product Support for further information on all S7-1200 CPs that support the S7 routing function. The CP 1243-1 (https://support.industry.siemens.com/cs/us/en/view/584459) is shown as an example CP...
Communication 11.2 PROFINET 11.2.16.1 S7 routing between CPU and CP interfaces Since the S7-1200 CPUs are limited to a single PN interface, a stand-alone CPU cannot serve the function of a router. You can never connect a stand-alone CPU to more than one S7 subnet at a time.
Communication 11.2 PROFINET 11.2.17 Disabling SNMP Simple Network Management Protocol (SNMP) is an Internet-standard protocol for collecting and organizing information about managed devices on IP networks and for modifying that information to change device behavior. Devices that typically support SNMP include routers, switches, servers, workstations, printers, modem racks, and more.
Communication 11.2 PROFINET 11.2.17.1 Disabling SNMP Disabling SNMP Follow these steps to disable SNMP in the S7-1200 CPU: 1. Create a classic data block (DB): 2. Select the Properties of the newly-created DB. 3. Select the Attributes tab. Deselect the check box for "Optimized block access": 4.
Page 966
Communication 11.2 PROFINET 5. In the classic DB block interface, create the following static tags with the values shown. You will use these tags in your program to disable the internal SNMP implementation: 6. In the Startup OB (OB100), add the Temporary variables as shown: 7.
Communication 11.2 PROFINET 11.2.18 Diagnostics Refer to "Organization blocks (OBs)" (Page 92) for information on how to use organization blocks (OBs) for diagnostics with these communication networks. 11.2.19 Distributed I/O instructions Refer to "Distributed I/O (PROFINET, PROFIBUS, or AS-i)" (Page 384) for information on how to use the distributed I/O instructions with these communication networks.
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 (https://support.industry.siemens.com/cs/ww/en/ps/6GK7242-5DX30-0XE0) pages on the Internet.
Page 969
Master CM firmware to at least V1.3. Note Always update the PROFIBUS CM firmware to the latest version available (http://support.automation.siemens.com/WW/view/en/42131407). You can perform a firmware update by any of these methods: • Using the online and diagnostic tools of STEP 7 (Page 1318) •...
Communication 11.3 PROFIBUS 11.3.1 Communications services of the PROFIBUS CMs The PROFIBUS CMs use the PROFIBUS DP-V1 protocol. Types of communication with DP-V1 The following types of communication are available with DP-V1: ● Cyclic communication (CM 1242-5 and CM 1243-5) Both PROFIBUS modules support cyclic communication for the transfer of process data between DP slave and DP master.
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 (https://support.industry.siemens.com/cs/ww/en/ps/15667) ●...
Communication 11.3 PROFIBUS Next, select "6ES7 155-6BU00-0CN0" (IM155-6 DP HF) from the list of part numbers, and add the ET 200SP DP slave as shown in the figure below. Table 11- 55 Adding an ET 200SP DP slave to the device configuration Insert the DP slave Result 11.3.3.2...
Page 973
● Address 0: Reserved for network configuration and/or programming tools attached to the ● Address 1: Reserved by Siemens for the first master ● Address 126: Reserved for devices from the factory that do not have a switch setting and must be re-addressed through the network ●...
Communication 11.3 PROFIBUS Table 11- 57 Parameters for the PROFIBUS address 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"...
AS-i Master CM 1243-2. Note It is recommended that you always update the AS-i CM firmware to the latest version available (http://support.automation.siemens.com/WW/view/en/43416171)at the Siemens Service and Support web site. S7-1200 Programmable controller System Manual, V4.2, 09/2016, A5E02486680-AK...
The AS-i master CM 1243-2 is integrated into the S7-1200 automation system as a communication module. You can find detailed information on the AS-i master CM 1243-2 in the "AS-i master CM 1243-2 and AS-i data decoupling unit DCM 1271 for SIMATIC S7-1200" Manual (https://support.industry.siemens.com/cs/ww/en/ps/15750/man). 11.4.1.1 Adding the AS-i master CM 1243-2 and AS-i slave Use the hardware catalog to add AS-i master CM1243-2 modules to the CPU.
Communication 11.4 AS-i 11.4.1.2 Configuring logical network connections between two AS-i devices After you configure the AS-i master CM1243-2, you are now ready to configure your network connections. In the Devices and Networks portal, use the "Network view" to create the network connections between the devices in your project.
Communication 11.4 AS-i 11.4.1.4 Assigning an AS-i address to an AS-i slave Configuring the AS-i slave interface To configure parameters for the AS-i interface, click the yellow AS-i box on the AS-i slave, and the "Properties" tab in the inspector window displays the AS-i interface. ①...
Page 979
Communication 11.4 AS-i Assigning the AS-i slave address In an AS-i network, each device is assigned an AS-i slave address. This address can range from 0 through 31; however, address 0 is reserved only for new slave devices. The slave addresses are 1(A or B) to 31(A or B) for a total of up to 62 slave devices.
Page 980
Communication 11.4 AS-i Enter the AS-i slave address here: Table 11- 61 Parameters for the AS-i interface 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 S7-1200 Programmable controller System Manual, V4.2, 09/2016, A5E02486680-AK...
"ACTUAL > EXPECTED". Further information You can find detailed information on the AS-i master CM 1243-2 in the "AS-i master CM 1243-2 and AS-i data decoupling unit DCM 1271 for SIMATIC S7-1200" Manual (https://support.industry.siemens.com/cs/ww/en/ps/15750/man). S7-1200 Programmable controller...
Communication 11.4 AS-i 11.4.2.2 Configuring slaves with STEP 7 Transferring AS-i digital values The CPU accesses the digital inputs and outputs of the AS-i slaves through the AS-i master CM1243-2 in cyclic operation. The data is accessed through I/O addresses or by means of a data record transfer.
Page 983
(Page 981) ("ACTUAL -> EXPECTED") will be overwritten. Further information You can find detailed information on the AS-i master CM 1243-2 in the "AS-i master CM 1243-2 and AS-i data decoupling unit DCM 1271 for SIMATIC S7-1200" Manual (http://support.automation.siemens.com/WW/view/en/50414115/133300). S7-1200 Programmable controller...
Communication 11.4 AS-i 11.4.3 Distributed I/O instructions Refer to "Distributed I/O (PROFINET, PROFIBUS, or AS-i)" (Page 384) for information on how to use the distributed I/O instructions with these communication networks. 11.4.4 Working with AS-i online tools Changing AS-i operational modes online You must go online to view and change the AS-i operational modes.
Page 985
Communication 11.4 AS-i There are two AS-i operational modes: ● Protection mode: – You cannot change AS-i slave device and CPU I/O addresses. – The green "CM" LED is OFF. ● Configuration mode: – You can make required changes in your AS-i slave device and CPU I/O addresses. –...
Communication 11.5 S7 communication 11.5 S7 communication 11.5.1 GET and PUT (Read and write from a remote CPU) You can use the GET and PUT instructions to communicate with S7 CPUs through PROFINET and PROFIBUS connections. This is only possible if the "Permit access with PUT/GET communication"...
Page 987
Communication 11.5 S7 communication Table 11- 62 GET and PUT instructions LAD / FBD Description "GET_DB"( Use the GET instruction to read data from req:=_bool_in_, a remote S7 CPU. The remote CPU can ID:=_word_in_, be in either RUN or STOP mode. ndr=>_bool_out_, STEP 7 automatically creates the DB error=>_bool_out_,...
Page 988
Communication 11.5 S7 communication Table 11- 63 Data types for the parameters Parameter and type Data type Description Input Bool A low to high (positive edge) signal starts the operation. Input CONN_PRG S7 connection ID (Hex) (Word) NDR (GET) Output Bool New Data Ready: 0: request has not yet started or is still running...
Page 989
Communication 11.5 S7 communication You must ensure that the length (number of bytes) and data types for the ADDR_x (remote CPU) and RD_x or SD_x (local CPU) parameters match. The number after the identifier "Byte" is the number of bytes referenced by the ADDR_x, RD_x, or SD_x parameter. Note The total number of bytes received on a GET instruction or the total number of bytes sent on a PUT instruction is limited.
Page 990
Communication 11.5 S7 communication The ERROR and STATUS parameters provide information about the status of the read (GET) or write (PUT) operation. Table 11- 64 Error information ERROR STATUS (deci- Description mal) New job cannot take effect since previous job is not yet completed. •...
Communication 11.5 S7 communication 11.5.2 Creating an S7 connection 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.
Communication 11.5 S7 communication 11.5.3 Configuring the Local/Partner connection path between two devices Configuring General parameters You specify the communication parameters in the "Properties" configuration dialog of the communication instruction. This dialog appears near the bottom of the page whenever you have selected any part of the instruction.
Communication 11.5 S7 communication The inspector window displays the properties of the connection whenever you have selected any part of the instruction. You can configure the communication parameters in the "Configuration" tab of the "Properties" for the communication instruction. Note V4.1 and later CPU program GET/PUT operation is not automatically enabled A V3.0 CPU program GET/PUT operation is automatically enabled in a V4.1 and later CPU.
Page 994
Communication 11.5 S7 communication Table 11- 65 Connection parameter: General definitions Parameter Definition Connection End point "Local End point": Name assigned to the Local CPU parameter: "Partner End point": Name assigned to the Partner (remote) CPU General Note: In the "Partner End point" dropdown list, the system displays all potential S7 connection partners of the current project as well as the option "unspeci- fied".
Communication 11.5 S7 communication Connection name parameter The connection name is editable through a special user control, the "Connection overview" dialog. This dialog offers all the available S7 connections which could be selected as an alternative for the current GET/PUT communication. The user can create a completely new connection in this table.
Page 996
Communication 11.5 S7 communication For the GET or PUT instruction, the "Properties" tab is automatically displayed in the inspector window with the following menu selections: ● "Configuration" ● "Connection parameters" Configuring a PROFINET S7 connection For the "Partner End point", select "PLC_3". S7-1200 Programmable controller System Manual, V4.2, 09/2016, A5E02486680-AK...
Page 997
Communication 11.5 S7 communication The system reacts with the following changes: Table 11- 66 Connection parameter: General values Parameter Definition Connection End point "Local End point" contains "PLC_1" as read-only. parameter: "Partner End point" field contains "PLC_3[CPU319-3PN/DP]": General The color switches from red to white •...
Page 998
Communication 11.5 S7 communication Completed PROFINET S7 connection In the "Network view", a two-way S7 connection is shown in the "Connections" table between "PLC_1" and "PLC_3". Configuring a PROFIBUS S7 connection For the "Partner End point", select "PLC_3". S7-1200 Programmable controller System Manual, V4.2, 09/2016, A5E02486680-AK...
Page 999
Communication 11.5 S7 communication The system reacts with the following changes: Table 11- 67 Connection parameter: General values Parameter Definition Connection End point "Local End point" contains "PLC_1" as read-only. parameter: "Partner End point" field contains "PLC_3[CPU319-3PN/DP]": General The color switches from red to white •...
Page 1000
Communication 11.5 S7 communication Completed PROFIBUS S7 connection In the "Network view", a one-way S7 connection is shown in the "Connections" table between "PLC_1" and "PLC_3". S7-1200 Programmable controller 1000 System Manual, V4.2, 09/2016, A5E02486680-AK...