发表于:2005-11-30 10:16:00
楼主
给大家提供一个siemens FB41 的使用例子,直接拷贝到source文件中,编译即可运行,其中的地址可能会和您的实际配置有所差别,如果冲突,需要修改。
DATA_BLOCK DB 41
TITLE =
AUTHOR : SIMATIC
FAMILY : ICONT
VERSION : 0.0
FB 41
BEGIN
COM_RST := FALSE;
MAN_ON := TRUE;
PVPER_ON := FALSE;
P_SEL := TRUE;
I_SEL := TRUE;
INT_HOLD := FALSE;
I_ITL_ON := FALSE;
D_SEL := FALSE;
CYCLE := T#1S;
SP_INT := 0.000000e+000;
PV_IN := 0.000000e+000;
PV_PER := W#16#0;
MAN := 0.000000e+000;
GAIN := 2.000000e+000;
TI := T#20S;
TD := T#10S;
TM_LAG := T#2S;
DEADB_W := 0.000000e+000;
LMN_HLM := 1.000000e+002;
LMN_LLM := 0.000000e+000;
PV_FAC := 1.000000e+000;
PV_OFF := 0.000000e+000;
LMN_FAC := 1.000000e+000;
LMN_OFF := 0.000000e+000;
I_ITLVAL := 0.000000e+000;
DISV := 0.000000e+000;
LMN := 0.000000e+000;
LMN_PER := W#16#0;
QLMN_HLM := FALSE;
QLMN_LLM := FALSE;
LMN_P := 0.000000e+000;
LMN_I := 0.000000e+000;
LMN_D := 0.000000e+000;
PV := 0.000000e+000;
ER := 0.000000e+000;
sInvAlt := 0.000000e+000;
sIanteilAlt := 0.000000e+000;
sRestInt := 0.000000e+000;
sRestDif := 0.000000e+000;
sRueck := 0.000000e+000;
sLmn := 0.000000e+000;
sbArwHLmOn := FALSE;
sbArwLLmOn := FALSE;
sbILimOn := TRUE;
END_DATA_BLOCK
ORGANIZATION_BLOCK OB 35
TITLE = "Cyclic Interrupt"
VERSION : 0.1
VAR_TEMP
OB35_EV_CLASS : BYTE ; //Bits 0-3 = 1 (Coming event), Bits 4-7 = 1 (Event class 1)
OB35_STRT_INF : BYTE ; //16#36 (OB 35 has started)
OB35_PRIORITY : BYTE ; //Priority of OB Execution
OB35_OB_NUMBR : BYTE ; //35 (Organization block 35, OB35)
OB35_RESERVED_1 : BYTE ; //Reserved for system
OB35_RESERVED_2 : BYTE ; //Reserved for system
OB35_PHASE_OFFSET : WORD ; //Phase offset (msec)
OB35_RESERVED_3 : INT ; //Reserved for system
OB35_EXC_FREQ : INT ; //Frequency of execution (msec)
OB35_DATE_TIME : DATE_AND_TIME ; //Date and time OB35 started
END_VAR
BEGIN
NETWORK
TITLE =Wenn switching from Auto->Hand then takeover output on Handvalue
//Flankdetection on Automatik to Manual
A M 10.0; // If hand is choossen then switch the actual output on the hand value
FP M 11.0; // one time !!, so a positive flank
= M 11.1;
JCN cont; // When no flank then to the controller
L MD 48; // Output
T MD 20; // --> Manual value
NETWORK
TITLE =Controller
//Not all the parameters are necessary on the FB, here this is done to test it
//easy in a VAT-table.
//
//The values from the Analog Input and the Analog Output are here 27648 bitvalues
//are&