1.6 Program structure

1.6.1 CASE statements

Programming format:

CASE expression OF constant 1 GOTOF LABEL1 … DEFAULT GOTOF LABELn

CASE instruction can jump correspondingly according to the different actual value(INT). CASE instruction detects the value in the expression, and then the program transfers to the destination which the constant is corresponding. If the value of the expression is not in the constant class table, it would determine the jump destination by using DEFAULT instruction. If DEFAULT instruction is not programmed, the block which follows the CASE instruction is the jump target.

Example:

DEF INT VAR1, VAR2

CASE (VAR1+VAR2) OF 7 GOTOF MARK1 9 GOTOF MARK2 DEFAULT GOTOF MARK3

MARK1: G00 X1 Y1

MARK2: G00 X2 Y2

MARK3: G00 X3 Y3

1.6.2 IF statements

Programming format:

IF expression

NC block

ELSE

NC block

ENDIF

IF-ELSE-END block is used for the alternative, if the expression evaluates to TRUE, IF branch program is executed, otherwise the ELSE branch is executed. The ELSE branch can be canceled.

Example:

DEF INT VAR1, VAR2

IF VAR1>VAR2

G00 X1 Y1

ELSE

G00 X2 Y2

ENDIF

 IF statements can be nested, nesting can not be more than nine layers.

1.6.3 WHILE statements

Programming format:

WHILE expression

NC block

ENDWHILE

As long as the expression is TRUE, the WHILE loop is executed. To get out of the loop, we need to modify the structure of the value of the expression until it is FALSE.

Example:

DEF REAL HH=9

G01 X0

WHILE HH>0

G91 X=HH

HH=HH-1

ENDWHILE

0 (0)
Article Rating (No Votes)
Rate this article
Attachments
There are no attachments for this article.
Comments
There are no comments for this article. Be the first to post a comment.
Full Name
Email Address
Security Code Security Code
Related Articles RSS Feed
5.1 Overview of cycles
Viewed 1718 times since Fri, Aug 26, 2016
2.9 Exact stop/continuous-path control mode: G09/G60/G64
Viewed 2989 times since Thu, Aug 25, 2016
5.3 Turning cycles
Viewed 2048 times since Fri, Aug 26, 2016
Preface
Viewed 1752 times since Thu, Aug 25, 2016
3.5 Tool radius compensation G40/G41/G42
Viewed 5590 times since Fri, Aug 26, 2016
2.7 Axis movements
Viewed 11575 times since Thu, Aug 25, 2016
5.2.3 Deep-hole drilling CYCLE83
Viewed 13816 times since Fri, Aug 26, 2016
1.7 The instructions table
Viewed 2028 times since Thu, Aug 25, 2016
5.2.4 Rigid tapping CYCLE84
Viewed 3092 times since Fri, Aug 26, 2016
5.3.6 Copy cutting CYCLE99
Viewed 5268 times since Fri, Aug 26, 2016