
Modular Programming
Modular programming divides complex automation tasks into subtasks corresponding to technical functions in the production process, with each subtask corresponding to a subroutine called a “block”. The program is organized through mutual calls between blocks.
This type of program is easy to modify, debug, and troubleshoot. The block structure significantly increases the organizational transparency, understandability, and maintainability of PLC programs.
OB, FB, and FC are collectively referred to as code blocks, and the called code blocks can nest other code blocks. The nesting depth starts from the program loop OB or startup OB is 16; from the interrupt OB, the nesting depth is 6.

Structured Programming Method
The structured programming method employs object-oriented programming concepts, with the core idea based on the concept of objects, aiming to improve code reusability, modularity, and flexibility.

The framework of structured programming adopts the “four-layer pyramid” method.
Structured Programming “Four-Layer Pyramid” Method
The explanation is as follows:
The top layer is the Control Layer, which spatially divides different control tasks for easier understanding by engineers.
The Process Layer still divides based on space, mainly calling the functions of the lower functional block layer, primarily responsible for writing the logic control of the process.
The Functional Block Layer is mainly a standard program block abstracted based on object instances, serving the upper control layer. If the functional requirements of the object control tasks increase, programming in the functional block is sufficient without needing to adjust the control layer’s program.
The bottom layer is the Object Layer, also known as the Instance Layer, which mainly consists of the underlying hardware. Here, it is essential to classify and categorize the underlying hardware to serve the upper functional block layer in writing standard control programs.