F53_DBDIV

8-digit BCD division, destination can be specified

The result is stored in the area specified by d, and the remainder is stored in the system variable sys_diDDivRemainder.

Parameters

Input

s1 (DWORD)

Dividend, 32-bit area for BCD data or 8-digit BCD equivalent constant

s2 (DWORD)

Divisor, 32-bit area for BCD data or 8-digit BCD equivalent constant

Output

d (DWORD)

Quotient, 32-bit area for BCD data (remainder stored in the system variable sys_diDDivRemainder

Example

  1.  (1) Example value 16#00001110 (BCD)
  2.  (2) Example value 16#0000011 (BCD)
  3.  (3) Result value 16#00000100 (BCD) if trigger is ON
  4.  (4) Remainder 16#00000010 (BCD) if trigger is ON stored in sys_diDDivRemainder
  5.  (5) 32-bit area
  6.  (6) Trigger: ON

Remarks

Instead of using this F instruction, we recommend using the corresponding FP7 instruction:

FP_MOD_BCD,FP_DIV_MOD_BCD,FP_DIV_BCD

Error flags

sys_bIsEqual (turns to TRUE for one scan)

if the calculated result is 0.

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 fuction*)
		dividend: DWORD:=16#00001110;
			(*dividend*)
		divisor: DWORD:=16#00000011;
			(*divisor*)
		output_value: DWORD:=0;
			(*result after 0->1 leading edge
from start: 16#00000100*)
	END_VAR

LD body

When the variable start 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_CONTACT,,start,10,1,12,3,);
B(B_VARIN,,dividend,12,2,14,4,);
B(B_VARIN,,divisor,12,3,14,5,);
B(B_VAROUT,,output_value,21,2,23,4,);
B(B_F,F53_DBDIV!,Instance,14,0,21,5,,?DEN?D@'s1'?Ds2?AENO?Cd);
L(1,2,10,2);
L(12,2,14,2);
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
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
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
L(1,0,1,6);
        END_NETWORK_BODY
    END_NET_WORK
END_BODY

ST body

IF start then
    F53_DBDIV(dividend, divisor, output_value);
END_IF;

Modified on: 2019-01-24Feedback on this pagePanasonic hotline