发布于 2013-10-08 13:00:55
2楼
一个STL源文件,是FC块,功能:在编号为No_DB的数据块中,Count_Data个地址连续整数的相加(第一个数据的地址为Add_st,相邻两个数据之间的步长为Length_step个字节)。
FUNCTION FC xx : VOID
VAR_INPUT
No_DB : INT ; //The Number of DB, for example DB10, No.DB=10
Count_Data : INT ; //The Count of data, for example there are 50, Count_Data=50
Add_ST : INT ; //The start address, for example DB10.DBW6, Add_st=6
Length_step : INT ; //The step length, for example DBW6,DBW10,DBW14,.... Length_step=4
END_VAR
VAR_OUTPUT
OutI : INT ;
END_VAR
VAR_TEMP
tNo_DB : WORD ;
tCount_Data : INT ;
tAdd : DINT ;
tLength_step : DINT ;
tSum : INT ;
END_VAR
BEGIN
NETWORK
TITLE =
L #No_DB;
T #tNo_DB;
L #Length_step;
SLW 3;
T #tLength_step;
L #Add_ST;
SLW 3;
T #tAdd;
L 0.000000e+000;
T #tSum;
OPN DB [#tNo_DB];
L #Count_Data;
next: T #tCount_Data;
L DBW [#tAdd];
L #tSum;
+I ;
T #tSum;
L #tAdd;
L #tLength_step;
+D ;
T #tAdd;
L #tCount_Data;
LOOP next;
L #tSum;
T #OutI;
END_FUNCTION
No discussion, no outcome.