ACR Electronics FPR-10 PROGRAMMER Manual Página 53

  • Descarregar
  • Adicionar aos meus manuais
  • Imprimir
Vista de página 52
Parker Hannifin
Programming Basics 53
Here is how it works. When the IF condition is true, the subsequent
statements are executed. When the IF condition is false, each ELSEIF
statement is tested in order. When an ELSEIF condition tests true, the
subsequent statements are executed. When the ELSEIF condition test
false, the statements following ELSE condition execute. After
executing the statements following an IF, ELSEIF, or ELSE, the
program moves past the ENDIF to continue program execution.
When using the ELSEIF condition, you can omit the ELSE condition.
When the IF and ELSEIF conditions test false, statement execution
after the ENDIF continues. Think of it as creating a series of IF/THEN
statements.
GOSUB
The GOSUB branches to a subroutine and returns when complete.
You can use GOSUB and RETURN anywhere in a program, but both
must be in the same program. A procedure can contain multiple
RETURN statements. However, on encountering the first RETURN
statement, the program execution branches to the statement
directly following the most recently executed GOSUB statement.
Example
The following example demonstrates a simple GOSUB routine.
GOSUB Label1
_Label1
PRINT “Inside Label1 subroutine”
RETURN
GOTO
The GOTO statement provides an unconditional branch within a
procedure. You can only use the GOTO in the procedure in which it
appears.
You can nest GOTO statements in an IF/THEN statement.
NOTE: The GOTO statement makes code difficult to read and
maintain.
Example
The following demonstrates a simple GOTO statement. The program
sets output bit 32, then moves axis X one incremental unit in the
positive direction. The program pauses until the “Not in Position“ bit
768 is clear, then clears the output, waits 2 seconds, and goes to
LOOP1.
ACC10 DEC10 STP10 VEL1
_LOOP1
SET 32
X/1
INH -768
CLR 32
DWL 2
GOTO LOOP1
Vista de página 52
1 2 ... 48 49 50 51 52 53 54 55 56 57 58 ... 198 199

Comentários a estes Manuais

Sem comentários