FP_INTERRUPT_ACTIVATE

控制一个单元的中断程序的激活

该FP指令根据s_Control指定的数据来控制d_Slot指定的插槽中安装单元的中断程序激活。

参数

输入

d_Slot (WORD, INT, UINT)

插槽编号:1–16

s_Control (WORD)

用于激活指定插槽安装单元中断号的控制字:16#0–FF

  1.  (1) 较高的8位: 固定为0
  2.  (2) 0:中断禁用
  3.  (3) 1:中断使能

标注

  • 应该为给定的中断号执行的中断程序(INTPG 0-7)可以分配给具有适当编号的中断任务。

  • 可以使用插槽编号计算中断号,如下所示:<插槽编号> * 10 + INTPG

错误标志

sys_bIsOperationErrorHold(变为TRUE并保持为TRUE)

如果使用索引寄存器指定的区域超出限制。

sys_bIsOperationErrorNonHold(对于一次扫描变为TRUE)

如果使用索引寄存器指定的区域超出限制。

示例

全局变量

在全局变量列表中,定义项目中所有POU都可以访问的变量。

POU头

所有用于编程此函数的输入和输出变量已在POU头中声明。 所有编程语言使用相同的POU头。

	VAR
		bEnable_Interrupt: BOOL:=FALSE;
		bComparisonMatchMonitor: BOOL:=FALSE;
		bDisableHscUnit: BOOL:=FALSE;
		bDisable_Interrupt: BOOL:=FALSE;
		bReset_interruptValue: BOOL:=FALSE;
	END_VAR

LD本体

BODY
    WORKSPACE
        NETWORK_LIST_TYPE := NWTYPELD ;
        ACTIVE_NETWORK := 0 ;
    END_WORKSPACE
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 14 ;
        NETWORK_BODY
