-
-
lyc19730508 | 当前状态:在线
总积分:21345 2024年可用积分:3
注册时间: 2008-03-20
最后登录时间: 2021-05-27
-
siemens S7-300/400编程技巧1
lyc19730508 发表于 2014/4/1 8:36:08 971 查看 2 回复 [上一主题] [下一主题]
手机阅读
S7 300/400 的一些功能和技巧1
数据块拷贝
FUNCTION FC 100 : VOID
TITLE =
//DB BLOCK COPY
AUTHOR : AXG
NAME : DBBTODBB
VERSION : 0.1
VAR_INPUT
SOU_DB : INT ; //SOURCE DB NUMBER
LENG : INT ; //HOW MANY TO COPY
DES_DB : INT ; //DESTINATION DB NUMBER
END_VAR
VAR_TEMP
SOURCE : ANY ;
DEST : ANY ;
END_VAR
BEGIN
NETWORK
TITLE =
LAR1 P##SOURCE; // Load the start address of the ANY pointers in AR1.
L B#16#10; // Load the syntax ID and
T LB [AR1,P#0.0]; // transfer it to the ANY pointer.
L B#16#4; // Load data type WORD and
T LB [AR1,P#1.0]; // transfer it to the ANY pointer.
L #LENG; // Load HOW MANY WORDS and
T LW [AR1,P#2.0]; // transfer them to the ANY pointer
L #SOU_DB; // Source is DB[?], DBB0.0
T LW [AR1,P#4.0]; //
L P#DBX 0.0; //
T LD [AR1,P#6.0]; //
LAR1 P##DEST; //Load the DESTINATION address of the ANY pointer in AR1.
L B#16#10; //Load the syntax ID and
T LB [AR1,P#0.0]; //transfer it to the ANY pointer.
L B#16#4; //Load data type WORD and
T LB [AR1,P#1.0]; //transfer it to the ANY pointer.
L #LENG; //Load HOW MANY WORDS and
T LW [AR1,P#2.0]; //transfer them to the ANY pointer.
L #DES_DB; //Destination is DB{?}, DBB0.0
T LW [AR1,P#4.0];
L P#DBX 0.0; //
T LD [AR1,P#6.0]; //
CALL "BLKMOV" (//Call the block move system function
SRCBLK := #SOURCE,//
RET_VAL := MW 210,//Evaluate the BR bit and MW 210
DSTBLK := #DEST);//
END_FUNCTION
使用说明:可直接调用,#SOURCE---源数据块号
#DEST------目标数据块号
#LENG----要拷贝数据的长度