Welcome to the Industrial Automation website!

NameDescriptionContent
XING-Automation
E-mail  
Password  
  
Forgot password?
  Register
当前位置:

SIEMIENS S7-1200/1500 Controller TIA Portal Programming Guide

F: | Au:FAN | DA:2025-11-24 | 729 Br: | 🔊 点击朗读正文 ❚❚ | Share:


SIEMIENS S7-1200/1500 Controller TIA Portal Programming Guide

Overview

The Siemens S7-1200/1500 Controller TIA Portal Programming Guide (V1.6 version) focuses on optimizing programming and covers the core innovations of the S7-1200/1500, such as optimization blocks, new data types VNet, direct machine code compilation, general programming specifications (block structure, symbol addressing, memory management), hardware independent programming methods, STEP 7 Safety programming points, and visual automatic generation solutions. It explicitly recommends using optimization blocks instead of non optimization blocks, symbol addressing instead of absolute addressing, and global data blocks instead of bit memory. At the same time, it provides a large number of performance optimization techniques (such as avoiding deep call hierarchy and using loop instructions reasonably), aiming to help users achieve standardized, efficient, and reusable automation program development.


S7-1200/1500 Core Innovation

1. Programming languages and compilation optimization

Language support differences:

Programming language S7-1200 S7-1500

Ladder diagram (LAD) ✅   ✅

Function Block Diagram (FBD) ✅   ✅

Structured Control Language (SCL) ✅   ✅

Statement Table (STL) ❌   ✅

Sequential Function Graph ❌   ✅

Compilation method: S7-1200/1500 generates machine code directly for all languages, without the intermediate step of "LAD/FBD → STL → machine code" for S7-300/400, ensuring consistent performance for all languages.

2. Optimize block technology (core innovation)

Optimized block vs non optimized block:

Feature optimization block (recommended) Non optimization block (only compatible)

Data storage is automatically sorted by data type, stored in declared order without gaps, and may have gaps

The addressing method can be either symbolic addressing or absolute addressing

Retention settings: A single label can be set to maintain the entire block or not to maintain it

Download feature supports uninitialized download (RUN mode update) not supported

Fast access speed (processor optimized storage) slow

Setting method: By default, "Optimize Block Access" is enabled for new blocks, which can be batch modified in the "Program Block" list; The optimization properties of instance DB inherit from the associated FB.

3. New data types

Core new type:

Data Type Applicable Controller Purpose Key Features

VARIANT S7-1500; S7-1200 (FW4.1+) dynamic pointer with type detection, replacing the ANY pointer, supporting symbol access

Date_Time_Long (DTL) both support timestamp storage containing year/month/day/nanosecond, with symbol accessible sub fields (such as DTL. Hour)

Both LReal and LReal support high-precision floating-point numbers of 64 bits and 15 decimal places, making them suitable for precise calculations

LTime only has a long-term storage range of ± 106751 days for S7-1500 and supports nanosecond level accuracy

WSRING only supports S7-1500 Unicode strings for multiple languages (such as Chinese and Latin), with a maximum of 16382 characters

4. Key instruction upgrade

MOVE series instructions:

Advantages of Instruction Usage

MOVE supports single value copying and complete copying of structures/arrays

MOVE_SLK array partial copy specifies the starting index and quantity, efficiently processing the array

MOVE_SLK_VARIANT Dynamic Type Copy Run Time Detect Data Types, Supports PLC Data Types/Arrays

The serialize/deserialize structure and byte array conversion are used for communication frame packaging/unpacking, supporting VNet input

Other instructions:

TypeOf(): detects the data type pointed to by VNet on the label (SCL only);

RUNTIME: measures program/block running time, supports performance optimization;

Multi assignment (V14+): such as # a:=# b:=# c:=0; Simplify initialization.

image.png

Universal Programming Specification

1. Program block structure

Core block type:

Key features of block type functionality

Organizational block (OB) operating system call, management program execution including loop OB (OB1), interrupt OB (OB40 hardware interrupt), etc; S7-1200 up to 100 cycles/start OB, S7-1500 supports clock interrupt OB

Function (FC) has no state block and no independent storage temporary label. Only the current call is valid, and data needs to be passed through parameters; Support direct participation of return values in SCL formulas

Function block (FB) has a status block that requires the instance DB static label to maintain its value; The instance DB structure is defined by FB and cannot be modified separately

Data Block (DB) stores data in a global DB for all blocks to access; Instance DB is only associated with FB usage

Block Reuse Techniques:

