siemens 300/400编程技巧3则

[复制链接]
查看3707 | 回复11 | 2006-6-14 00:47:00 | 显示全部楼层 |阅读模式
siemens 300/400编程技巧3则

S7 300400 的一些功能和技巧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----要拷贝数据的长度
bsmtlxw | 2006-6-14 00:48:00 | 显示全部楼层
S7 300400 的一些功能和技巧2

单键翻转
FUNCTION FC 11 : VOID
TITLE =
//
AUTHOR : AXG
FAMILY : ESU
NAME : SDZF
VERSION : 0.0

BEGIN
NETWORK
TITLE =

A M 0.0;
A M 0.1;
= M 58.0;
NETWORK
TITLE =

A M 58.0;
AN M 58.1;
= M 58.2;
NETWORK
TITLE =

A M 58.2;
S M 58.1;
ON M 58.0;
ON M 0.0;
R M 58.1; NOP 0;
NETWORK
TITLE =

A M 58.2;
A M 58.4;
= M 58.3;
NETWORK
TITLE =

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翻转
bsmtlxw | 2006-6-14 00:48:00 | 显示全部楼层
S7 300400 的一些功能和技巧3

循环读模拟量入DB块
L #DB_NO
T LW 0
OPN DB [LW 0]
L #PIW_ADDR
SLD 3
T LD 4
L #DBD_ADDR
SLD 3
T LD 8
L #CH_LEN
NEXT: T LW 0
L LD 4
LAR1
L PIW [AR1,P#0.0]
T LW 2

{ CALL \"Read Analog Value 464-2\"
IN :=LW2
HI_LIM :=5.000000e+002
LO_LIM :=-1.000000e+001 将模拟量转换成工程量
BIPOLAR:=TRUERET_VAL:=LW10
OUT :=LD12 }

L LD 8
LAR1
L LD 2
T DBD [AR1,P#0.0]
L LD 4
+ L#16
T LD 4
L LD 8
+ L#32
T LD 8
L LW 0
LOOP NEXT


PIW_Addr :模拟块通道起始地址
CHI_LEN :要读入的 通道数
DB_NO :存储数据块
DBW_Addr :存储在数据块中的字地址
whb1981 | 2006-11-30 16:27:00 | 显示全部楼层

8懂~呵呵~楼主可以多点描述介绍吗?

yonhji | 2006-11-30 16:53:00 | 显示全部楼层

对初学者来说,有点难!

多点说明就好了

yjcomein | 2006-12-23 14:10:00 | 显示全部楼层
我找来找去好象就是要找这个哎!呵呵!试试看先!!
wgp80 | 2007-1-22 11:12:00 | 显示全部楼层

确实优点难!

chunhuisan19 | 2007-1-23 05:43:00 | 显示全部楼层

学习了

wj14378 | 2007-2-3 08:53:00 | 显示全部楼层
看不明白
afflatus_xxx | 2007-2-19 18:45:00 | 显示全部楼层

nuli

[em01]
afflatus_xxx | 2007-2-19 18:47:00 | 显示全部楼层
努力[em01][em01][em01]
BLACKDOVE | 2010-7-5 18:31:00 | 显示全部楼层
晕,太炫了吧
您需要登录后才可以回帖 登录 | 注册哦

本版积分规则