Skip to content

02 Controller software and structure

mgledhill edited this page Oct 10, 2024 · 7 revisions

PAL Logo showing Wiki Documentation heading

2.   The controller software and structure

The PAL software is intended to run within the S7-1500 and S7-1200 ranges of Siemens Simatic Controllers, as such the PAL software must be compatible with the internal structures present within these Controllers.

The S7-1500 and S7-1200 ranges of Controllers both operate in the same manner and (largely) support the same software modules, software commands and have the identical operating structures within them.

The S7-1200 is restricted in terms of capacity (it supports fewer blocks in total and is restricted in terms of the amount of IO modules that can be connected to it), and is also restricted in terms of the programming languages supported, the S7-1200 does not support the statement list (STL1) programming language; however, STL will not be used by the PAL software, All PAL software is written using ladder logic2.

Other restrictions apply to the S7-1200, the amount of data that can be transmitted over communications networks is limited (for example) and this has some impact on certain software modules, where such restrictions exist, this is explained in the relevant Software Module Design Specification (SMDS) for that module.

The following sections explains the pertinent points of the Controller software, its underlying structures and how these structures are adapted to the PAL software modules.

All the software developed as part of the PAL is developed using the Siemens Simatic programming environment: TIA Portal Professional, Version 16 or later.

Note

1 STL or statement list is a text-based programming language similar to assembler language.
2 Ladder logic is a graphical programming language widely used to programme Controllers and PLCs.

⬆️ Top

2.1.       Internal structure of the Controllers

All software within a Siemens controller is written in blocks (effectively each block is a software module of some description). These blocks are split into program blocks (that hold executable software code) and data storage blocks (that hold information: numbers, strings, arrays &c.). Examining each in turn:

⬆️ Top

2.1.1       Programmable blocks

The Simatic controllers are programmed using blocks of different types, there are three programmable (blocks that contain software instructions) block types:

  1. Organisation block (OB) Interrupt driven block called in response to a specific event detected by the Controller operating system

  2. Function (FC) A subroutine (with or without parameters) used to structure the software or handle recurring or complex functions

  3. Function block (FB) Similar to an FC but with an allocated retentive data area

All these blocks are user blocks; i.e. they are blocks that the user can programme, configure and edit. These blocks are used to subdivide the controller programme into smaller, self-contained modules that perform specific aspects of the programme (e.g. controlling emergency stops, handling communications, operating a valve &c.).

⬆️ Top

Organisation blocks (OBs)

Organisation blocks (OBs) serve as the interface between the Controller operating system and the user programme; OB 1, for example, the main organisation block is called at the start of every Controller cycle and is the only user block that the Controller will execute automatically (all other user blocks must be called by elements within the user programme).

Other OBs are called in response to certain events: hardware interrupts, timed interrupts, Controller faults &c. and are given specific numbers, these are discussed in detail in § xxx.

⬆️ Top

Functions (FCs)

Functions (FCs) are used to subdivide a programme into meaningful sections or are used to handle frequently recurring or complex functions; a typical example would be to have a FC that control a specific device (a valve for example) and then repeatedly call this FC for each such device in the system.

Using FCs to divide a programme into meaningful sections is common practice and makes for better structuring of the software; allowing the software to be more easily navigated and faults to be readily identified.

This subdivision of the Controller programme will be widely applied within the PAL and will have the prescribed structure detailed in Section xxx.

FCs will form the vast majority of blocks within the PAL.

⬆️ Top

Function blocks (FBs)

Function blocks are a special version of functions that are automatically assigned a data block within which they can store function block specific data.

In practice, FBs are not used in the PAL. However, where third-party software is required (to interface to specific equipment) these are often provided as FBs and their use is permitted.

The PAL does not restrict the use of FBs in any way, it simply does not require any itself for the library modules within it.

⬆️ Top

2.1.2       Data storage blocks

The Simatic controllers use data blocks (DBs) to store data for the user programme.

Data blocks support all the standard data types available to the controller: Booleans, integers, bytes, floating point numbers, strings &c. In addition, DBs can be configured using user created data structures, these data structures are referred to as User Data Types (UDTs).

Both DBs and UDTs are discussed in the following sections:

⬆️ Top

Data blocks (DBs)

DBs are configurable by the user, but do not contain programming instructions (unlike the programmable blocks of the previous section), they hold data specified by the users (variables, constants, working values &c). The data stored in a DB can be anything and of any supported type (Booleans, integers, byte, floating point numbers, strings &c.). The structure and configuration of a DB is entirely at the discretion of the user; DBs are a very flexible and convenient mechanism for storing user information.

