Overview
1. The Chinese name of FC is “Function”, and the Chinese name of FB is “Function Block” (respectively called “Function” and “Function Block” in the blog)
2. FC and FB are equivalent to subroutines in 200 and 200Smart. The purpose of writing subroutines is to facilitate multiple calls
3. FB is more powerful than FC. There are STAT static variables in FB, but there is no STAT static variable in FC.
Create a new FC and call, simulate
1. Create a new FC: Right-click on the blank space – “Insert New Object” – “Function” – enter and fill in the relevant content – “OK”
2. “Name (N):” only supports filling in the form of “FC+number”, and does not support other symbols including Chinese
3. Click “Details” – you can see information such as symbol name, creation language and type
4. After double-clicking the newly created FC to enter, create various types of local variables (temporary variables) in the “Interface”. Take the start-stop circuit as an example. After the establishment, enter any character in the “??” Temporary variable for selection. L is the storage area for temporary variables. Temporary variables are indicated by adding “#” in front, and the FC subroutine is completed and saved, as shown in the figure below:
Local variables are: L, TEMP (temporary variable) and STAT (static variable);
Global variables are: I, Q, M, V, T (timer), C (counter);
When writing FC and FB, use local variables as much as possible
5. Open OB1 to call FC1, expand “FC block”-drag “FC1 start, stop, stop” to program segments 1 and 2 of OB1
6. After saving, open “Simulation”, download the site to the emulator – “Insert” – “General”, enter MB0 and QB0 respectively
7. Open OB1 and perform simulation, so as to use FC to realize the writing and repeated calling of subroutines
Create a new FB and call, simulate
1. Create a new FB: Right click on the blank space – “Insert New Object” – “Function Block” – enter and fill in the relevant content – “OK”
2. “Name (N):” only supports filling in the form of “FB+number”, and does not support other symbols including Chinese
3. Click “Details” – you can see information such as symbol name, creation language and type
4. After double-clicking the newly created FB to enter, create various types of local variables (temporary variables) in the “Interface”. Take the start-stop circuit as an example. After the establishment, enter any character in the “??” Temporary variable for selection. L is the storage area for temporary variables. Temporary variables are indicated by adding “#” in front, and the FB subroutine is completed and saved, as shown in the figure below:
Local variables are: L, TEMP (temporary variable) and STAT (static variable);
Global variables are: I, Q, M, V, T (timer), C (counter)
When writing FC and FB, use local variables as much as possible
5. Open OB1 to call FB1, expand “FB block” – drag “FB1 start-stop circuit” to the program segment of OB1
There is a background data block DB in the FB, just input DB+value in “???”, and the background data DB of the FB block will be automatically generated
6. Open the background data block DB1, the content inside is automatically generated
7. After saving, open “Simulation”, download the site to the emulator – “Insert” – “General”, enter MB0 and QB0 respectively
8. Open OB1 and perform simulation, so as to use FB to realize the writing and repeated calling of subroutines