Multiple instances: FB calls other FBs to store data in their own instance DB, reducing the number of instance DBs;

Typeization block: Store FB/FC/PLC data types in the global library, supporting cross project reuse and batch updates.

2. Memory management

Memory type and access speed (from fast to slow):

Optimize the temporary labels, FC/FB parameters, and non persistent static labels of the block;

Optimize the retention labels of blocks and optimize the global database;

Non optimized blocks;

Array access for runtime calculation index (such as # Array [# i]);

Indirect memory access (such as pointer operations);

Data replication between optimized and non optimized blocks.

Key recommendations:

Replace bit memory with global DB (M-zone): The size of M-zone varies depending on the controller, while global DB is more flexible and supports optimized storage;

Use temporary tag caching for frequently accessed I/O tags to reduce the number of I/O accesses;

Retention setting: Only the necessary labels need to be set to hold (such as process parameters) to reduce the cost of saving power-off data.

3. Addressing method

Symbol addressing (mandatory recommendation):

Advantages: The tag name is descriptive (such as # Motor1_Run) and automatically updates when the address changes, reducing errors;

Operation: Simply enter the symbol name in the instruction input box, right-click on "Define Label" to quickly create it.

Indirect access scheme:

Indirect array access: Replace pointers with # Array [# Index], such as # Temp:=# MotorSpeed [# i];;

Slice access: Directly access the bits/bytes of Byte/Word/DWord, such as # WordVar.% X0 (bits), # DWordVar.% W1 (words).

4. Performance optimization techniques

Disable the ENO evaluation (LAD/FBD) of blocks to reduce runtime detection;

Avoid deep level calling (≤ 8 layers), otherwise TIA Portal will compile alarms and increase protection code overhead;

FOR loop: Do not manipulate the loop counter (compiler optimized times), use EXIT to interrupt the loop;

Reduce unnecessary IF instructions, such as # Motor:=# On1 AND # On2; Replace IF # On1 AND # On2 THEN # Motor:=TRUE;  ELSE #Motor:=FALSE;  END_IF;。


Hardware independent programming

1. Data type compatibility

Only use EN 61131-3 standard data types (such as INT/DINT/REAL/BOOL), avoiding S7-300/400 specific types (such as S5TIME);

The timer/counter of S7-1200/1500 uses IEC standard blocks (such as TON/CUTU) and is integrated through multiple instances to avoid absolute addresses (such as T37).

2. Clock signal replacement

Do not use hardware clock memory (such as M0.5), use programming clock generation block instead:

Example: SCL writes FB, sets the frequency through the # Frequency parameter, # Q outputs pulses, and # Countdown outputs the remaining time;

Advantage: The clock frequency can be flexibly adjusted without relying on hardware configuration.

image.png

STEP 7 Safety Programming

1. Core components

F operation group: the execution unit of safety programs, including 1 fault safety OB and 1 main safety block, with a maximum of 2 created;

F-signature: a unique identifier for each F-component (F-I/O, F-block) used to detect configuration/programming changes;

Security Management Editor: Manage F run groups, F signatures, access permissions, and set security program passwords.

2. Key specifications

Data exchange: Standard programs and security programs only interact through two standard DBs, avoiding direct access to the security DB;

Performance optimization:

Avoid using TP/TON/TOF instructions (add protection code);

Disable the JMP/Label structure (resulting in additional system protection blocks);

Loop call hierarchy ≤ 8 layers;

Test restriction: The security program can only force testing when the security mode is disabled, with a maximum of 5 F-I/O forced at a time.


 Visual automatic generation (SiVArc)

1. Basic requirements

Tools: TIA Portal V14++SiVArc Options Package;

Prerequisite: The program is modularized (such as motor control FB, conveyor belt FB), and the visualization library includes standard image templates.

2. Control mode

Network comment: Add a tag (such as "SiVArc: Generate=True") when calling the network on FB. The SiVArc rule triggers generation through Contains (Block. NetworkComment, "Generate=True");

SiVArc variable: Define a variable in the "Plugin" label of the block (such as Location="Bottling_Test"), and the rule filters the generated range based on the variable value.

  • Atlas Copco QCS-T34025 Quick Connect System
  • Atlas Copco HR115-C6-88S Electric Nutrunner
  • Atlas Copco 4240031280 PF4 Tool Cable Assembly
  • Atlas Copco 3HAB8101-11 Robot Controller Component
  • Atlas Copco 1614 6449-00 Regulating Valve
  • Atlas Copco 9040120204 Power Box Tool Controller 400VAC
  • Atlas Copco 1900100381 Control Panel for Air Compressor
  • Atlas Copco TC-4000-P-PB-ES Power MACS Controller Drive
  • Atlas Copco 2012-S7-115R Power Focus Torque Controller Tensor S7
  • Atlas Copco IRC-Focus-B-C-EIP-HW IRC Focus Controller with Bluetooth
  • Atlas Copco LTV 48 R150-HAD Nutrunner Air Wrench
  • Atlas Copco TC4000-P-ES Torque Controller 8435651100
  • Atlas Copco 4240-5008-01 Servo Motor
  • Atlas Copco 8433-0015-30 Controller Module
  • Atlas Copco 3HAB8101-6/07B Servo Driver
  • Atlas Copco QST Cable 4220379907
  • Atlas Copco 1900071181 Compressor Control Panel
  • Atlas Copco 1900071292 Compressor Control Panel
  • Atlas Copco 2101-S9-115R Tensor S9 Power Focus Controller
  • Atlas Copco XC2002 Compressor Control Panel 1604951600
  • Atlas Copco 4240500201 PF4 Interface Cable
  • Atlas Copco PF4 Tool Cable 5M ST 4220 2636 05
  • Atlas Copco PF4 Tool Cable 5M ST 4220 2636 05
  • Atlas Copco 4240-0366-82 PF4 Tool Cable 5 Meter
  • Atlas Copco 4240-0367-81 PF4 Tool Cable with Straight Connector
  • Atlas Copco 4240-0367-82 PF4 Tool Cable Assembly
  • Atlas Copco 2101-S9-115R Electric Nutrunner Assembly Tool
  • Atlas Copco 3HAB8101-7 Control Interface
  • Atlas Copco 3HAB8101-3/07B Control Module
  • Atlas Copco PF6000 IAM Station Control
  • Atlas Copco 8433-0610-04 Selector-4 Controller
  • Atlas Copco Power Focus PF4000-C-DN-HW Tool Controller
  • Atlas Copco SAM-PA-400-30-E Power Supply Module
  • Atlas Copco PF3007-C-H Tensor S4 S7 Torque Controller
  • Atlas Copco PF4000-C-HW Control System 8433610005
  • Atlas Copco BSM 2590D R Servo Motor 4230 3012 80
  • Atlas Copco 80450.000029 Servo Motor Gear Drive Unit
  • Atlas Copco 3HAB8101-4/02D Servo Driver DSQC345D
  • Atlas Copco 1900071032 Compressor Control Panel
  • Atlas Copco 1900520400 Compressor Control Panel
  • Atlas Copco Power Focus PF4000-C-EIP-HW Tool Controller
  • Atlas Copco PF6000IF 8436180202 Controller
  • Atlas Copco 8202900410 Power Supply Unit
  • Atlas Copco 4240-0355-80 Interface Module
  • Atlas Copco 1089935597 Start Switch Control Panel
  • Atlas Copco 1626850003 XC2003 Control Panel
  • Atlas Copco STR61-200-20 Angle Wrench
  • Atlas Copco 1900070123 Power Control Module
  • Atlas Copco 1089935597 Compressor Control Panel
  • Atlas Copco ETP ST32-10-10 Pistol Nutrunner
  • Atlas Copco 1900520400 Control Panel Unit
  • Atlas Copco 48R050-01001 Relay Module
  • Atlas Copco 49-4100-01C5L Power Supply
  • Atlas Copco D303-DL-BASIC Controller
  • Atlas Copco 8433056445 I/O Expander Error Proofing Module
  • Atlas Copco PF4000-G-HW Screwdriver Controller
  • Atlas Copco 1202-66270-9325 Cooler Cover Valve
  • Atlas Copco EA2-TX-100 Dew Point Sensor
  • Atlas Copco PF4000-C-HW Controller 240VAC
  • Atlas Copco 1900 0701 05 Elektronikon Control Panel
  • Atlas Copco PF3107-C-HW Tensor 3-7 Controller
  • Atlas Copco TPS Control 8202900410 Controller
  • Atlas Copco 1900-1005-27 Circuit Board XAS 750
  • Atlas Copco Power Focus SL PF4002-C-HW Controller
  • Atlas Copco 1900520490 Air Compressor Control Panel
  • Atlas Copco QCM2-T-34050 Mass Flow Meter
  • Atlas Copco CSS91-B2 Compressor Controller Module
  • Atlas Copco PF3109-C-DN-HW Industrial Controller
  • Atlas Copco P1900520060 Air Compressor Controller Gateway
  • Atlas Copco Coupling 1635099600 Compressor Part
  • Atlas Copco ACTA 4000 Torque Calibrator
  • Atlas Copco 1626850005 Compressor Control Panel
  • Atlas Copco DMC50412 Digital Motion Controller
  • Kontron 2-DH34-0100-03 Atlas Copco SOKO-M@C-IIA-70 HMI 12-24V
  • Atlas Copco PF3107-G-HW PF3107GHW Controller
  • Atlas Copco PF3109-G-DN-HW PF3109GDNHW Controller
  • Atlas Copco 8433-2742-00 Power Supply Module
  • Atlas Copco 1900-0710-82 Controller Module
  • Atlas Copco 9040120204 Industrial Component
  • Atlas Copco 2906-0674-00 Zr55-90 8000H Maintenance Kit
  • Atlas Copco 1900 0701 23 High Range Regulator for Compressor Controller
  • Atlas Copco 4220263610 PF4 Tool Cable 10M ST Cable
  • Atlas Copco XC2002 1604951601 Compressor Panel
  • Atlas Copco S9 Tensor PF3009-G-DN-HW Controller
  • Atlas Copco 80471.000009 Pneumatic Roller Screw Unit
  • Atlas Copco 8433710005 PF4000-C-HW Compact Controller Profibus
  • Atlas Copco PF4002-G-HW Power Focus Controller
  • Atlas Copco 8431038150 Impulse Nutrunner
  • Atlas Copco PF6000 Power Focus Nutrunner Controller
  • Atlas Copco 1626850006 Compressor Controller Panel
  • Atlas Copco STR61-70-13 Tensor Angle Wrench
  • Atlas Copco ETV ST61-40-10 Right Angle Electric Screwdriver with Cable
  • Atlas Copco MK5S Touch Display Controller P1900520400
  • Atlas Copco 1900520020 Controller Panel for Compressor
  • Atlas Copco SRTT-B 1000Nm-50 Transducer 8059094675
  • Atlas Copco ETV ST61-50-10 Right Angle Electric Screwdriver with Cables
  • Atlas Copco 4240070100 Power Supply Module
  • Atlas Copco TC-52S-I TC52SI Controller
  • Atlas Copco ACTA 4000 QC Torque Calibrator
  • Atlas Copco 8433 1236 51 ETV S42-10-10 Right Angle Nutrunner
  • Atlas Copco ETV STB63-50-B10-BCR-IRCW Tensor STB Right Angle Nutrunner
  • Atlas Copco PF6000 SE-10523 Screwdriver Control System
  • Atlas Copco Power MACS TC52S 4240 0442 81 Controller
  • Atlas Copco 1900071162 Operator Interface Panel
  • Atlas Copco 4230-1705-80 I/O Expansion Module
  • Atlas Copco 8433 0005 10 Power Supply Module
  • Atlas Copco 8433-0020-20 Interface Module
  • Atlas Copco TC-4000-S 8435 6500 00 Controller
  • Atlas Copco PF4002-C-HW Power Focus SL Controller
  • Atlas Copco STanalyser STA-6000 8059095560 Torque Analyzer
  • Atlas Copco ComNode 2 Touch 8433271110 Communication Gateway
  • Atlas Copco PF3000-C-HW Tensor S4 S7 RBU Controller
  • Atlas Copco PPBE0613 24VAC Control Panel
  • Atlas Copco PF3000-C-HW Tensor S4 S7 Controller
  • Atlas Copco Neos ARC-D130-S+ Inverter Drive
  • Atlas Copco Power Focus SL PF4002-G-HW Controller
  • Atlas Copco 8436 6770 00 ILT Base Station
  • Atlas Copco 1900520400 Air Compressor Control Panel
  • Atlas Copco 1900-0711-51 Display Keypad Unit
  • Atlas Copco 1900-0710-52 Communication Control Board
  • Atlas Copco 1900-0701-04 Control Interface Module
  • Atlas Copco 8092 1143 40 SRTT Transducer 180Nm
  • Atlas Copco MT Focus 6000 Controller with Pump and Screwdriver
  • Atlas Copco Elektronikon GraphicPlus Controller PPBE0622 PPBE0633
  • Atlas Copco PF3109-G-DN-HW Tensor 8-9 Power Focus Nutrunner Control
  • Atlas Copco Elektronikon P1900520440 Touch Controller
  • Atlas Copco Power Focus 8 Controller 8436280002
  • Atlas Copco 8436 1500 03 FlexCarrier 3-Slot Torque System Component