⬆️ Top

Instance data blocks (iDBs)

Instance data blocks are a used by function blocks (FBs) as retentive data storage areas. These preserve data between successive calls of the block and are a requirement when using function blocks. Each call of a function block requires its own iDB.

User data types (UDTs)

The PAL will rely heavily on the use of data structures to pass information between modules. UDTs are used to define the internal structure of DBs and can be passed as parameters into functions (FCs) and function blocks (FBs). Within the Siemens Controller these data structures are variously called User Defined Data Types or User Data Types or PLC Data Types.

These terms are interchangeable, all meaning a data structure (a collection of named variables made up of standard data types, grouped together in a named structure). The original name (predating TIA Portal) was User Defined Data Type (UDT), with the advent of TIA Portal this became either a User Data Type (again UDT) or PLC Data Type (PDT). They all mean the same thing (a data structure).

For clarity, the term UDT (User Data Type) is used to specify a user defined data structure (or any of the other names it uses) throughout this and other project documentation.

⬆️ Top

2.1.3       Built-in system blocks

The Simatic Controllers and the TIA Portal programming environment have built-in system blocks that perform specific functions (for example, a PID control loop,), these blocks will always be used in preference to developing a new block with similar functionality.

These built-in system blocks are pre-configured functions (FCs) and function blocks (FBs) written and issued by Siemens. They are given numbers in the reserved numbering range 1-999 (this range being reserved for third-party software and special software. It is is not occupied by any of the PAL modules).

Where system function blocks are used, these, like all FBs, require an instance DB; these function blocks will generally be contained (called from) within a standard module, and this standard module will always be a function FC, this standard module can be considered a wrapper for the system function block. To accommodate the need for an instance DB required by the contained system function block, the instance DB to be used will be passed as a parameter to the standard function.

Some system blocks have their own system data structures (referred to as system data types), these are similar to UDTs but are predefined within the TIA Portal programming environment, where such system data types are required, they will be installed and issued as part of the PAL software.

⬆️ Top

2.1.4       Block numbering and quantities

The number of blocks that can be used in a Controller program is entirely dependent on the processor running that programme. The pertinent values are shown here:

CPU 1511 1513 1515 1516 1517 1518
Part No. 6ES7511-
1AK01-0AB0
6ES7513-
AL01-0AB0
6ES7515-
2AM02-0AB0
6ES7516-
3AN01-0AB0
6ES7517-
AP00-0AB0
6ES7518-
4AP00-0AB0
Total No.
of Blocks
2000 2000 6000 6000 10000 10000
No. of
FCs
2000 2000 6000 6000 10000 10000
FC No.
Range
1-65535 1-65535 1-65535 1-65535 1-65535 1-65535
No. of
FBs
2000 2000 6000 6000 10000 10000
FB No.
Range
1-65535 1-65535 1-65535 1-65535 1-65535 1-65535
No. of
DBs
2000 2000 6000 6000 10000 10000
DB No.
Range
1-59999 1-59999 1-59999 1-59999 1-59999 1-59999
Table 2.1 — Block number and quantities for the S7-1500 series of processors
CPU 1211C 1212C 1214C 1215C 1217C
Part No. 6ES7211-
0AE40-0XB0
6ES7212-
1AE40-0XB0
6ES7214-
1AG40-0XB0
6ES7215-
1AG40-0XB0
6ES7217-
1AG40-0XB0
Total No.
of Blocks
1024 1024 1024 1024 1024
No. of
FCs
1024 1024 1024 1024 1024
FC No.
Range
1-65535 1-65535 1-65535 1-65535 1-65535
No. of
FBs
1024 1024 1024 1024 1024
FB No.
Range
1-65535 1-65535 1-65535 1-65535 1-65535
No. of
DBs
1024 1024 1024 1024 1024
DB No.
Range
1-59999 1-59999 1-59999 1-59999 1-59999
Table 2.2 — Block number and quantities for the S7-1200 series of processors

All S7-1500 CPUs support at least two thousand blocks and this is more than sufficient for virtually any application.

The S7-1200 CPUs all support a maximum of 1024 blocks, this is a practical amount for the simpler type of application at which the S7-1200 CPUs are targeted.

The Practical Series Automation Library is designed to fit in the smallest of the S7-1500 CPUs; the library itself will also fit in the S7-1200 CPUs, but number and complexity of the application modules is constrained by the restrictions of the S7-1200 range.

