FP_INTERRUPT_ACTIVATE

Control the activation of interrupt programs for one unit

This FP instruction controls the activation of interrupt programs for the unit installed in the slot specified by d_Slot according to the data specified by s_Control.

Parameters

Input

d_Slot (WORD, INT, UINT)

Slot number: 1–16

s_Control (WORD)

Control word to activate the interrupt number of the unit installed in the specified slot: 16#0–FF

  1.  (1) Higher 8 bits: fixed at 0
  2.  (2) 0: Interrupt disabled
  3.  (3) 1: Interrupt enabled

Remarks

  • The interrupt program (INTPG 0-7) which should be executed for a given interrupt number can be assigned to the interrupt task with the appropriate number.

  • The interrupt number can be calculated using the slot number as follows: <slot number> * 10 + INTPG.

Error flags

sys_bIsOperationErrorHold (turns to TRUE and remains TRUE)

if the area specified using the index modifier exceeds the limit.

sys_bIsOperationErrorNonHold (turns to TRUE for one scan)

if the area specified using the index modifier exceeds the limit.

Example

Global variables

In the global variable list you define variables that can be accessed by all POUs in the project.

POU header

All input and output variables used for programming this function have been declared in the POU header. The same POU header is used for all programming languages.

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

LD body

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 body

(* 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;

Modified on: 2022-05-13Feedback on this pagePanasonic hotline