and has no arguments. If the argument of the IF command evaluates false, the controller will skip commands until
the ELSE command. If the argument for the IF command evaluates true, the controller will execute the commands
between the IF and ELSE command.
Nesting IF Conditional Statements
The DMC-42x0 allows for IF conditional statements to be included within other IF conditional statements. This
technique is known as ‘nesting’ and the DMC-42x0 allows up to 255 IF conditional statements to be nested. This is
a very powerful technique allowing the user to specify a variety of different cases for branching.
Command Format - IF, ELSE and ENDIF
Format:
Description
IF conditional statement(s)
Execute commands proceeding IF command (up to ELSE command) if
conditional statement(s) is true, otherwise continue executing at ENDIF
command or optional ELSE command.
ELSE
Optional command. Allows for commands to be executed when argument of
IF command evaluates not true. Can only be used with IF command.
ENDIF
Command to end IF conditional statement. Program must have an ENDIF
command for every IF command.
Example using IF, ELSE and ENDIF:
#TEST
Begin Main Program “TEST”
II,,3
Enable input interrupts on input 1 and input 2
MG “WAITING FOR INPUT 1, INPUT 2”
Output message
#LOOP
Label to be used for endless loop
JP #LOOP
Endless loop
EN
End of main program
#ININT
Input Interrupt Subroutine
IF (@IN[1]=0)
IF conditional statement based on input 1
IF (@IN[2]=0)
2
nd
IF conditional statement executed if 1
st
IF conditional true
MG “INPUT 1 AND INPUT 2 ARE ACTIVE”
Message to be executed if 2
nd
IF conditional is true
ELSE
ELSE command for 2
nd
IF conditional statement
MG “ONLY INPUT 1 IS ACTIVE
Message to be executed if 2
nd
IF conditional is false
ENDIF
End of 2
nd
conditional statement
ELSE
ELSE command for 1
st
IF conditional statement
MG”ONLY INPUT 2 IS ACTIVE”
Message to be executed if 1
st
IF conditional statement is false
ENDIF
End of 1
st
conditional statement
#WAIT
Label to be used for a loop
JP#WAIT,(@IN[1]=0) | (@IN[2]=0)
Loop until both input 1 and input 2 are not active
RI0
End Input Interrupt Routine without restoring trippoints
Subroutines
A subroutine is a group of instructions beginning with a label and ending with an end command (EN). Subroutines
are called from the main program with the jump subroutine instruction JS, followed by a label or line number, and
conditional statement. Up to 8 subroutines can be nested. After the subroutine is executed, the program
sequencer returns to the program location where the subroutine was called unless the subroutine stack is
manipulated as described in the following section.
Example:
An example of a subroutine to draw a square 500 counts per side is given below. The square is drawn at vector
position 1000,1000.
Chapter 7 Application Programming ▫ 112
DMC-42x0 User Manual
Содержание DMC-42 0 Series
Страница 85: ...Chapter 6 Programming Motion 81 DMC 42x0 User Manual Figure 6 14 ECAM cycle with Z axis as master...
Страница 195: ...ICM 2900 PCB Layout Appendices 191 DMC 42x0 User Manual...
Страница 205: ...CB 50 100 Drawings Appendices 201 DMC 42x0 User Manual...
Страница 206: ...Appendices 202 DMC 42x0 User Manual...
Страница 207: ...Appendices 203 DMC 42x0 User Manual...
Страница 208: ...Appendices 204 DMC 42x0 User Manual...
Страница 209: ...Appendices 205 DMC 42x0 User Manual...
Страница 210: ...Appendices 206 DMC 42x0 User Manual...
Страница 211: ...Appendices 207 DMC 42x0 User Manual...
Страница 214: ...CB 50 80 Drawing Appendices 210 DMC 42x0 User Manual...
Страница 215: ...Appendices 211 DMC 42x0 User Manual...