DIV: Divide (S7-1200, S7-1500) - STEP 7

FBD (S7-1200, S7-1500)

ft:publication_title
FBD (S7-1200, S7-1500)
Product
STEP 7
Version
V20
Publication date
11/2024
Language
en-US
DIV: Divide

Description

You can use the "Divide" instruction to divide the value at input IN1 by the value at input IN2 and query the quotient at output OUT (OUT := IN1/IN2).

Enable output ENO has the signal state "0" if one of the following conditions applies:

  • Enable input EN has the signal state "0".

  • The result of the instruction is outside the range permitted for the data type specified at the OUT output.

  • A floating-point number has an invalid value.

Note

Division by the value "0"

The division of a dividend (IN1) by a divisor (IN2) with the value "0" sets the enable output (ENO) to signal state "TRUE".

On division by "0", the quotient value (OUT) is influenced by the data type as follows:

  • The data type is INT or LREAL: Quotient value (OUT) is "0".

  • The data type is REAL: Quotient value (OUT) is the maximum value "2143289344".

    Exception: If the dividend and the divisor have the value "0", the quotient is "nan" (not a number).

Parameters

The following table shows the parameters of the "Divide" instruction:

Parameters

Declaration

Data type

Memory area

Description

S7-1200

S7-1500

EN

Input

BOOL

I, Q, M, D, L or constant

I, Q, M, D, L, T, C or constant

Enable input

ENO

Output

BOOL

I, Q, M, D, L

I, Q, M, D, L

Enable output

IN1

Input

Integers, floating-point numbers

I, Q, M, D, L, P or constant

I, Q, M, D, L, P or constant

Dividend

IN2

Input

Integers, floating-point numbers

I, Q, M, D, L, P or constant

I, Q, M, D, L, P or constant

Divisor

OUT

Output

Integers, floating-point numbers

I, Q, M, D, L, P

I, Q, M, D, L, P

Quotient value

You can select the data type of the instruction from the "???" drop-down list of the instruction box.

You can find additional information on valid data types under "See also".

Example

The following example shows how the instruction works:

If the "TagIn" operand has signal state "1", the instruction is executed. The value of operand "Tag_Value1" is divided by the value of operand "Tag_Value2". The result of the division is stored in the operand "Tag_Result". If the instruction is executed without errors, the enable output ENO has the signal state "1" and the "TagOut" output is set.