FP_DEC

Decrement

This FP instruction subtracts 1 from the data specified by d if the trigger EN is TRUE. The result is stored in d.

Parameters

Input/output

d (INT, DINT, UINT, UDINT, REAL, LREAL)

Data to be decremented by 1 and result

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.
Related topics:

Example

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
		start: BOOL:=FALSE;
			(*activates the function*)
		decrement_value: DINT:=131081;
			(*result after a 0->1 leading
edge from start: 16*)
	END_VAR

LD body

When the variable bStart is set to TRUE, the function is carried out.

BODY
    WORKSPACE
        NETWORK_LIST_TYPE := NWTYPELD ;
        ACTIVE_NETWORK := 0 ;
    END_WORKSPACE
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 5 ;
        NETWORK_BODY
B(B_F,FP_DEC!,,14,1,20,5,,?DEN?Dd?Ad?AENO);
B(B_CONTACT,,start,4,2,6,4,R);
B(B_VARIN,,decrement_value,12,3,14,5,);
B(B_VAROUT,,decrement_value,20,3,22,5,);
L(1,3,4,3);
L(6,3,14,3);
L(1,0,1,5);
        END_NETWORK_BODY
    END_NET_WORK
END_BODY

ST body

IF DF(start) then
    FP_DEC(decrement_value);
END_IF;

Modified on: 2022-08-23Feedback on this pagePanasonic hotline