The block structure in the object_pascal _ Siemens SCL _series 3_scl Program

Source: Internet
Author: User
Tags define local

The other day I wrote an article about the Siemens SCL _series 2, which was suspected of advertisement promotion by the system ..........

To be honest, although I am currently engaged in automated industrial control, I am not very interested in this article.ArticleI have no contact with the manufacturers of the links provided in.

There was no connection with me. At that time, I only wanted to introduce the actual nature of industrial control and explain the gap between industrial control in China and foreign countries, there is absolutely no meaning of promotion .........

Hey .......

We will continue to make our journey over the past few days. Today we will briefly describe the structure and key points of FB, FC, and Ob. What we have said is wrong, thank you for choosing ..........

4.4.6 function block FB Structure
Feature block features: the feature block is a function for computing and containsProgramWhen the FB block is called, there must be a data block that is specified to be accessed by the FB,
This data block is the instance data block, also known as the background data block. If the content of the background data block is not changed, the data will not automatically disappear or change. When the FB Interface part (declaration part) is defined,

The data block structure of the FB block instance is determined. Siemens uses the FB Interface part (declaration part) as the template to define the corresponding background data block.
4.4.6.1 function block Declaration/Definition
You can declare/define the FB block using two keywords in the SCL:
1) Program:
2) function_block
Follow the keywords function_block and program to keep up with the keyword FB and keep up with the symbol name of a block number or FB. The block number is a value between 0 and 65533.
The specific definition format is:
Program fbxx
....
End_program

Function_block fbxx
...
End_function_block

Exp:
Function_block Fb1
....
End_function_block

Function_block motor_control
...
End_function_block


Program fb10
...
End_program

4.4.6.2 function block declaration part/Interface part
the FB declaration part is used to define the private data of the FB block. The declaration part should be described in detail according to the declaration part, to improve the
function of the FB block.
the declaration part/Interface part of the FB block determines the structure of the FB instance data block/background data block.
4.4.6.3 FB instance
Exp:

function_block getsqrt
var_input
input: Real: = O. o;
end_var
var_output
root: Real: = 0.0;
retflag: bool;
end_var
begin
If input = 0.0 then
root: = 0.0;
retflag: = true;
elseif input <0.0 then
retflag: = false;
else
root: = SQRT (input);
retflag: = true;
end_if
end_function_block

4.4.6.4 FB block call
To call an FB block, you must specify the corresponding actual parameters for the interface parameters and the corresponding background data block.
Exp:
Getsqrt. db11
(Input := 81.0,
Root: = reroot,
Retflag: = bretflag );

Tip: Pay attention to the format of the background data block when calling FB.

4.4.7 function FC structure (function structure)
A function is a block that implements certain logic functions. When called, you do not need to specify instance data blocks. Compared with FB, function FC can return values.
Function FC blocks can be used in expressions like variables. Functions Defined as void do not return values.
4.4.7.1 define a function
Use the keyword function to define a function,
After the function keyword, you can use the FC keyword as the Function Identifier, followed by a block number or the symbol name of the function,
The block number is the same as that of FB. The value range is 0 ~ 65533
Exp:
Function getsqr: Real
......
End_function

Function fc10: void
....
End_function
Tip:
1) the return value type of a function cannot be struct or array. It can be any other data type.
2) If the return value is not required, the void type is defined.
4.4.7.2 the function is declaration part/Interface part
1) The declaration part of the function is used to declare/define local variables.
2) The declaration part of the function includes input parameters, output parameters, input and output parameters, constants, labels, and zero-hour variables.
4.4.7.3 FCCodePart
1) You must assign a value to the function name in the Code section, that is, the function returns the value through the function name.
2) void functions do not need to return values.
Exp:
Function getsqr: Real
Var_input
In: Real: = 0.0;
End_var

Begin
Getsqr: = In * in;
End_function

4.4.8 structure of organizational Blocks
In the system structure of Siemens plc, ob blocks are equivalent to the interruptions in the computer world (in fact, the first generation of S7 200 PLC uses
Is an Intel 8086 CPU ).
In all ob blocks, there is a special organizational block ob1, which is the entry point of the Siemens S7 300/400 PLC user program,
The user program starts to run from ob1 and ends from ob1.
After executing an ob1 loop, Siemens plc will execute ob1, that is, the ob1 loop until the user
Select from Run Status to stop status.
Other OB will automatically call and execute when the hardware and software are interrupted, which is a bit similar to the situation in the computer.
The organizational block provides interfaces between the operating system and user programs to provide system functions for user programs.
4.4.8.1 definition of organizational Block
The organizational block is defined by the keyword organization,
After the keyword organization, type the keyword ob as the OB identifier, followed by an OB block number, or use
Definition of the symbol name of the OB block. The ob block number is a number between 1 and 65533.
Exp:
Organization_block ob1
...
End_organization_block

Organization alarm
4.4.8.2 organization block Declaration
Ob declaration is used to define local data: temporary variables, constants, and labels.
To ensure the normal operation of the OB block, the declared part of each ob block is the local data that the operating system requires 20 bytes,
Therefore, you must declare an array with identifiers. If you insert an OB block template, these declarations are automatically generated.
Exp:
Organization_block ob1
Var_temp
Header: array [1 .. 20] of byte; // defines the 20 bytes required by the system.
End_var
Begin
Fb13.db13 (V1: = 7 );
End_organization_block

The above content requires a certain degree of basic knowledge of PLC programming to be understood, in which the PLC works cyclically, This is not described, if

For more information, see related books.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.