Emerson EZMotion User Manual page 173

Table of Contents

Advertisement

Call Program
This program flow instruction is used to call another program. When the called program finishes the controller picks up where
it left off in the program that called it. This is often used when a section of code is used in multiple places in a program. By
moving the code to another program and then calling that program, the total number of program lines can be reduced. This
can also make the program easier to understand. Care should be taken not to "nest" more than four program calls due to
processor stack overflow. Therefore, no more than four different programs should be called without returning to the original
program.
In the diagram below, => Represents a Call Program instruction.
Program0=>Program1=>Program2=>Program3=>Program4 => NO MORE THAN 4!
Example:
Call Program.10
Example:
Call Program.100
Case
When the Switch Instruction value and the case number instruction match, all the instructions that follow the case instruction
up to a Break or EndSwitch are executed. This includes instructions following the next Case instructions and the default
instruction found. Duplicate "Case numbers" are not allowed.
Default:
The default is an optional statement within the switch instruction. It must follow all the case instruction within a Switch
instruction. When none of the case instruction numbers match the switch expression value the program instructions following
the Default instruction are executed. They are also executed if there is no break instruction in the previous case statements
Do While/Loop
This program instruction is used for repeating a sequence of code as long as an expression is true. To loop forever use
"TRUE" as the test expression as shown in the third example below. The test expression is tested before the loop is entered.
If the test expression is evaluated as False (0) the code in the loop will be skipped over.
Logical tests (AND, OR, NOT) can be used in the Do While/Loop instruction. Parenthesis "()" can be used to group the logical
tests.
Example:
Do While EZInput.1=ON
Index.1.Initiate
Dwell For Time 1.000 'seconds
Loop
Example:
Do While (Slot2.Input.4=ON AND Slot2.Input.4=OFF)
Index.1.Initiate
Dwell For Time 1.000 'seconds
Loop
Example:
Do While (TRUE)
Index.1.Initiate
Dwell For Time 1.000 'seconds
Loop
Else
This program flow instruction is used in conjunction with the If/Then/Endif instruction. If the If/Then test condition evaluates to
true the code after the If/Then and before the Else is executed. If the test evaluates to false the code between the Else and the
Endif is executed.
Example:
If EZInput.1=ON Then
EZOutput.1=ON
EZOutput.2=OFF
Else
EZOutput.1=OFF
EZOutput.2=ON
Endif
Example:
If (SPInput.5=ON) Then
Jog.0.Vel = 1.0 'in/s
Else
Jog.0.Vel = 0.1 'in/s
Endif
EZMotion User/Programming Guide
Revision A8
'Program 10 contains a complex home
'routine.
'Program 100 contains a "teach position"
'routine.
www.controltechniques.com
161

Advertisement

Table of Contents
loading

Table of Contents