November 2, 2024

Fanuc Robot Coding: Jump and Label instructions

Jump and label instructions can be used to define loops. They are best explained through an example. The following code will draw the square (tool center point will define a square), defined through the positions P[1],P[2],P[3], and P[4]

1: J P[1] 100% FINE
2: L P[2] 200 mm/sec FINE
3: L P[3] 200 mm/sec FINE
4: L P[4] 200 mm/sec FINE
5: L P[1] 200 mm/sec FINE

Now, let us modify this code to repeatedly draw a square. We can use this by introducing a label instruction and a jump command. The modified code has the following form

1: LBL[1]
2: J P[1] 100% FINE
3: L P[2] 200 mm/sec FINE
4: L P[3] 200 mm/sec FINE
5: L P[4] 200 mm/sec FINE
6: L P[1] 200 mm/sec FINE
7: JMP LBL[1]

Code line 1 defines a label. This code line is skipped in the first execution of the program. In the first execution, the code is executed until line 7. When we reach command line 7, the code jumps to the label [1], and the code starts again from code line 2. This procedure will run an infinite number of times.