DIV(

Divide

The content of the accumulator is divided by the result of the expression in the following brackets. The result is transferred to the accumulator.

Remarks

  • Valid operands for this operator must be of one of the following data types: (INT, DINT, UINT, UDINT, REAL)

  • Operator only available in IL programming language.

  • All operands must be of the same data type.

  • The whole operation can be described in the following way:

    var_1 is loaded into the accu

    ® the content of the accu is pushed onto the stack

    ®   var_2 is loaded into the accu

    ®   var_3 is added to the accu; the result of this operation is stored in the accu

    ®   var_1 is popped off the stack and divided by the accu; the result of this operation is stored in the accu

    ® the content of the accu is written to the variable var_4. (The actual implementation for a specific target system may process the whole operation a different way.)

Related topics:

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.

IL body

LD

var_1

(* Load var_1 in accu *)

(* Since bracket expression follows, save content of accu;

process expression in brackets first *)

DIV(

var_2

(* Load var_2 in accu *)

ADD

var_3

(* Add var_3 to accu; store result in accu *)

)

(* Get saved accu content and divide by actual content of accu;

store result in accu *)

ST

var_4

(* Store accu in var_4 *)

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