1、S7 300400 的一些功能和技巧 1数据块拷贝FUNCTION FC 100 : VOIDTITLE =/DB BLOCK COPYAUTHOR : AXGNAME : DBBTODBBVERSION : 0.1VAR_INPUTSOU_DB : INT ; /SOURCE DB NUMBERLENG : INT ; /HOW MANY TO COPYDES_DB : INT ; /DESTINATION DB NUMBEREND_VARVAR_TEMPSOURCE : ANY ; DEST : ANY ; END_VARBEGINNETWORKTITLE =LAR1 P#SOURCE;
2、/ Load the start address of the ANY pointers in AR1.L B#16#10; / Load the syntax ID andT LB AR1,P#0.0; / transfer it to the ANY pointer. L B#16#4; / Load data type WORD andT LB AR1,P#1.0; / transfer it to the ANY pointer.L #LENG; / Load HOW MANY WORDS andT LW AR1,P#2.0; / transfer them to the ANY po
3、interL #SOU_DB; / Source is DB?, DBB0.0T 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; /tran
4、sfer 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
5、 the BR bit and MW 210DSTBLK := #DEST);/ END_FUNCTION使用说明:可直接调用,#SOURCE-源数据块号#DEST-目标数据块号#LENG-要拷贝数据的长度S7 300400 的一些功能和技巧 2单键翻转FUNCTION FC 11 : VOIDTITLE =/AUTHOR : AXGFAMILY : ESUNAME : SDZFVERSION : 0.0BEGINNETWORKTITLE =A M 0.0; A M 0.1; = M 58.0; NETWORKTITLE =A M 58.0; AN M 58.1; = M 58.2; NETW
6、ORKTITLE =A M 58.2; S M 58.1; ON M 58.0; ON M 0.0; R M 58.1; NOP 0; NETWORKTITLE =A M 58.2; A M 58.4; = M 58.3; NETWORKTITLE =A M 58.2; AN M 58.3; AN M 58.4; S M 58.4; O M 58.3; ON M 0.0; R M 58.4; NOP 0; END_FUNCTION使用说明:M0.0-使能M0.1-单键使 M58.4翻转 S7 300400 的一些功能和技巧 3循环读模拟量入 DB块L #DB_NOT LW 0OPN DB LW
7、 0L #PIW_ADDRSLD 3T LD 4L #DBD_ADDRSLD 3T LD 8L #CH_LENNEXT: T LW 0L LD 4LAR1 L PIW AR1,P#0.0T LW 2 CALL “Read Analog Value 464-2“IN :=LW2HI_LIM :=5.000000e+002LO_LIM :=-1.000000e+001 将模拟量转换成工程量BIPOLAR:=TRUERET_VAL:=LW10OUT :=LD12 L LD 8LAR1 L LD 2T DBD AR1,P#0.0L LD 4+ L#16T LD 4L LD 8+ L#32T LD 8L LW 0LOOP NEXTPIW_Addr 模拟块通道起始地址CHI_LEN 要读入的 通道数DB_NO 存储数据块DBW_Addr 存储在数据块中的字地址