Step7 program execution principle and programming method - Database & Sql Blog Articles

Programmable Package SG-8018CA(SG7050C) 0.67M~170M
Photocoupler

How is plc's loop program executed. (this point is very important)

1. How to execute the loop program



Siemens plc program execution map (suggested to save)

1.1 After the CPU is powered up, the startup block OB100/101/102 is started once. (Which OB block is called is determined by the system's startup mode configuration)

1.2 After the startup block is executed, the system's cycle monitoring time is activated (this time can be set in the hardware configuration of STEP7, if the cycle time is exceeded, the PLC will stop)

After 1.3, the CPU reads all input states from the input module and other process image devices.

1.4 Then came the execution of the main loop program.

1.4.1 The main loop execution is also executed in the order of the statement. As shown in the figure, when OB1 executes the first statement CallFB, then the program enters the called FB block and executes the statement of the FB block sequentially.

1.4.2 If the CallFB/FC is executed in a certain statement in the called FB block, the program proceeds to the next level of FC to execute the block statement in turn, and so on.

1.4.3 When all the statements of the next level FC are executed, the program returns to the statement of CallFC and continues to execute the following statement.

1.4.4 When the execution of the FB of the Call is completed, the program returns to the CallFB of OB1 and continues to execute the following statement.

1.4.5 Until the end, complete all the procedures of OB1, the main loop ends.

1.4.6 During the execution of OB1, cyclic interrupts (such as OB35) and fault interrupts (such as OB86) can be inserted and executed. After the execution is completed, it will return to the interrupted place to continue the execution of the main loop.

After the main loop execution is completed, the PLC writes the output of the process image to the output module.

1.6 After completing the steps of 1.5, a complete cycle is over. At this point, skip to step 1.2 and restart the monitoring time of the new cycle.

2. Block type

After knowing how to execute the PLC cycle program, let's take a look at the types of STEP7 blocks.

2.1 user block

User blocks include program code and user data. In a structured program, some blocks are called cyclically, and some blocks are called when needed.



2.1.1 Organization Block

The OB block forms the interface between the S7CPU and the user program. All programs can be stored in OB1, allowing it to be continuously cycled. It is also possible to place the program in different blocks and call them with OB1 when needed. In addition to OB1. The operating system can call other OB blocks according to different events, for example:

2.1.1.1 Time-date interrupt

2.1.1.2 Cycle time interruption

2.1.1.3 Diagnostic interrupt

2.1.1.4 Hardware interrupt

2.1.1.5 Troubleshooting

2.1.1.6 Hardware boot

2.1.2 Function Block (FB)

A function block is a function or group of functions within a logical operation block in which memory is allocated and variables are stored. The FB requires an auxiliary memory in the form of an instance data block. Parameters are passed through the instance data block, and some local parameters are also saved in this area. Other temporary variables exist in the local stack. The data stored in the instance DB is retained when the function block is closed. Data saved in the local stack cannot be saved.

2.1.3 function (FC)

A function is a logical operation block similar to a function block, but no memory area is allocated therein. The FC does not require an instance DB. Temporary variables are kept in the local stack until the end of the function. When the FC execution ends, the variables used are lost.

2.1.4 Data Block (DB)

A data block is a permanently allocated area that holds data or information about other functions. The data block is a readable/writable area and is transferred to the CPU as part of the user program.

2.2 system block

System blocks are predefined functions and function blocks in the CPU operating system. These blocks do not occupy user program space. The user program calls the system block, which has the same interface, the same label and the same number throughout the system. User programs can be easily converted to different CPUs or PLCs.



2.2.1 System Function Block (SFC)

The system function is a function that has been programmed and debugged in the S7CPU. Some of the tasks supported by these blocks are setting module parameters, data communication and copy functions. The user program can call the SFC directly without loading. SFC does not need to allocate data blocks.

2.2.2 System Function Block (SFB)

The system function block is an integrated function of the S7CPU. Since the SFB is part of the operating system, the user program can call the SFB directly without loading. The SFB needs to allocate the instance DB, which must be downloaded to the CPU as part of the user program.

2.2.3 System Data Block (SDB)

The system data block is a program memory area generated by different STEP7 tools, which contains the necessary data for operating the controller. There is some information in the SDB, such as configuration data, communication connections and parameters.

3. Programming method

I have a general understanding of how a loop of the PLC program is executed, and understand the types of blocks in the program. Let's look at the programming methods to organize these blocks.

Every Siemens programmer has his own programming habits and methods. STEP7 provides three methods for designing a program. Based on these methods, you can choose the programming method that works best for your application.

3.1 linear programming

All programs are in one continuous block of instructions. This structure is similar to a fixed-wired relay circuit that is replaced by a PLC. The system processes the individual instructions in order.

3.2 modular programming

The program is divided into different blocks, each block containing logic instructions for some devices and tasks. The instructions in the organization block determine whether to call the relevant control program module. For example, a module program contains various modes of operation for a controlled process.

3.3 Structured Programming

The structured program contains user-defined instruction blocks with parameters. These blocks can be designed to be called in general. The actual parameters (input and output addresses) are assigned at the time of the call.

Laptop Stand with Cooling Fan


The Laptop Stand is completely height adjustable and has six different elevations levels. Aluminum Laptop Cooling Stand is 17 inches wide, which offers plenty of room for your smartphone ,a notebook. Laptop Stand Aluminum Adjustable can find the best viewing angle. The Ergonomic Aluminum Laptop Stand is made of aluminum and comes in black or silver gray, making it an awesome match for Apple`s notebook. Laptop Stands And Risers also features an open-wedge design for better airflow.

Laptop Stand is simple and portable, understand what you need, say goodbye to a single support method, care for your health, and multiple choices. Detachable Laptop Stand is gear support, straight spine, refuse to lower your head, work more efficiently.


Laptop Stand Keyboard is front and back support, turn on the "desktop mode", a large field of view, to bring you a more comfortable viewing angle experience. Laptop Stand Upright six-speed adjustment is just right.


Shenzhen Chengrong Technology Co.ltd is a high-quality enterprise specializing in metal stamping and CNC production for 12 years. The company mainly aims at the R&D, production and sales of Notebook Laptop Stands and Mobile Phone Stands. From the mold design and processing to machining and product surface oxidation, spraying treatment etc ,integration can fully meet the various processing needs of customers. Have a complete and scientific quality management system, strength and product quality are recognized and trusted by the industry, to meet changing economic and social needs .


Sturdy Laptop Stand

Ergonomic Aluminum Laptop Stand,Ergonomic Portable Laptop Stand For Desk,Adjustable Aluminum Ergonomic Laptop Stand,Ergonomic Aluminum Desk Notebook Holder

Shenzhen ChengRong Technology Co.,Ltd. , https://www.dglaptopstandsupplier.com