Table of contents
Programming Guideline for S7-1200/1500
Entry-ID: 81318674, V1.2, 03/2014
3
Siemens AG 2014 All rights reserved
Table of contents
Warranty and liability ................................................................................................... 2
1 Preface ................................................................................................................ 5
2 S7-1200/1500 Innovations ................................................................................. 6
2.1 Introduction ........................................................................................... 6
2.2 Terms ................................................................................................... 6
2.3 Programming languages ...................................................................... 8
2.4 Optimized machine code ...................................................................... 8
2.5 Block creation ....................................................................................... 9
2.6 Optimized blocks ................................................................................ 10
2.6.1 S7-1200: Setup of optimized blocks ................................................... 10
2.6.2 S7-1500: Setup of optimized blocks ................................................... 11
2.6.3 Best possible data storage in the processor on S7-1500 .................. 12
2.6.4 Conversion between optimized and non-optimized tags ................... 15
2.6.5 Communication with optimized data .................................................. 16
2.7 Block sizes ......................................................................................... 17
2.8 New data types for S7-1200/1500 ...................................................... 17
2.8.1 Elementary data types ........................................................................ 17
2.8.2 Date_Time_Long data type ................................................................ 18
2.8.3 VARIANT data type ............................................................................ 18
2.9 Instructions ......................................................................................... 20
2.9.1 CALCULATE ...................................................................................... 20
2.9.2 MOVE instructions .............................................................................. 20
2.9.3 RUNTIME ........................................................................................... 21
2.10 Symbolic and comments .................................................................... 22
2.11 System constants ............................................................................... 23
2.12 Internal reference ID for controller and HMI tags ............................... 24
2.13 STOP mode in the event of errors ..................................................... 25
3 General Programming ..................................................................................... 27
3.1 Operating system and user program .................................................. 27
3.2 Program blocks .................................................................................. 27
3.2.1 Organization blocks (OB) ................................................................... 28
3.2.2 Functions (FC) .................................................................................... 30
3.2.3 Function blocks (FB) .......................................................................... 32
3.2.4 Instances ............................................................................................ 33
3.2.5 Multi-instances ................................................................................... 33
3.2.6 Global data blocks (DB) ..................................................................... 35
3.2.7 Downloading without reinitialization ................................................... 36
3.2.8 Reusability of blocks ........................................................................... 39
3.3 Block interface types .......................................................................... 40
3.3.1 Call-by-value with In interface type .................................................... 40
3.3.2 Call-by-reference with InOut interface type ........................................ 41
3.4 Storage concept ................................................................................. 41
3.4.1 Block interfaces as data exchange .................................................... 41
3.4.2 Global memory ................................................................................... 42
3.4.3 Local memory ..................................................................................... 43
3.4.4 Access speed of memory areas ......................................................... 44
3.5 Retentivity ........................................................................................... 45
3.6 Symbolic addressing .......................................................................... 47
3.6.1 Symbolic instead of absolute addressing ........................................... 47
3.6.2 ARRAY data type and indirect field accesses .................................... 49
3.6.3 STRUCT data type and PLC data types ............................................ 51
3.6.4 Access to I/O areas with PLC data types ........................................... 52
3.6.5 Slice access ....................................................................................... 53