68 www.emersonct.com SM-EZMotion Module User Guide
8.4 Program Instruction List
Figure 105: Program Instruction List
8.4.1 Program Flow Instructions
8.4.1.1 If/Then/EndIf
This is a program flow control instruction used to
selectively run a section of code only if a logical test
condition is true. If the test evaluates to true the code
between the If/Then and Endif lines is executed. If the test
evaluates to false the code is not executed and the
program skips to the next line of code after the Endif.
Logical tests (AND, OR, NOT) can be used in the If/Then/
Endif instruction. Parenthesis "()" can be used to group the
logical tests.
Example:
If EZInput.1=ON Then
EZOutput.1=ON
EZOutput.2=OFF
Endif
Example:
If (EZInput.1=ON AND EZInput.2=OFF) Then
EZOutput.1=ON
EZOutput.2=OFF
Endif
Example:
If (SPInput.4=OFF) Then
Jog.0.PlusInitiate 'Vel=20in/s
Wait For SPInput.4=OFF
Jog.Stop
Endif
Example:
If (NOT SPInput.5=ON) Then
Jog.0.MinusInitiate 'Vel=20in/s
Wait For SPInput.5=OFF
Jog.Stop
Endif
8.4.1.2 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
8.4.1.3 For Count/Next
This instruction is used to execute a section of code a
specific number of times.
The user must enter the two numbers that control the
repeat count. This instruction can either count up or count
down. If the first number provided by the user is larger than
the second number, then the instruction will count down. If
the first number provided by the user is smaller than the
second number, then the instruction will count up. The