Object_pascal _ Siemens! Block _ 1 in series 2_scl

Source: Internet
Author: User
Tags printable characters

Ah, now I really want to learn, but I don't have time.

Thanks to the Administrator for not deleting the previous articleArticle. Therefore, in order to fulfill my commitment, we will continue the journey of the SCL .....

One point to be declared here: this series, that is, the Siemens SCL application, is an article. You are welcome to repost and correct it, but please be sure to apply it for any commercial purpose. Write in blog

The article is for sharing and communication, not for commercial purposes. Therefore, please use this series of articles for any commercial purposes.

If you don't need to worry about it, let's start this issue of the SCL Journey:

The last course introduced the definition of the beginning and end of the block, and also the definition of the start of the block. Today, we will continue to describe the relevant content of the block:

4.4.1 block name
As described in the article in Series 1, xx_name is used as the block name. refer to the following syntax:

Block keyword number
Db fb fc ob UDT n
Identifier
Symbol

The number can be a value between 0 and 65535, but the data block identifier db0 is retained and cannot be defined or used by the user.
If you use a symbolic name, you must define an identifier or symbolic name for the block in Step 7.
Exp:
Function Block
Function_block fb10 // define with block keywords
...
End_function_block

Function_block cotroll_block // define with an identifier
...
End_function_block

Function_block "control block" // use global symbols for definition
...
End_function_block

Here we need to note that the block is globally visible using block keywords and global symbols.

4.4.2 block attributes
Block attributes are available in the following parts:
1) block type
2) version of the block
3) block protection features
4) the creator of the block
5) block name
6) series names of blocks: usually used for quick search
As listed below:
Keyword-Applied Instance
Title = 'printable characters' block Title = 'sort'
It is usually used to describe the Block Function

Version: 'Number. digit 'version Number of the specified block: '3. 01 '
tip: The version attribute of the data block is not/DB
you must set version: 3.01 in quotation marks

know_how_protect block protection attribute; blocks with this option, such as know_how_protect
, are compiled into STL statements and Source Code is deleted
. show Editor
open

The name of the author of author, mainly used to reflect an author: Siemens
Related information of some authors

Name block name, used to specify the open name: PID

Name of the Family block series, such as a motor, used for family: volcanol
Save the block category.

Rules for using block attributes:
1. After the block definition starts, use keywords to directly define the block attributes.
2. The identifier can contain a maximum of 8 characters.

Exp:
Function_block "start_motor"
Title = Motor Start Control Function Block '// This title will appear in the comment column of Step 7 Resource Management
Version = '0. 01'
Know_how_protect
Author: volcnol
Name: startm
Family:

4.4.3 block comments
The comments of Siemens SCL are compatible with Object Pascal comments, and the attributes defined by title are
The editor appears in the comment of the block.
Usage:
// Annotation

As shown above:
// This title will appear in the comment column of the resource manager in Step 7.
Title = 'Motor Start Control Function Block'

4.4.4 Declaration
Since the SCL and PASCAL languages are similar, and FC is a function block, the function declaration
Some of them exist in the same way in the SCL.
Block declaration is used to declare local (local) variables, parameters, constants, and labels.
The declaration follows the following rules:
1) the scope of local variables, parameters, constants, and labels defined in the Declaration part of the Logical Block is only valid within the block.
2) to define a globally valid variable or storage area, it must be defined in the data block dB.
3) UDT only provides a suitable data type. If you do not need UDT to define user variables, UDT is unavailable.

declaration part structure:
the declaration part defines different subareas with different keywords. each subarea contains the declaration of the same type of variables or data, subarea
the sequence is not defined and can be arranged freely.
1) constant declaration area
Keyword:
const
declaration list
end_const
the constant area is used to declare constants, it is equivalent to the const variable in C language.
Exp:
const
Number: = 10;
timeofday1: = time # 1d_1h_10m_22s_2ms;
name: = 'siemens ';
number2: = 2*5 + 10*4;
Number3: = 3 + number2;
end_const
the compiler automatically checks the constant data type based on the data type.