B(B_COMMENT,,Program behavior:ø^- with first scan all interrups are disabled (or via bDisable_interrupt by hand)ø^ø^- g_Count_up ONCE a second --> if EQ 5 Interrupt 10 will be activated (NW 11) --> but isn't enabled jet!!!ø^ø^- g_Count_up = 10 the interrupts will be enabled ø^ø^- the interrupt program is activated in Interrupt 10 (Slot 1 Channel 0)ø^ø^- if g_bCount_interrupt EQ 16 --> Interrupt 10 (only) is deactivated againø^ø^- wait until g_iCount_up GE 25 --> Reset of g_iCount_up and g_iCount_interruptø^,4,1,52,14,);
L(1,0,1,14);
        END_NETWORK_BODY
    END_NET_WORK
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 6 ;
        NETWORK_BODY
B(B_CONTACT,,sys_bIsFirstScan,6,1,8,3,F);
B(B_COIL,,g_bHscUnitEnable,29,1,31,3,);
B(B_CONTACT,,g_bHscUnitEnable,6,4,8,6,);
B(B_CONTACT,,bDisableHscUnit,16,1,18,3,N);
L(18,2,29,2);
L(8,2,16,2);
L(1,2,6,2);
L(1,5,6,5);
L(8,5,11,5);
L(11,2,11,5);
L(1,0,1,6);
        END_NETWORK_BODY
    END_NET_WORK
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 6 ;
        NETWORK_BODY
B(B_CONTACT,,g_bHscUnitEnable,6,1,8,3,R);
B(B_COIL,,g_bHscUnitEnableCounting,29,1,31,3,);
B(B_CONTACT,,g_bHscUnitEnableCounting,6,4,8,6,);
B(B_CONTACT,,bDisableHscUnit,16,1,18,3,N);
L(18,2,29,2);
L(1,5,6,5);
L(13,2,13,5);
L(8,5,13,5);
L(13,2,16,2);
L(8,2,13,2);
L(1,2,6,2);
L(1,0,1,6);
        END_NETWORK_BODY
    END_NET_WORK
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 3 ;
        NETWORK_BODY
B(B_CONTACT,,g_bHscUnitComparisonMatchFlag,7,1,9,3,);
B(B_COIL,,bComparisonMatchMonitor,29,1,31,3,);
L(9,2,29,2);
L(1,2,7,2);
L(1,0,1,3);
        END_NETWORK_BODY
    END_NET_WORK
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 7 ;
        NETWORK_BODY
B(B_F,FP_INTERRUPT_DISABLE!,,12,2,24,5,,?DEN?AENO);
B(B_CONTACT,,sys_bIsFirstScan,4,3,6,5,);
B(B_COIL,,bEnable_Interrupt,29,3,31,5,E);
B(B_CONTACT,,bDisable_Interrupt,4,5,6,7,);
B(B_COMMENT,,Disables all Interrupts: no activation with the FB- FP_INTERRUPT_ENABLE possible,1,0,25,2,);
L(6,4,12,4);
L(6,6,11,6);
L(11,4,11,6);
L(24,4,29,4);
L(1,6,4,6);
L(1,4,4,4);
L(1,0,1,7);
        END_NETWORK_BODY
    END_NET_WORK
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 5 ;
        NETWORK_BODY
B(B_COMMENT,,For monitoring the counter variable in the interrupt 10,2,0,26,2,);
B(B_VARIN,,g_iCount_interrupt,9,3,11,5,);
B(B_VAROUT,,g_iCount_interrupt,11,3,13,5,);
L(1,0,1,5);
        END_NETWORK_BODY
    END_NET_WORK
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 8 ;
        NETWORK_BODY
B(B_COMMENT,,Interrupt 10 is activated,2,1,26,3,);
B(B_F,FP_INTERRUPT_ACTIVATE!,,18,3,31,8,,?DEN?Dd_Slot?Ds_Control?AENO);
B(B_VARIN,,1,16,5,18,7,);
B(B_VARIN,,16#0001,16,6,18,8,);
B(B_F,@EQ-2!,,8,4,13,7,,?D?D?C);
B(B_VARIN,,g_iCount_up,6,4,8,6,);
B(B_VARIN,,5,6,5,8,7,);
L(13,5,18,5);
L(1,0,1,8);
        END_NETWORK_BODY
    END_NET_WORK
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 4 ;
        NETWORK_BODY
B(B_F,@EQ-2!,,9,1,14,4,,?D?D?C);
B(B_VARIN,,g_iCount_up,7,1,9,3,);
B(B_VARIN,,10,7,2,9,4,);
B(B_COIL,,bEnable_Interrupt,33,1,35,3,S);
L(14,2,33,2);
L(1,0,1,4);
        END_NETWORK_BODY
    END_NET_WORK
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 10 ;
        NETWORK_BODY
B(B_F,FP_INTERRUPT_ENABLE!,,19,5,31,8,,?DEN?AENO);
B(B_CONTACT,,bEnable_Interrupt,10,6,12,8,);
B(B_COMMENT,,Interrupts are possible,2,1,26,3,);
L(12,7,19,7);
L(1,7,10,7);
L(1,0,1,10);
        END_NETWORK_BODY
    END_NET_WORK
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 11 ;
        NETWORK_BODY
B(B_VARIN,,g_iCount_interrupt,7,6,9,8,);
B(B_VARIN,,15,7,7,9,9,);
B(B_F,FP_INTERRUPT_ACTIVATE!,,19,5,32,10,,?DEN?Dd_Slot?Ds_Control?AENO);
B(B_VARIN,,1,17,7,19,9,);
B(B_VARIN,,16#0000,17,8,19,10,);
B(B_F,@GT-2!,,9,6,14,9,,?D?D?C);
B(B_F,E_GE-2!,,39,5,45,10,,?DEN?D?D?AENO?C);
B(B_VARIN,,g_iCount_up,37,7,39,9,);
B(B_VARIN,,25,37,8,39,10,);
B(B_COIL,,bReset_interruptValue,49,7,51,9,);
B(B_COMMENT,,Deactivate interrupt 10 again if g_iCount_interrupt is higher than 15ø^ø^if g_iCount_Up > 25   g_iCount_interrupt will be set to Zero,2,0,31,3,);
L(14,7,19,7);
L(32,7,39,7);
L(45,8,49,8);
L(1,0,1,11);
        END_NETWORK_BODY
    END_NET_WORK
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 4 ;
        NETWORK_BODY
B(B_F,E_MOVE!,,19,0,25,4,,?DEN?D?AENO?C);
B(B_VAROUT,,g_iCount_interrupt,25,2,27,4,);
B(B_VARIN,,0,17,2,19,4,);
B(B_CONTACT,,bReset_interruptValue,7,1,9,3,R);
B(B_F,E_MOVE!,,39,0,45,4,,?DEN?D?AENO?C);
B(B_VAROUT,,g_iCount_up,45,2,47,4,);
B(B_VARIN,,0,37,2,39,4,);
L(1,2,7,2);
L(25,2,39,2);
L(9,2,19,2);
L(1,0,1,4);
        END_NETWORK_BODY
    END_NET_WORK
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 9 ;
        NETWORK_BODY
B(B_F,FP_INC!,,19,4,25,8,,?DEN?Dd?Ad?AENO);
B(B_VARIN,,g_iCount_up,17,6,19,8,);
B(B_CONTACT,,sys_bPulse1s,7,5,9,7,R);
B(B_COMMENT,,Increment the main counter every second by one,3,1,27,3,);
L(9,6,19,6);
L(1,6,7,6);
L(1,0,1,9);
        END_NETWORK_BODY
    END_NET_WORK
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 5 ;
        NETWORK_BODY
L(1,0,1,5);
        END_NETWORK_BODY
    END_NET_WORK
END_BODY

ST本体

(* Initiation *)
g_bHscUnitEnable := (DFN(sys_bIsFirstScan) OR g_bHscUnitEnable) AND NOT bDisableHscUnit ;
g_bHscUnitEnableCounting := (DF(g_bHscUnitEnable) OR g_bHscUnitEnableCounting) AND NOT bDisableHscUnit ;
(* Monitoring *)
bComparisonMatchMonitor := g_bHscUnitComparisonMatchFlag ;  
g_iCount_up := g_iCount_up;                    (* is counted in the main project *)
g_iCount_interrupt := g_iCount_interrupt;            (* is counted in the interrupt program 1_0*)
(* Interrupt expressions *)
if (sys_bIsFirstScan OR bDisable_Interrupt) then
    FP_INTERRUPT_DISABLE();
    bEnable_Interrupt := FALSE;
end_if;
case g_iCount_up of
    5:    FP_INTERRUPT_ACTIVATE(d_Slot := 1 , s_Control := 16#0001 );    (* Activate interrupt 1_0 *)
    10:    bEnable_Interrupt := True;                        (* set bEnable_Interrupt *)
    16: FP_INTERRUPT_ACTIVATE(d_Slot := 1, s_Control := 16#0000);    (* Deactivate interrupt 1_0 *)
    20: g_iCount_up := 0;                                (* Reset countervariables *)
            g_iCount_interrupt := 0;
end_case;
if (bEnable_Interrupt) then
    FP_INTERRUPT_ENABLE();                                (* Enabel all interrupts *)
end_if;
(* 1 second counting pulse *)
if (DF(sys_bPulse1s)) then
    FP_INC(d := g_iCount_up);
end_if;

最后更新日期: 此页面上的反馈松下热线