CP1H 功能塊 結(jié)構(gòu)化ST編程 指令I(lǐng)F 用法
程序如下:
FB1功能塊
定義接口
IF P_1s AND NOT Temp_1 THEN // 上升沿用,自制時間定時器,ST編程,小型機時間指令不支持
index:= index+1;
END_IF;
Temp_1:= P_1s;
IF index>=17 THEN
index:= 0;
END_IF;
FB2功能塊
定義接口
IF INDEX =1 THEN
OUT_07:= FALSE;
OUT_0:= TRUE;
ELSIF INDEX=2 THEN
OUT_0:= FALSE;
OUT_1:= TRUE;
ELSIF INDEX=3 THEN
OUT_1:= FALSE;
OUT_2:= TRUE;
ELSIF INDEX=4 THEN
OUT_2:= FALSE;
OUT_3:= TRUE;
ELSIF INDEX=5THEN
OUT_3:= FALSE;
OUT_4:= TRUE;
ELSIF INDEX =6THEN
OUT_4:= FALSE;
OUT_5:= TRUE;
ELSIF INDEX=7 THEN
OUT_5:= FALSE;
OUT_6:= TRUE;
ELSIF INDEX=8 THEN
OUT_6:= FALSE;
OUT_7:= TRUE;
ELSIF INDEX=9THEN
OUT_7:= FALSE;
OUT_00:= TRUE;
ELSIF INDEX =10THEN
OUT_00:= FALSE;
OUT_01:= TRUE;
ELSIF INDEX=11 THEN
OUT_01:= FALSE;
OUT_02:= TRUE;
ELSIF INDEX =12 THEN
OUT_02:= FALSE;
OUT_03:= TRUE;
ELSIF INDEX=13 THEN
OUT_03:= FALSE;
OUT_04:= TRUE;
ELSIF INDEX =14THEN
OUT_04:= FALSE;
OUT_05:= TRUE;
ELSIF INDEX=15 THEN
OUT_05:= FALSE;
OUT_06:= TRUE;
ELSIF INDEX =16 THEN
OUT_06:=FALSE;
OUT_07:= TRUE;
END_IF;