The FSC instruction is a ladder logic rung output instruction that compares data in an array, element by element. 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
- Control.EN High when the instruction is enabled.
- Control.DN When the .POS is equal to the .LEN
- Control.ER Error bit
- Control.IN Inhibit bit is set when a true comparison is detected. Clear the bit to continue the search operation.
- Control.FD Set when a true comparison is found. Similar to the Inhibit bit.
- Cotnrol.LEN The number of elements in an array to search.
- Contol.POS The current element the instruction is comparing.
LENGTH Number of elements in the array to be compared. 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.
EXPRESSION can contain one or more of the following data types
- SINT
- INT
- DINT
- REAL
- CONSTANT
- STRING
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
If the Position or Length is less than zero a major fault will occur. Make sure the length is less than or equal to the actual array size. If the Length value is set higher than the length of the array the destination value will be wrong.
Note: Arithmetic status flags are affected (S:V, S:Z, S:N, S:C). Overflow, Zero, Negative, and Carry.