文档介绍:精选优质文档-----倾情为你奉上
精选优质文档-----倾情为你奉上
专心---专注---专业
专心---专注---专业
精选优质文档-----倾情为你奉上
专心---专注---专业
第一章 上
精选优质文档-----倾情为你奉上
专心---专注---专业
专心---专注---专业
精选优质文档-----倾情为你奉上
专心---专注---专业
函数(Function)
当定义函数的时候,不要忘记函数中必须含有返回值的数据类型,也就是说在函数名的后面必需紧跟冒号和一个数据类型。
下面是一个正确的函数定义:
FUNCTION INDUAL :INT
就是说函数名被用作输出变量。函数定义的以关键字FUNCTION开始,以END_FUNCTION 结尾。Example in IL of a function that takes three input variables and returns the product of the first two divided by the third:
Image : Function
{bmc }
x Example of a function in IL
函数没有任何的内部条件,就是说当用相同的输入变量时就会得出相同的结果(输出)。
x Examples for calling up the function described above
Examples for calling up the function described above:
in ST:
Result := Fct(7, 2, 4);
程序(Program)
程序是一种程序结构单元,在运行过程中返回一定数量的值。程序在整个工程中都可以被识别。
{bmc }
x Example of a program
程序能够被调用,但不允许在函数中调用程序。如果在程序结构单元中调用程序时程序的返回值有变化,这些变化将保持到下一次程序调用,即使程序程序是从其它程序结构单元调用的。
程序由起始关键字PROGRAM开始,END_PROGRAM结束。.
x Examples of calls of the program described above
精选优质文档-----倾情为你奉上
精选优质文档-----倾情为你奉上
专心---专注---专业
专心---专注---专业
精选优质文档-----倾情为你奉上
专心---专注---专业
in ST:
PRGExample;
Res := ;
If the variable PAR from the program PRGexample is initialized by a main program with 0, and then one after the other programs are called with above named program calls, then the RES result in the programs will have the values 1, 2, and 3. If one exchanges the sequence of the calls, then the values of the given result parameters also change in a corresponding fashion.
PLC_PRG
PLC_PRG 是一个特殊的预先定义的程序结构单元,任何工程都必须含有这个特殊的程序。每次循环的过程中调用一次PLC_PRG 。
在新工程建立之后第一次执行 "Project" "Object Add" 命令时,程序结构单元对话框中的初始输入项就是名为PLC_PRG的程序类型。
注意: 不要删除或者重命名PLC_PRG
Resources
设置和组织工程所需的资源:
· 全局变量 Global Variables
· PLC设置 PLC Configuration
· 任务配置 Task Configuration
· 采样轨迹 Sampling Trace
· 观察和接收管理器Watch and Receipt Manager
库函数(Libraries)
库函数""是一个标准的函数库,可供程序进行调用。
精选优质文档-----倾情为你奉上
精选优质文档-----倾情为你奉上
专心---专