0% found this document useful (0 votes)
25 views

02 - Linear and Structured Programming

The document discusses linear and structured programming approaches. Linear programming involves placing all code in a main cycle, while structured programming divides code into reusable subprograms/blocks to improve organization, debugging, and maintenance. It also provides guidelines for maximum nesting depths of blocks and structures based on the CPU family.

Uploaded by

Hildis Lisboa
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

02 - Linear and Structured Programming

The document discusses linear and structured programming approaches. Linear programming involves placing all code in a main cycle, while structured programming divides code into reusable subprograms/blocks to improve organization, debugging, and maintenance. It also provides guidelines for maximum nesting depths of blocks and structures based on the CPU family.

Uploaded by

Hildis Lisboa
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Linear and structured programming

Linear and structured programming

Linear programming
Solutions for small automation tasks can be programmed linearly in a program cycle OB.
This is only recommended for simple programs.
The following figure shows a linear program schematically: The "Main" cycle OB contains
the complete user program.

Structured programming
Complex automation tasks can be more easily handled and managed by dividing them into
smaller sub-tasks that correspond to the technological functions of the process or that can
be reused. These sub-tasks are represented in the user program by blocks. Each block is
then an independent section of the user program.
Structuring the program offers the following advantages:
• Extensive programs are easier to program through the structure.
• Individual program sections can be standardized and used repeatedly with changing pa-
rameters.
• Program organization is simplified.
• Changes to the program can be made more easily.
• Debugging is simplified since separate sections can be tested.
• Commissioning is simplified.
The following figure shows a structured program schematically: The "Main" cycle OB calls
subprograms in succession to execute defined subtasks.

-1-
Linear and structured programming

Nesting depth for blocks


The permissible nesting depth for blocks depends on the CPU that is used.
The following table shows the guide values for the maximum nesting depth. For detailed
information on the CPU you are using, refer to the technical specifications in the hardware
documentation. To call the hardware documentation on the Internet, click the links in the
table.

CPU family Nesting depth (guide value) Link to hardware documentation

SIMATIC S7-1500 / ET 200MP Man-


S7-1500 24 blocks per priority class
ual Collection
16 blocks from cycle or startup OB, 6
SIMATIC S7-1200 Automation Sys-
S7-1200 additional blocks within any interrupt
tem
event OB
24 blocks per priority class, 1-2 addi- SIMATIC S7-400 automation system
S7-400
tional blocks within an error OB S7-400 CPU data
16 blocks per priority class, 4 addi- SIMATIC S7-300 CPU 31xC and
S7-300
tional blocks within an error OB CPU 31x: Technical specifications
SIMATIC ET 200SP Manual Collec-
ET 200SP 24 blocks
tion

Nesting depth for structures


Structures (STRUCT) and PLC data types (UDT) can be nested to a depth of 8. This nest-
ing depth is independent of the CPU used.

-2-

You might also like