SQR (Square Root) Ladder Logic Instruction

Definition

The Square Root instruction is a ladder logic rung output instruction that calculates the square root of the Source value and places the result in the Destination tag. The instruction is enabled when the preceding logic is true and disabled otherwise. The values can be constants, tags or any combination.

If the Destination tag is not of Real data type the fractional portion of the result is handled one of two ways:

  1. If the Source data type is not REAL i.e. INT,SINT,DINT the fractional portion is truncated.
  2. If the Source data type is REAL the fractional portion is rounded.

List of possible arguments

SOURCE and DESTINATION can be any combination of the following data types.

  • CONSTANT             Can’t be the DESTINATION obviously
  • SINT              
  • INT
  • DINT
  • REAL

Note: If the Source is negative the absolute value of the Source is taken before the calculation is performed. Arithmetic status flags are affected (S:V, S:Z, S:N, S:C). Overflow, Zero, Negative, and Carry.