FAL (File Arithmetic and Logic) Ladder Logic Instruction

The File Arithmetic and Logic instruction is a ladder logic instruction that can perform copy, arithmetic and logic functions on data in an array. The instruction uses a Control data type in conjunction with a user defined expression. The instruction is enabled when the preceding logic is true and disabled otherwise.

Insure the Length and Position does not travel outside the array boundaries.

List of possible arguments

CONTROL Must be a Control Data Type

LENGTH Number of elements in the array to be manipulated. Constant type no tags.

POSITION The current element in the array. Is an element of the control tag and can be used in the expression to step through arrays.

MODE Can be ALL or INCREMENTAL. Selecting ALL will enable the instruction to execute from the first element in an array to the last element in an array on a false to true transition. INCREMENTAL will enable the instruction to execute one element in an array for every false to true transition.

DESTINATION can be one of the following data types

  • SINT
  • INT
  • DINT
  • REAL

EXPRESSION can contain one or more of the following data types

  • SINT
  • INT
  • DINT
  • REAL

Note: The REAL data type is supported for safety routines on the 1756-L7xS series of controllers.

The expression is defined using tags, math operators, and constants. Parentheses () are used to give priority to sections of an expression. Here is a list of logical operands.

Expressions are executed in a predetermined order of operation, not the order they are written in. The operation order may be changed by placing sections of the expression in parentheses as an expression enclosed in parentheses will execute first.

Order                                           Operation

  • 1                                            () Parentheses
  • 2                                            ABS, ACS, ASN, ATN, COS, DEG, FRD, LN, LOG, RAD,                                                         SIN, SQR, TAN, TOD, TRN
  • 3                                            **
  • 4                                            –(negate), NOT
  • 5                                            *, /, MOD
  • 6                                            –(subtract), +(add)
  • 7                                            AND
  • 8                                            XOR
  • 9                                            OR

Expression and Destination examples: The result of the expression is placed in the tag referenced in the Destination part of the instruction.

           Expression                                                         Destination

  • My_Array[Control_Tag.POS]+3       Value_1
  • Value_1                                                       My_Array[Control_Tag.POS]
  • My_Array[Control_Tag.POS]            Your_Array[Control_Tag.POS]


Note: Arithmetic status flags are affected (S:V, S:Z, S:N, S:C). Overflow, Zero, Negative, and Carry.

Leave a Comment