News Center
The difference between function blocks FC and FB in Siemens PLC
- Categorize:Industry Information
- Author:China Industrial control network
- Source:China Industrial control network
- Release time:2023-09-12
- pageviews:0
Summary
The difference between function blocks FC and FB in Siemens PLC
Summary
- Categorize:Industry Information
- Author:China Industrial control network
- Source:China Industrial control network
- Release time:2023-09-12
- pageviews:0
0ne. Differences between FB and FC
1. FB function block, with background data block FC -- function, equivalent to function;
2, FB, FC block is equivalent to a subroutine, can call other FB, FC block, can also be called by OB, FB, FC block;
Two, the main difference between FB and FC
1. FB uses background data block as the storage area, FC has no independent storage area, and uses global DB or M area;
2. FB local variables include STAT and TEMP. FC does not have STAT because it does not have its own storage area, and TEMP itself cannot be set to an initial value.
Note: In essence, the purpose of FB and FC is the same, no matter what kind of logic requirements, FB and FC can be realized, but the efficiency of the implementation is different, which is also related to the personal programming habits of engineers.
Three, FB block advantages
1, easy portability, for the controlled object with different parameters of the same control logic, as long as different background DB is used, the same FB block can be convenient;
2, multiple backgrounds, reduce duplication of work, improve efficiency;
3, multiple calls, parameter modification is convenient;
4, there is an independent storage area;
Four, the advantages of FC block
1, small and flexible, it is easier to understand the program that is not called many times;
2, do not occupy additional storage resources;
Five, FB, FC piece pin definition
1, IN - the variable is an external input, can only be read by this block, can not be written by this block;
2, OUT - is the output of this program block, he can be read and written by this program block, other programs through the pin can only read the value can not be written;
3, IN_OUT - input and output variables this program block and other programs can read and write the value of this pin;
4, TEMP - temporary variable, as the name suggests is a temporary storage of data variables, these temporary data stored in the CPU working storage area of the local data stack (L stack);
5, STAT - is always stored during the operation of PLC, S7 defines static variables in the background data block (only for FB, FC and OB have no static variables), when the called block is running, can read or modify static variables, after the called block is over, static variables are retained in the data block;
Six, why the definition of FB, FC block, after repeated calls the program confusion?
For a program block that is called multiple times, FB block is recommended to call a different background DB, and FC block needs to ensure that the storage address used is not repeated, that is, the address called in the block is not repeated every time.
Seven, why the FB or FC with timer or counter is called ok once, and the timer or counter is confused when it is called multiple times?
For multiple calls of FB or FC, such as S7 TIMER and Counter, it is necessary to define timer or counter IN the IN interface. For each call of FB or FC, a different timer or counter number is assigned. For each call of IEC timer and counter, Block_DB needs to be defined in the IN interface. Each DB block is assigned to an IEC timer or counter;
Eight, temporary variables to cause trouble
Temporary variables can be used in the organization OB, function FC and function block FB. When the block is executed, they are used to temporarily store data. Once the block is executed, the address of the stack will be reassigned to other blocks and the data on this address will not be cleared to zero until it is given a new value by other blocks.
Nine, there are several common circumstances that lead to the abnormal operation of the program
1, a block program runs good and bad, in which one or more values are occasionally abnormal. The problem is that the "assign first, use again" must be followed; otherwise, the value of TEMP is not clearly assigned at the beginning of each scan period, and the value of this address will be random.
2, multiple blocks use TEMP, any one is normal when used alone, and cannot be used together. The problem is that the value of TEMP in block 1 is not cleared to zero, but the CPU operation mechanism calls this address to use or directly allocates it to block 2, resulting in this TEMP address is not 0, so the program is confused, because the memory operation mechanism is not open, so the allocation process seems to be random. This may lead to the normal operation of the program for many times, and problems after running for a period of time, as long as the principle of "first assignment, then use" is followed, it can be avoided;
3. TEMP cannot realize self-locking. The problem is that the TEMP value cannot maintain the value of the previous period like point M or point Q. TEMP needs a clear assignment in each scan period, that is, assignment (write) before use (read and write). To solve the problem, FB can use STAT static variable, and FC can use M area or global DB address.
Popular news
Advantages and disadvantages of modules
Wide application of modules
Advantages and disadvantages of touch screen
Page Copyright © 2024 Fuzhou Zhuokai Electronic Technology Co., Ltd All rights reserved. 闽ICP备17019029号-2 Powered by saa
© 2024 Fuzhou Zhuokai Electronic Technology Co., Ltd