在西门子的一本书籍中有一个模拟量批量处理的程序,FC100中的STL程序有一些不懂的地方。望各位懂的朋友能对此程序注释一下,说明一下每条语句的作用,源程序见附件中的FC100,以及对应的DB1,DB2
L DBNO
T #DBTEMP
L DINO
T #DITEMP
TAR1 #AR1TEMP
TAR2 #AR2TEMP //save system pointer
L #AI_START_ADD
SLD 3 (此处为什么左移三位)
T #AI_POINTER_BASE //load starting address of analog input to pointer
L #DB_SCALE
T #DB_SCALE_NOTEMP
OPN DB [#DB_SCALE_NOTEMP] //open DB for storing parameter
L #DB_RESULT
T #DB_RESULT_NOTEMP
OPN DI [#DB_RESULT_NOTEMP] //open DB for storing result
L 0
T #LOOPCOUNT
LOOP: NOP 0
L #LOOPCOUNT
L 16
*D (为什么要乘16?)
T #AI_POINTER_OFFSET //get the offset address of analog input
L #AI_POINTER_BASE
L #AI_POINTER_OFFSET
+D
T #AI_POINTER //get the pointer address of analog input
L PIW [#AI_POINTER]
T #AI_TEMP //get the analog input
L #LOOPCOUNT //get the address of parameter
L 80 //each group length is 10 BYTES
*D
T #DB_SCALE_POINTER
LAR1
L DBD [AR1,P#0.0]
T #DB_SCALE_HILIM //get SCALE_HILIM
L DBD [AR1,P#4.0]
T #DB_SCALE_LOWLIM //get SCALE_LOWLIM
SET
A DBX [AR1,P#8.0]
= #DB_SCALE_BIPOLAR //get SCALE_BIPOLAR
CALL "SCALE"
IN :=#AI_TEMP
HI_LIM :=#DB_SCALE_HILIM
LO_LIM :=#DB_SCALE_LOWLIM
BIPOLAR:=#DB_SCALE_BIPOLAR
RET_VAL:=#DB_RESULT_STATUS_TEMP
OUT :=#DB_RESULT_AIRESULT_TEMP
L #LOOPCOUNT //get the address for storing result
L 48 //each group length is 6 BYTES
*D
T #DB_RESULT_POINTER
LAR1
L #DB_RESULT_AIRESULT_TEMP //save the result scaled
T DID [AR1,P#0.0]
L #DB_RESULT_STATUS_TEMP //save RET_VAL when calling FC105
T DIW [AR1,P#4.0]
L #LOOPCOUNT
L 1
+I
T #LOOPCOUNT //increase 1 to loopcounter
L #AI_COUNT
>=I
JCN LOOP
LAR1 #AR1TEMP
LAR2 #AR2TEMP
OPN DB [#DBTEMP]
OPN DI [#DITEMP] //restore system pointer
点击此处查看附件