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
4.1 Arithmetic parameter R
Viewed 1572 times since Fri, Aug 26, 2016
2.10 Dwell Time: G04
Viewed 2176 times since Thu, Aug 25, 2016
5.2.6 Boring (boring 2) CYCLE86
Viewed 11873 times since Fri, Aug 26, 2016
3.3 Tool offset table
Viewed 3904 times since Fri, Aug 26, 2016
5.3.4 Thread undercut CYCLE96
Viewed 6355 times since Fri, Aug 26, 2016
3.5 Tool radius compensation G40/G41/G42
Viewed 5587 times since Fri, Aug 26, 2016
5.2.4 Rigid tapping CYCLE84
Viewed 3090 times since Fri, Aug 26, 2016
5.3.2 Undercut CYCLE94
Viewed 3560 times since Fri, Aug 26, 2016
2.2 Dimensions in metric units and inches: G70/G71
Viewed 2040 times since Thu, Aug 25, 2016
2.6 Work plane G17/G18/G19
Viewed 6342 times since Thu, Aug 25, 2016