3) programming examples – Yaskawa MP2000 Series: User's Manual for Motion Programming User Manual
Page 195
8 Command Reference
8.4.1 Branching Commands (IF ELSE IEND)
8-88
The conditional expressions that can be used for the branching commands are as follows.
(a) Bit Data Comparison
(b) Integer/Double Integer/Real Number Data Comparison
(3) Programming Examples
A programming example of branching commands (IF ELSE IEND) is shown below.
Format
• Use == (MATCH) command for data comparison.
• Specify a register on the left, and 0 or 1 on the right.
IF MB000000 == 0; "MB000000 = 0
IF MB000000 == 1; "MB000000 = 1
Operations in
Conditional
Expression
• &,
⏐, and ! (AND, OR, and NOT) can be used.
IF (MB000000 & MB000001) == 1; "MB000000=1 AND MB000001=1
IF (MB000000 & !MB000001) == 1; "MB000000=1 AND MB000001=0
IF (MB000000 | MB000001) == 1;
"MB000000=1 OR MB000001=1
IF (MB000000 | !MB000001) == 1;
"MB000000=1 OR MB000001=0
Syntax Error
Examples
• When a <> (MISMATCH) is used:
IF MB000000 <> 0; => Syntax error
• When a numerical value is specified on the left, or a register is specified on the right:
IF 1 == MB000000; => Syntax error
IF MB000000 == MB000001; => Syntax error
• No data comparison command:
IF MB000000; => Syntax error
IF (0); => Syntax error
• When more than one data comparison command is used:
IF (MB000000 == 0) & (MB000001 == 1); => Syntax error
Format
• All data comparison commands (==, <>, >, <, >=, <=) can be used.
• Specify a register either on the left or right.
IF MW00000 == 3; "MW00000 = 3
IF ML00000 <> ML00002; "ML00000
≠ ML00002
IF 1.23456 >= MF00000; "1.23456
≥ MF00000
Operations in
Conditional
Expression
• Arithmetic operations and logic operations can be used.
IF MW00000 == (MW00001/3); "MW00000 = (MW00001
÷ 3)
IF (ML00000 & F0000000H) <> ML00002; "(ML00000
∧ F0000000H) ≠ ML00002
IF 1.23456 >= (MF00000 * MF00002); "1.23456
≥ (MF00000 × MF00002)
Syntax Error
Examples
• When a constant is specified both on the left and right:
IF 0 == 3; => Syntax error
IF (3.14*2*1000) > 9000.0; => Syntax error
• No comparison command:
IF MW000000; => Syntax error
IF (-1); => Syntax error
• When more than one data comparison command is used:
IF (MW00000 < 0) & (MW000001 > 0); => Syntax error
IF MB000000== 1;
MOV [A1] 10000; " If MB000000 is ON, A1 starts positioning.
ELSE;
MOV [B1] 10000; " If MB000000 is OFF, B1 starts positioning.
IEND;
EXAMPLE