L10 - Branching and PR
L10 - Branching and PR
Robotics
Branching
1
2
objectives
9
10
Register instructions
INDIRECT
DIRECT R[R[3]] = 13
R[3] = 8 R[8] = 13
Indirect addressing is
looking in R[3] to find
the number of the
register to put the
value of 13 into
13
Register instructions
14
limitations
You can mix “+” and “-” in the same instruction. Arithmetic
operations within an instruction that mixes “+” and “-” will
be performed from left to right. You cannot mix “*” or “/”
in an instruction that already contains “+” or “-”.
You can mix “*” and “/” in the same instruction. Arithmetic
operations within an instruction that mixes “*” and “/” will
be performed from left to right. You cannot mix “+” or “-”
in an instruction that already contains “*” or “/”.
The maximum number of arithmetic operations you can have
in the same instruction is 5.
Programs do not read the lines of the instructions again unless
instructed to do so (looped).
15
Register if instructions
16
If i/o instructions
17
Looping a program
• The FOR…DO loop creates a loop that repeats a
series of program instructions for a specified
number of times.
Example: FOR..DO loop program counting up
1. R[1] = 5
2. R[2] = 0
3. LBL [1] This program would
4. J P[1] 100% FINE
5. J P[2] 100% FINE
repeat 5 times then END
6. J P[3] 100% FINE
7. J P[4] 100% FINE
8. R[2] = R[2] + 1
9. IF R[2] >= R[1] JMP LBL [2]
10.JMP LBL [1]
11.LBL [2]
END
18
Looping a program contd.
• The FOR…DO loop creates a loop that repeats a
series of program instructions for a specified number
of times.
Example: FOR..DO loop program counting down
1.R[1] = 5
2.LBL [1]
3.J P[1] 100% FINE This program would
4.J P[2] 100% FINE repeat 5 times then END
5.J P[3] 100% FINE
6.J P[4] 100% FINE
7.R[1] = R[1] - 1
8.IF R[1] =< 0 JMP LBL [2]
9.JMP LBL [1]
10.LBL [2]
END
19
Looping a program contd.
• The WHILE loop creates a loop that executes
until a specific condition is or is not satisfied.
1.LBL [1]
2.IF DI [1] = OFF JMP LBL[2] This program would
3.J P[1] 100% FINE execute until DI [1] (digital input 1)
4.J P[2] 100% FINE is OFF then END
5.J P[3] 100% FINE
6.J P[4] 100% FINE
7.JMP LBL [1]
8.LBL [2]
END
20
Looping a program contd.
• The REPEAT loop executes as long as the
condition is satisfied.
Example: REPEAT loop
program
1.LBL [1]
2.J P[1] 100% FINE
This program would
3.J P[2] 100% FINE
execute until DI [10]
4.J P[3] 100% FINE
(digital input 10)
5.J P[4] 100% FINE
is ON then END
6.IF DI [10] = ON JMP LBL[2]
7.JMP LBL [1]
8.LBL [2]
END
21
Select instructions
If the value of the register equals one of the values, the jump or call
instruction associated with that value is executed.
If the value of the register does not equal one of the values, the jump or
call instruction associated with the word ELSE is executed.
23
Wait instructions
Instructions
position registers &
miscellaneous
26
27
objectives
Use of Position Register Instructions
and apply positional register
statement
Register statement
Register statement
…=…
30
Position register instructions
PR[GRPn:x]=[value]
(1-8)
X,Y,Z,W,P,R X,Y,Z,W,P,R
(1-200)
31
Position register element
PR [i, j]
Indirect:
Direct:
Position register element #= contents of R[x]
Position Register element #
Direct:
Position Register element #
Indirect:
For Cartesian Positions: For Joint positions
Position register #= contents of R[x]
1=x 1=joint 1
2=y 2=joint 2
3=z 3=joint 3
4=w 4=joint 4
5=p 5=joint 5
6=r 6=joint 6
/PROG PREG_ELE
1: !POSITION REG VALUE
2:J P[1:ABOVE JOINT] 100% FINE
3:J P[2] 100% FINE
4: PR[1]=LPOS
5: PR[1,2]=600
6:L PR[1] 100.0inch/min FINE
7:J P[1:ABOVE JOINT] 100% FINE x, y, z, w, p, r,
/END
x, 600 ,z, w, p, r,
32
Position register element: example
Current Robot Position (LPOS) Move Up-Safe Z Height HOME Position
1: PR[10:SNAPSHOT]=LPOS
2: R[8:VALUE HOLDER]=
: PR[10,3:SNAPSHOT]
3: IF R[8:VALUE HOLDER]>100,
: JMP LBL[2]
4: PR[10,3SNAPSHOT]=100
5: J PR[10:SNAPSHOT] 100% FINE
6: LBL[2]
7: J PR[1:HOME] 100% FINE
33
offsets
Offsets are commonly used in Vision and Palletizing Applications
– An input or register can set the value
– Some Mathematical operations are possible
– Representation of the Point and Position Register should match …
(Cartesian or JOINT)
Offset Instructions:
OFFSET CONDITION PR[…]
OFFSET
OFFSET PR[…]
Register statement
Register statement
…=…+…
35
Miscellaneous instructions
• Timers- Used to track time of a routine or function.
• Override- Sets the % value of the programmed speed
• Remark- Allows a comment to be added to the program.
• Message- Displays the message on the user screen.
– USERCLR macro will clear it when used as a program
instruction.