11/25/96
➆
6270 Programming Tips
89
Conditional looping (REPEAT/UNTIL and WHILE/NWHILE) entails repeating a set of
commands until or while a certain condition exists. In conditional branching
(IF/ELSE/NIF), a specific set of commands is not executed until a certain condition exists.
Both rely on the fulfillment of a conditional expression, a condition specified in the UNTIL,
WHILE, or IF commands.
Flow Control
Expression
Examples
This section provides examples of expressions that can be used in conditional branching and
looping commands (UNTIL, WHILE, and IF). These expressions can be constructed, in
conjunction with relational and logical operators, with the following operands:
❏ Numeric Variables and Binary Variables
❏ Inputs and Outputs
❏ Current Motion Parameters and Status
❏ Current Actual and Commanded Position
❏ Error, Axis, and System Status
❏ Timer Value
❏ Data Read from the Serial Port
❏ Data Read from the RP240
Numeric and
Binary Variables
A numeric variable (VAR) can be used within an expression, if the variable is compared against
another numeric variable, a value, or one of the comparison commands (A, AD, ANV, D, DAC,
FB, PC, PCA, PCC, PCE, PER, PE, TIM, V, VEL). When comparing a variable against
another value, variable, or comparison command, the relational operators (=, >, >=, <, <=,
<>) and logical operators (AND, OR, NOT) are used.
Expression Description
(VAR1<VAR2) True expression if variable 1 is less than variable 2
(VAR1>=25ØØ) True expression if variable 1 is greater than or equal to 2500
(VAR1=1AD) True expression if variable 1 is equal to the deceleration of
axis 1
(VAR1<VAR2 AND VAR4>1PE) True expression if variable 1 is less than variable 2 and
variable 4 is greater than axis 1 actual position
A binary variable (VARB) can be used within an expression, if the variable is compared against
another binary variable, or a value. When comparing a variable against another value or
variable, the relational operators (=, >, >=, <, <=, <>) and logical operators (AND, OR, NOT)
are used.
Expression Description
(VARB1<>VARB2) True expression if binary variable 1 is not equal to binary
variable 2
(VARB1=b11Ø1 X111) True expression if binary variable 1 is equal to 1101 X111
(VARB1<VARB2 AND VARB4>hF) True expression if binary variable 1 is less than binary
variable 2 and binary variable 4 is greater than the
hexadecimal value of F
Inputs and
Outputs
An input or output operand (IN, INO, LIM, OUT) can be used within an expression, if the
operand is compared against a binary variable or a binary or hexadecimal value. When making
the comparison, the relational operators (=, >, >=, <, <=, <>) and logical operators (AND,
OR, NOT) are used.
Expression Description
(IN.12=b1) True expression if input 12 is equal to 1
(LIM>h3) True expression if limit status is greater than hexadecimal 3
Current Motion
Parameters and
Status
Motion parameters consist of A, AD, D, V, VEL, and MOV. The motion parameters can be
used within an expression, if the operand is compared against a numeric variable or value. The
motion status operand must be compared against a binary variable or a binary or hexadecimal
value. When making the comparison, the relational operators (=, >, >=, <, <=, <>) and
logical operators (AND, OR, NOT) are used.
Expression Description
(VAR1<1VEL) True expression if the value of variable 1 is less than the actual
velocity of axis 1
(1AD=25ØØØ) True expression if axis 1 deceleration equals 25000
(MOV=bØØ) True expression if moving status equals ØØ (axes 1 & 2 are not
moving)
Commentaires sur ces manuels