MUL

Multiply

MUL multiplies the values of the input variables with each other and writes the result into the output variable.

Parameters

Input

Unnamed input (INT, DINT, UINT, UDINT, REAL, LREAL)

1st input: multiplicand

Unnamed input (INT, DINT, UINT, UDINT, REAL, LREAL)

2nd input: multiplicator

Output

Unnamed output (INT, DINT, UINT, UDINT, REAL, LREAL)

Output as input: result

Remarks

  • All operands must be of the same data type.
  • This function can be expanded to a maximum of 28 input contacts, see also modifying elements.

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
		enable: BOOL:=FALSE;
		multiplicand: INT:=0;
		multiplicator: INT:=0;
		result: INT:=0;
	END_VAR

In this example the input variables (multiplicand, multiplicator and enable) have been declared. Instead, you may enter constants directly into the function (enable input e.g. for tests).

LD body

If enable is set (TRUE), the multiplicant is multiplied with the multiplicator. The result will be written into result.

BODY
    WORKSPACE
        NETWORK_LIST_TYPE := NWTYPELD ;
        ACTIVE_NETWORK := 0 ;
    END_WORKSPACE
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 8 ;
        NETWORK_BODY
B(B_F,E_MUL-2!,Instance,8,1,14,6,,?DEN?D?D?AENO?C);
B(B_VARIN,,multiplicand,6,3,8,5,);
B(B_VARIN,,multiplicator,6,4,8,6,);
B(B_VAROUT,,result,14,3,16,5,);
B(B_CONTACT,,enable,3,2,5,4,);
L(1,3,3,3);
L(5,3,8,3);
L(1,0,1,8);
        END_NETWORK_BODY
    END_NET_WORK
END_BODY

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