F46_DBSUB

8-digit BCD subtraction

Subtracts the 8-digit BCD equivalent constant or 8-digit BCD data specified by s from the 8-digit BCD data specified by d if the trigger EN is in the ON-state. The result is stored in d.

Parameters

Input

s (DWORD)

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

Output

d (DWORD)

Minuend and result, 32-bit area for 8-digit BCD data

Example

  1.  (1) Example value: 16#23210044 (BCD)
  2.  (2) Example value: 16#00210011 (BCD)
  3.  (3) Target value: 16#23000033 (BCD)
  4.  (4) 32-bit area
  5.  (5) Trigger: ON

Remarks

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

Error flags

sys_bIsEqual (turns to TRUE for one scan)

if the calculated result is 0.

sys_bIsCarry (turns to TRUE for one scan)

if the result exceeds the range of 8-digit BCD data (overflow).

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*)
		subtrahend: DWORD:=16#00210011;
			(*this value will be subtracted
from the output_value*)
		output_value: DWORD:=16#23210044;
			(*result after 0->1 leading
edge from start:
16#23000033*)
	END_VAR

LD body

When the variable start changes from FALSE 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,9,1,11,3,R);
B(B_VARIN,,subtrahend,11,2,13,4,);
B(B_VAROUT,,output_value,20,2,22,4,);
B(B_F,F46_DBSUB!,Instance,13,0,20,4,,?DEN?D@'s'?AENO?Cd);
L(1,2,9,2);
L(11,2,13,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 DF(start) then
    F46_DBSUB(subtrahend, output_value);
END_IF;

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