FB--function block with instance data block
FC--function, equivalent to function
The main difference between them is that FC uses shared data blocks and FB uses background data blocks.
For example, if you want to control three motors with the same parameters, you only need to use FB programming plus 3 instance data blocks. However, if you use FC, you need to constantly modify the shared data block. Otherwise it will result in data loss. The FB ensures that the parameters of the three motors do not interfere with each other.
FB, FC are essentially the same, are equivalent to subroutines, can be called by other programs (can also call other subroutines). The biggest difference between them is that FB works with DB, and the data stored by FB is stored in DB, even if FB exits. FC does not have a permanent block of data to store data, only a temporary data area is allocated during runtime. In actual programming, whether to use FB or FC depends on the actual needs. The benefits of FB are very good upstairs.
FB and FC are not much different, FB has background data blocks, and FC does not. So FB with different data blocks, you can bring different parameter values. This allows you to be called by multiple objects using the same FB and different instance data blocks.
FC and FB are functions in C, except that FB can generate static variables. The data can be retained in the next function call, while the FC variable is valid only during the calling period, and the next call is replaced again.
What is the difference between FB and FC in S7-300plc? FB has its own background DB and FC does not have its own background DB. What is the difference between FC and FB? They can implement the control function. In the end, should FB be used with FC, and when should FB be used?
FB and FC are not much different, FB has background data blocks, and FC does not. So FB with different data blocks, you can bring different parameter values. This allows you to be called by multiple objects using the same FB and different instance data blocks.
FC and FB are functions in C, except that FB can generate static variables. The data can be retained in the next function call, while the FC variable is valid only during the calling period, and the next call is replaced again. Every time you call the I/O area of ​​the FC, you must manually input it each time, but the FB is not needed, which saves a lot of trouble. If you input the DB control address directly in the host computer control.
For example, there are 50 motors that need to be controlled. These motors have the same control flow except for the parameters.
The motor needs different parameters to run, and the running process parameters are involved in the next control process.
This requirement, if you use FC, you need to allocate DB blocks for different motors to confirm the parameter address one by one.
Confusion, save and call can't go wrong, you can imagine how much trouble. What if you use FB? Write the control process and the defined parameters
The number of calls is fine. Repeat the same FB for the motor, each time you specify a separate DB as the instance data block
I don't have to worry about how the data in the background DB is stored. If the function needs to be modified, just modify the FB.
There are other examples, such as PID, such as traffic accumulation and so on.
Fc is equivalent to the assembly line, and the processing is over! There are no records. Fb+db can not only process, but also record data.
When there are usually multiple devices, we write an fb and then call it multiple times to automatically generate the corresponding db, which simplifies us.
work.
The variable declaration table of the FB has static variables, and can perform multi-level parameter transfer, so the background data block needs to be generated when calling the FB.
FC does not have these .FBs can replace FC, but not vice versa.
Multi-level parameter passing is called MULTIINSTANCE. You can call FB and DB as functions in another FB.
For example, the parameters in FB1 can be used in FB2, and only one instance data block is finally generated.
Zane:
FB doesn't actually take up too much resources, because a program always has these variables, whether global or local.
I am using a lot of FBs now. FC is only used to program some logic, simple subroutines, or just a few CALL instruction calls.
FB. The use of FB and local variables is more conducive to the modularization of the program, increasing the portability of the program, just like the FB provided by Siemens.
Piece.
In fact, the fundamental difference between FB and FC is that FB supports static variables, while FC only supports temporary variables.
Static variable: When the FB is called back, the variable area is still reserved for the FB, so the data value of this area is not changed. Pro
Time variables do not have such characteristics.
Therefore, if you write the determined data in the temporary data variable in the FC, you may have unpredictable results when you read it.
, but not for static variables, because it will retain the results of your last write.
Wanquanhe:
The control program we compiled, FB is rarely used. It is rare to say that the use of FB instead of FC is practical. Who used to
FC all use up? I am afraid that the system can not afford it.
Among the standard libraries provided, FB is quite a lot.
If the function you are going to compile does not use static variables, I am afraid there is no need to use FB? I see high-level language, although static
Variables are easy to use, but they are rarely used.
Knight: I have the same view as Zane. In my work, I also compiled the same function into FB, and then called it in FC.
The order is easy to modify, for example: if you have 10 motors, we usually have to start the startup, stop the logic, report
Police, reset logic. If I compile an FB to do all of this logic, assign a background block to each motor.
When I call these motors in FC, I just need to add the corresponding I/O points of these motors to the FB pins.
Consider the logic inside him. If you use FC to compile these logics, you have to write 10 times, 2, if you use paste
And if you copy, there may be some I/O points forgoing modification or some other errors. 3. The program is not structurally strong and is wasted to maintain.
time.
Therefore, the combination of FB and FC is the most convenient.
I suggest you try FB. When you understand FB, you will be pleasantly surprised.
Zane: Regarding the use of FB and FC, I also came to know it step by step in the specific application, but this is only my personal
The views and experience, did not say that must be used in this way, you can make different attempts. But one thing is certain, that is
Before you start the handwriting process, you must have a good plan for the entire project in advance.
Programs that look at foreigners are usually programmed directly in FC, while domestic ones are programmed in FB and then called in FC. These two
What are the advantages and disadvantages of each method?
With the task that FC can achieve, there is no need to use FB.
FCFB is essentially the same
Calling FB is equivalent to opndi in FC and using ar2 to index variables
The advantage of FB is that the variables in the data block can be used by name, just display, and the execution efficiency is the same as fc.
supplement:
In fact, FC is more flexible. In fc, you can call opndi multiple times to access multiple background blocks. ar2 can also be used for multiple purposes.
In fact, ar2 in fb can not be used in principle, calling fb also specifies the data block, trouble
Supplement 2:
FB is actually a magic to play in the programming environment.
The program instructions of the PLC actually have no difference between FB and FC.
Calling FB or FC is ultimately a call instruction that is converted to UC or CC.
To observe this magic in the programming environment, just write a program with a parameter (FB or FC) and call it in another block, all
After downloading, change the parameter interface of the subroutine and download the subroutine.
(At this point, the calling instruction of the calling block is invalid), and then upload the calling block.
1, generally use FB to write some commonly used control programs, such as valve pump control, etc., in the interface stat variable can define some valve opening degree preset value (not through the input, directly controllable on hmi), And the fault signal of the scene can be written into the stat variable and sent directly to the HMI.
2, and FC generally calls these FBs, giving some input and output.
3, all input and output of FC must be assigned, and FB only needs to give the background data block.
4, of course, if I do not need the value of the process, then FC is good, simple.
If you have a little understanding of computer programming, I think it can be understood like this:
1, FC "program" in the program, directly called, for process programming;
2, FB is like a "class", with interfaces, properties and methods for programming "control objects", while FB DB is like a concrete "control object" instance.
OBD Connector Section.
OBD:On Board Diagnostics.
One is to connect to the OBD interface of the vehicle through a special data line. Reading out the data and displaying it on the matching display screen is basically equivalent to adding a driving computer display screen. At ordinary times, the connecting cable can be plugged into the OBD interface all the time without removing it, and only the fixed display screen is needed. The owner can choose the data to be displayed by himself
OBD Connector Section
ShenZhen Antenk Electronics Co,Ltd , https://www.antenkelec.com