Irrespective of the CPU (and irrespective of the range, i.e. S7-1500 or S7-1200), the range of numbers that can be assigned to a given block are the same (i.e. any CPU can have a function block with the number in the range 1-65535, only the total number of blocks is limited, not the numbers that can be assigned to them).

The PAL will use this capability to assign meaningful number ranges across all CPUs and Controller ranges:

BLOCK TYPE PERMISSIBLE NUMBER RANGE PAL NUMBER RANGE IN USE
FB, FC 1-65535 1-60999
(61000 onwards reserved for doc modules)
DB 1-59999 1-59999
OB 1-32767 (not inclusive) 1-122
Table 2.3 — Block number ranges

Organisation blocks typically have predefined (default) numbers, depending on function, in the range 1 122. It is possible to re-allocate these numbers anywhere in the range 123-32767; however, the PAL will only use the default (automatically assigned) numbers.

The permissible number range of FBs and FCs is wider than that for DBs. The PAL will use block numbers to denote particular functions; these numbers need to be applied to both programmable blocks (FBs and FCs) and data blocks (DBs). To ensure that all block types can be allocated the same range of numbers, the PAL will only use block numbers in the range 1-59999 for standard and application blocks (obviously, not every number in this range is used). Template modules extend outside this range (up to 60999), however, template modules that give examples of the application modules are in the range 1-59999. The range 60000-60999 is used for template modules that give examples of specific organisation block usage.

The range 61000-65535 is used by the PAL to store the example documentation modules.

These number ranges have been split further to allocate different number ranges to the different block and data block functions within the PAL. The PAL will use the following number ranges for the specified module classifications:

NUMBER RANGE FC/FB USAGE ABBREVIATION DB/UDT USAGE
00001-19999 Standard modules Std Static data storage
20001-39999 Application modules App Dynamic data storage
40001-59999 Template modules (application) Temp N/A
60001-60999 Template modules (interrupts) Temp N/A
61001-65535 Document modules Doc N/A
Table 2.4 — Block and number allocations for the PAL



Wiki contents           

Previous page Previous chapter Home Next chapter Next page

     Casenotes

   The licences and other details

       The Licence
       Why did I choose the MIT Licence?
       Permissive licences
       Copyleft licence
       Limiting liabilities
       Which licence to use?
       A note on spelling

1. Introducing the PAL

   1.1.      The approach taken
   1.1.1     The structure of the software
   1.1.2     The standard modules
   1.1.3     The user interface
   1.1.4     Templates and documentation
         Template modules
         Documentation modules
   1.2.      Background to the Project
   1.3.      Regulations and standards
   1.4.      Assumptions and limitations

2. The controller software and structure

   2.1.      Internal structure of the Controllers
   2.1.1     Programmable blocks
         Organisation blocks (OBs)
         Functions (FCs)
         Function blocks (FBs)
   2.1.2     Data storage blocks
         Data blocks (DBs)
         Instance data blocks (iDBs)
         User data types (UDTs)
   2.1.3     Built-in system blocks
   2.1.4     Block numbering and quantities
   2.2.      Execution of Controller software
   2.2.1     Cyclic programme execution

90.  How to build a GitHub Wiki

   90.1.    What are GitHub Wiki pages?
   90.2.    Understanding the Wiki pages
   90.3.    Creating a Wiki for a repository
   90.4.    Cloning a Wiki to a local machine
   90.5.    Basic components of a Wiki
   90.5.1   Title bar and revision
   90.5.2   Contents area
   90.5.3   Listing pages in the order you want
   90.6.    Sidebars and footers
   90.6.1   What are sidebars and footers?
   90.6.2   Create a sidebar or footer in GitHub
   90.6.3   Create a sidebar or footer locally

91.  Imposing a folder structure on a Wiki

   91.1.    The default arrangement
   91.2.    A practical Wiki folder structure
   91.2.1   Page Numbering in the Wiki
   91.2.2   Rules for page numbering
   91.2.2   Subfolder names for Wiki pages
   91.2.3   Page names for Wiki pages
   91.2.4   Storing images and other data

92.  Markdown, GitHub Markdown and HTML

         A note by the Author
         Some useful Markdown sites
   92.1.    An overview of Markdown
   92.2.    How Markdown works
   92.3.    Markdown flavours
   92.3.1   GitHub Flavoured Markdown (GFM)
   92.4.    HTML and Markdown
   92.4.1   HTML with GitHub Markdown
         GFM Blacklisted HTML tags
         GFM Whitelisted HTML tags
         GFM HTML tags — the grey area
         GFM whitelisted HTML attributes
   92.5.    PracticalSeries Markdown

99.  Template
⬇️ End of page
Clone this wiki locally