FP_MOD_BCD

Remainder of BCD data division

This FP instruction calculates the remainder of a BCD data division where the value specified by s1 is divided by s2. The remainder is stored in d.

Parameters

Input

s1, s2 (WORD, DWORD)

Dividend, divisor

Output

d (WORD, DWORD)

Remainder

Error flags

sys_bIsOperationErrorHold (turns to TRUE and remains TRUE)
  • if the area specified using the index modifier exceeds the limit.
  • if 0 is specified for s2.
  • if data other than BCD data is specified.
sys_bIsOperationErrorNonHold (turns to TRUE for one scan)
  • if the area specified using the index modifier exceeds the limit.
  • if 0 is specified for s2.
  • if data other than BCD data is specified.

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
		bStart: BOOL:=FALSE;
			(*activates the fuction*)
		dwDividend: DWORD:=16#00001110;
			(*dividend*)
		dwDivisor: DWORD:=16#00000047;
			(*divisor*)
		dwRemainder: DWORD:=0;
			(*result after 0->1 leading edge
from start: 16#00000029*)
	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 := 6 ;
        NETWORK_BODY
B(B_VARIN,,dwDividend,12,3,14,5,);
B(B_VARIN,,dwDivisor,12,4,14,6,);
B(B_VAROUT,,dwRemainder,22,3,24,5,);
B(B_F,FP_MOD_BCD!,,14,1,22,6,,?DEN?D@'s1'?Ds2?AENO?Cd);
B(B_CONTACT,,bStart,10,2,12,4,);
L(1,3,10,3);
L(12,3,14,3);
L(1,0,1,6);
        END_NETWORK_BODY
    END_NET_WORK
END_BODY

ST body

IF (bStart) then
    FP_MOD_BCD(s1 := dwDividend, 
                   s2 := dwDivisor,  
                   d => dwRemainder);
END_IF;

Modified on: 2018-11-30Feedback on this pagePanasonic hotline