2) label
the label is used to identify the target of a GOTO statement. It is declared by a symbolic name in the declaration part of the Logical Block.
keywords:
label
lab1, lab2, lab3;
end_label
Exp:
label
err;
end_label

InCodePart
If devsion = 0 then
Goto err;
End if
3) Zero-time variable
Temporary variables are equivalent to local variables in C.
Keywords:
Var_temp
....
End_var
Exp:
Var_temp
Add: int;
Factor: real;
End_var

4. Static variables
Static variables are local variables whose values are retained throughout all block cycles. The value of the function block is stored in the instance data block.

The variables defined here are equivalent to static variables in C. Static variables defined in FC do not have static attributes, which are also FB

And FC.

Keywords:
VaR
....
End_var
Tip:
The declared static variables declared in function FC are stored in the var_temp area during compilation.

Exp:
VaR
Count: int;
End_var
5. input parameters
The input parameter is equivalent to the form parameter in C and Pascal.
Keywords:
Var_input
...
End_var
Exp:
Var_input
Estop: bool;
End_var;
Tip:
In db block declaration and UDT declaration, the VaR and end_var structures are replaced by struct and end_struct.

5: output parameter
the output parameter is the data interface area used by the FC and Fb blocks for output.
Keyword:
var_output
...
end_var
the output parameters are unique in the current Program design language, it can output the FC and Fb computing results
to another storage location.
6: input/output parameters
the input/output parameters are equivalent to pointer structures and can accept real parameters. After FC and Fb are processed,
the real parameter value is changed.
Keyword:
var_in_out
...
end_var

4.4.5 statement part
the statement part is the core part of FB, FC, and ob blocks. The statement part is used to implement functions of functions, function blocks, and organizational blocks.
the data block statement contains the initialization variable statement.
statement rules:
1) in the FC, FB, and ob blocks, you can use begin to identify the beginning of the statement or not.
2) the data block initialization variable statement must start with begin.
3) the end part of the statement is marked with the block end keyword.
4) each statement must be ended with a semicolon.
5) the identifier used in the statement section must be declared
6) the label already defined can be used in the statement section
Exp:
begin // use begin to indicate the start of the statement
initial_value: = 0;
final_value: = 200; // The End Of The statement: semicolon indicates the end of a single statement
sorte: // use label
resualt: = setpoint;
end_function_block // indicates the end identifier and keyword

1) statement Definition
A statement is the minimum logical structure of a user program. It describes a processor (CPU) command that executes a specified operation.
2) Statement type
Value assignment statement: specify a value to a variable.
Control statement: the execution process of control statements
Call Statement: Call specific functions and function blocks (FC and Fb blocks)
Exp:
// Example of a value assignment statement
Ilength: = 0;

// Example of subroutine call
Fb1.db1 (temprature: = 10); // pay attention to the FB block calling rules.
// FC may return values. The call of the returned values is the same as that of the PASCAL Language.
// Number of call rules

// Example of a control statement
While icounter <Max do ..
......
End_while;

I don't know what my friends in the garden know about automation and industrial control. Here are two links,

If you are idle, you can check it out.

The first link:

5-axis linkage molding of a numerical control machine:

Link: http://v.youku.com/v_show/id_XMjM2OTQzMjQw.html

At present, China's lags behind in numerical control machine tools are too large. There is a research center in Shenyang and Huazhong numerical control machines are among the first class in China,

However, compared with the video presentation, the difference is too large. If you have done numerical control, you should know how difficult it is to have full freedom of numerical control.

The prices of imported three-axis linkage machines are above, and the prices of central China's large-scale NC machining centers are also around.

Other links:

Reel Machine video: http://v.youku.com/v_show/id_XNDYzOTY3OTY=.html

Rolling Mill video http://v.youku.com/v_show/id_XMjY2ODkzOTgw.html

Http://v.youku.com/v_show/id_XMjE4OTg4MzM2.html

Http://v.youku.com/v_show/id_XNzcwMzc1OTI=.html

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.