Professional Documents
Culture Documents
FECHA: 16-06-16
MATERIA: ROBOTICA
===============================================================
Function:
Depending on the result of and expression, a process is selected and executed.
Syntax:
IF <Expression> THEN <Process> [ELSE <Process>]
Parameters:
<Expression>
Describe a
expression.
numeric
operation
<Process>
Explanations:
If the result of <Expression> is true, then the <Process> in the THEN statement is
executed, and if false, then the <Process> in the ELSE statement is executed.
Omit ELSE if not needed.
The following cannot be used for <Process>:
MELFA-BASIC III-command
ON ... GOTO
ON ... GOSUB
IF ... THEN ... ELSE
Repeat control statement:
Remark statements:
REM
Example:
100 IF MDATA > 10 THEN 1000
110 IF MDATA > 10 GOTO 1000 ELSE GOTO 2000
120 IF MDATA > 10 THEN GOSUB 1000 ELSE GOTO 2000
130 IF MDATA > 10 GOTO 1000 ELSE GOTO *WORK
Reference
ON GOSUB, ON GOTO
================================================================
1.1.
================================================================================
Function:
A process is selected and executed according to the results of an expression. This format is
available for controller software version G1 or later:
Syntax:
IF <Expression> THEN <Process> [ELSE <Process>]
The BREAK command is available for controller software version J1 or later:
IF <Expression> THEN
<Process>
<Process>
BREAK
:
[ELSE]
<Process>
<Process>
BREAK
:
ENDIF
Parameters:
<Expression>
<Process>
Explanations:
Example:
Software Versions previous to G1:
100 IF M1 > 10 THEN 1000
110 IF M1 > 10 THEN GOTO 200 ELSE GOTO 300
200 M1 = 10
210 MOV P1
220 GOTO 400
Software version G1 or later
100 IF M1 > 10 THEN
110 M1 = 10
120 MOV P1
130 ELSE
140 M1 = -10
150 MOV P2
160 ENDIF
For earlier than G1 edition it is also possible to use the following:
250 IF M2 = 0 THEN GOSUB *SUB1 ELSE GOSUB *SUB2
When a IF statement is described inside THEN or ELSE (G1 and later)
300 IF M1 > 10 THEN
310 IF M2 > 20 THEN
320 M1 = 10
330 M2 = 10
340 ELSE
350 M1 = 0
360 M2 = 0
370 ENDIF
380 ELSE
390 M1 = -10
400 M2 = -10
410 ENDIF
In the THEN or the ELSE, it can escape to the next line of ENDIF by BREAK.(Version
J1 or later)
300 IF M1 > 10 THEN
310 IF M2 > 20 THEN BREAK
320 M1 = 10
330 M2 = 10
340 ELSE
350 M1 = -10
360 IF M2 > 20 THEN BREAK
370 M2 = -10
380 ENDIF
390 IF M_BRKCQ = 1 THEN HLT
400 MOV P1
SynactStatement =
"SYNACT" "WHEN" Expression "DO"
( Assignment | PulseStatement ) [ "DELAY" Expression ].
The
SynactStatement
(SYNchronized ACTion)
serves for the fast and
exact reaction on an event
Example:
VAR
OUTPUT BOOL: out_5 AT 6;
ROBTARGET: point_1;
...
BEGIN
...
SYNACT WHEN R_DISTANCE_F > 20.0 DO out_5 := TRUE;
MOVE LIN point_1;
...
ENDPROGRAM
Comentario: este en mi opinin no hace nada solo pero si se lo conbian con el while es una
muy buena opcin de programacin.
=================================================================
ForStatement =
"FOR" Object ":=" Expression "TO" Expression
[ "STEP" Expression ]
StatementBlock "ENDFOR".
The first Expression is the limit to start the loop, the second Expression is the limit to end the
loop. The third Expression is the increment. The default increment is 1. Negative increments
are allowed.
All expressions must be arithmetical expressions. They and the Object must be of data type
INT. Before the StatementBlock of the ForStatement starts execution all three expressions
are evaluated.
In the case of positive increment the StatementBlock is executed if the value of Object which
represents the counter is less or equal to the second Expression. With negative increment the
counter has to be greater or equal for execution. In the case of zero increment the
StatementBlock is executed as long as it is not left by a GotoStatement.
After leaving the loop with a GotoStatement the counter keeps its current value. After normal
completion of the loop the counter is equal to the first value that does not match the condition
for the execution of the statement block.
Example:
FOR i := 1 TO 10
MOVE LIN palette [i];
ENDFOR;
===============================================================
3. Uso del bucle for.
Comentario: el uso del for podramos decir que es muy limitado ya que uno da el incio y un
fin y asi este programa cumple un determinado numero de acciones a la que ha sido
programada con una cantidad limite de pasos.
===============================================================
Function:
This command will continually repeat part of the program between the FOR statement and
NEXT statement until the end conditions are satisfied.
Syntax:
FOR <Counter> = <Default value> TO <End value> [STEP <Increment>]
...
NEXT [<Counter 1> [, <Counter2>] ... ]
Parameters:
<Counter>
<Default Value>
<End Value>
<Increment>
Explanations:
o
o
o
o
o
When the NEXT statement corresponds to the closest FOR statement, the variable name in
the NEXT statement can be omitted. In the example, "MY" in line 50 and "MX" in line 60
can be omitted.
Program
depth:
In this system, it is possible for the control structure to have up to 16 levels within a
program. Exceeding 16 levels will cause an error during execution.
The FOR-NEXT process allows the control structure to go deep within the program.
It is possible to use the FOR-NEXT statements between other FOR-NEXT statements.
With each FOR-NEXT process, the control structure of the program becomes one level
deeper.
Example:
A program that adds the numbers 1 to 10:
10 MSUM=0
30 MSUN=MSUN+MDATA
40 NEXT MDATA
50 END
A program that puts the result of a product of two numbers into a 2-dimensional array
variable:
10 DIM MBOX(10,10)
40 MBOX(MX,MY)=MX*MY
50 NEXT MY
60 NEXT MX
70 END
Function:
Repeatedly executes the program between the FOR statement and NEXT statement until the
end conditions are satisfied.
Syntax:
FOR <Counter> = <Default value> TO <End value> [STEP <Increment>]
...
NEXT [<Counter 1> [, <Counter2>] ... ]
Parameters:
<Counter>
<Default Value>
<End Value>
<Increment>
Explanations:
Cases in which the repeated control is not executed are shown below.
The counter's <Default Value> is greater than <End Value> and <Increment> is a positive
number.
The counter's <Default Value> is smaller than <End Value>, and <Increment> is a negative
number.
If the FOR statement and NEXT statement contradict each other, an error will occur.
Note that when the FOR and NEXT statements are in a nesting structure and have the same
end value, the statement can be described with one NEXT statement. For example, line 50
and 60 in the example can be combined to be written "NEXT M2, M1" in one line.
When the NEXT statement corresponds to the closest FOR statement, the variable name in
the NEXT statement can be omitted. In the example, "M2" in line 50 and "M1" in line 60
can be omitted.
Program depth:
It is possible to describe FOR-NEXT statements between other FOR-NEXT statements.
With each FOR-NEXT process, the control structure of the program becomes one level
deeper.
In this system, it is possible for the control structure to have up to 16 levels within a
program. Exceeding 16 levels will cause an error during execution.
Example:
A program that adds the numbers 1 to 10:
10 MSUM=0
30 MSUM=MSUM+M1
40 NEXT M1
50 END
A program that puts the result of a product of two numbers into a 2-dimensional array
variable
(Using FOR-NEXT as a nesting structure)
10 DIM MBOX(10,10)
40 MBOX(M1,M2)=M1*M2
50 NEXT M2
60 NEXT M1
70 END
Reference
GOSUB, WHILE, END
================================================================================
WhileStatement =
"WHILE" Expression StatementBlock "ENDWHILE".
The statement block will be repetitively executed as long as the evaluation of the logical
Expression returns true (<>0). If the first interpretation of Expression returns false (=0) the
statement block will not be executed at all.
Every WHILE needs an ENDWHILE.
Example:
i := 1;
WHILE i<=10
MOVE LIN palette[i];
i := i+1;
ENDWHILE;
=================================================================
4.1.
=======================================================
Function:
The program between the WHILE statement and WEND statement is repeated until the
loop conditions are satisfied.
Syntax:
WHILE<Loop condition>
...
WEND
Parameters:
<Loop Condition>
Explanations:
The program between the WHILE statement and WEND statement is repeated.
If the result of <Expression> is true (not 0), then the control moves to the line following
the WHILE statement and the process is repeated.
If the result of <Expression> is false (is 0), then the control moves to the line following
the WEND statement.
If a GOTO instruction forces the program to jump out from between a WHILE statement
and a WEND state-ment, the free memory available for control structure (stack memory)
decreases. Thus, if a program is executed continuously, an error will eventually occur.
Write a program in such a way that the loop exits when the condition of the WHILE
statement is met.
Example:
20 WHILE (M1>=-5) AND (M1<=5)
30 M1=-(M1+1)
40 PRINT# 1, M1
50 WEND
60 END