FP_END_SCAN

Conditional end

Ends the current scan of the program code at the current program position.

Parameters

Input

EN (BOOL)

if TRUE, the instruction is carried out

Output

ENO (BOOL)

set to TRUE, if the instruction has been successfully processed

Remarks

  • When the execution condition turns to TRUE, the program ends the current scan and begins I/O processing. Then, the program returns to the first address.

  • This instruction cannot be performed in sub-programs such as subroutine programs or interrupt programs. Use the FP_END_SCAN instruction in the main program area only.

  • Two or more FP_END_SCAN instructions can be used within the main program.

  • You must be careful when using one of the instructions listed below, which are executed by detecting the rising edge of a execution condition (trigger).

    • DF (rising edge differential)

    • Count input for CT (counter)

    • Count input for F118_UDC (up/down counter)

    • Shift input for SR (shift register)

    • Shift input for F119_LRSR (left/right shift register)

    • Differential execution of P instructions (specified by P and a number, e.g. P20_ADD)

Example

Task pool

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
		bEndCurrentScan: BOOL:=FALSE;
		iCounterExecuted: INT:=0;
		iCounterNotExecuted: INT:=0;
	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 := 4 ;
        NETWORK_BODY
B(B_F,FP_INC!,,20,0,26,4,,?DEN?Dd?Ad?AENO);
B(B_VARIN,,iCounterExecuted,18,2,20,4,);
L(1,2,20,2);
L(1,0,1,4);
        END_NETWORK_BODY
    END_NET_WORK
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 3 ;
        NETWORK_BODY
B(B_F,FP_END_SCAN!,,19,0,27,3,,?DEN?AENO);
B(B_CONTACT,,bEndCurrentScan,6,1,8,3,);
L(1,2,6,2);
L(8,2,19,2);
L(1,0,1,3);
        END_NETWORK_BODY
    END_NET_WORK
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 4 ;
        NETWORK_BODY
B(B_F,FP_INC!,,20,0,26,4,,?DEN?Dd?Ad?AENO);
B(B_VARIN,,iCounterNotExecuted,18,2,20,4,);
L(1,2,20,2);
L(1,0,1,4);
        END_NETWORK_BODY
    END_NET_WORK
END_BODY

Example Program_2

ST body

FP_INC(d := iCounterExecuted);
If (bEndCurrentScan) then
    FP_END_SCAN();
End_if;
FP_INC(d := iCounterNotExecuted);

Modified on: 2023-03-13Feedback on this pagePanasonic hotline