User`s manual

11-4 Motion Mate DSM314 for Series 90-30 PLCs User's Manual
January 2001 GFK-1742A
11
Relational Operators
Relational operators compare two operands in a conditional statement. The < (less than), > (greater
than), <= (less than or equal), >= (greater than or equal), = (equal), and <> (not equal) operators are
valid relational operators. The IF statement body execution takes place when the conditional
expression is a true. In the example, the variable Torque_Limit_1 is set to 10000 if the variable
Block_1 equals 3. If the Block_1 value is not equal to 3 then the expression evaluates to false and
program execution continues after the END_IF program statement.
Example:
IF Block_1 = 3 THEN
Torque_Limit_1 := 10000; (* Set Torque Limit = 100% @ Block 3 *)
END_IF;
Complex relations may be solved by nesting IF statements. For example, to set Axis 1 torque limit
(Torque_Limit_1) to 10000=100% (i.e. same scaling as in AQ command processing) when the
motion program block 3 is active and axis 1 commanded velocity (Commanded_Velocity_1) is less
than 1000, the following construct is valid:
IF Block_1 = 3 THEN
IF Commanded_Velocity_1 < 1000 THEN
Torque_Limit_1 := 10000; (* Set Torque Limit = 100% @ Block 3 *)
END_IF;
END_IF;
Bitwise Logical Operators
Bitwise logical operators mask or invert an individual bit or groups of bits. The BWAND (and),
BWOR (or), BWXOR (exclusive or), and BWNOT (ones-complement) operators are valid
constructs. BWAND, BWOR, and BWXOR require two operands. The BWNOT operator
requires one operand.
As an example, the following code segment isolates a copy of several bits in the CTL_1_to_32
word and assigns them to a parameter register.
Then, the least significant four bits of that value are tested and P002 is assigned a value 4985 if any
are set.
P001 := CTL_1_to_32 BWAND 16#0000A005;
IF P001 BWAND 16#F THEN
P002 := 4985;
END_IF;
Specifically, the statements perform the following operations. The first statement uses
16#0000A005 as a mask. The mask corresponds to a binary value as follows:
16# 0000A005 = 2#0000 0000 0000 0000 1010 0000 0000 0101
Thus, the statement
P001:=CTL_1_to_32 BWAND 16#0000A005