Fanuc Palletizer Robot Program Example

/PROG PALLETIZE
/ATTR
COMMENT = "Multi-Layer Palletizing Program";
/MN
1: UFRAME_NUM=1 ; Use User Frame 1 for palletizing
2: UTOOL_NUM=1 ; Use Tool 1 (Gripper)
3: R[1]=1 ; Initialize row counter
4: R[2]=1 ; Initialize column counter
5: R[3]=0 ; Box counter
6: R[4]=1 ; Initialize layer counter
7: PR[10]=P[1] ; Set first pick position
8: PR[20]=P[2] ; Set first place position
9: PR[30]=P[2] ; Store original place position for resetting Z

10: J P[10] 100% FINE ; Move to home position
 
LBL[1] ; Start Loop
11: L PR[10] 500mm/sec FINE ; Move to pick position
12: DO[1]=ON ; Activate vacuum gripper
13: WAIT 0.5 sec ; Ensure gripping
14: L PR[20] 500mm/sec CNT50 ; Move to place position
15: DO[1]=OFF ; Release box
16: WAIT 0.5 sec ; Ensure release
17: R[3]=R[3]+1 ; Increment box counter
18: R[2]=R[2]+1 ; Increment column counter
19: IF R[2] <= 4, JMP LBL[2] ; If not last column, move right
20: R[2]=1 ; Reset column counter
21: R[1]=R[1]+1 ; Increment row counter
22: IF R[1] <= 3, JMP LBL[3] ; If not last row, move up
23: R[1]=1 ; Reset row counter
24: R[4]=R[4]+1 ; Increment layer counter
25: IF R[4] <= 3, JMP LBL[5] ; If not last layer, move up
26: JMP LBL[4] ; If all layers are done, end program
 
LBL[2] ; Shift column
27: PR[20,1]=PR[20,1] + 200 ; Shift X-axis by 200mm
28: JMP LBL[1] ; Repeat cycle
 
LBL[3] ; Shift row
29: PR[20,1]=P[2,1] ; Reset X-axis to starting column
30: PR[20,2]=PR[20,2] + 150 ; Shift Y-axis by 150mm
31: JMP LBL[1] ; Repeat cycle
 
LBL[5] ; Shift layer
32: PR[20]=PR[30] ; Reset X and Y to first position
33: PR[20,3]=PR[20,3] + 100 ; Move up 100mm for next layer
34: JMP LBL[1] ; Repeat cycle
 
LBL[4] ; End Program
35: J P[10] 100% FINE ; Return to home position
36: END

 

Explanation

1. Program Initialization

/PROG PALLETIZE
/ATTR
COMMENT = "Multi-Layer Palletizing Program";
/MN
  • /PROG PALLETIZE → Defines the program name (PALLETIZE).
  • COMMENT = "Multi-Layer Palletizing Program" → Provides a description of the program.
  • /MN → Marks the start of the main program instructions.

2. Setting Up Frames, Tools, and Registers

1: UFRAME_NUM=1 ; Use User Frame 1 for palletizing
2: UTOOL_NUM=1 ; Use Tool 1 (Gripper)
  • UFRAME_NUM=1 → Selects User Frame 1, which defines the pallet coordinate system.
  • UTOOL_NUM=1 → Selects Tool Frame 1, which defines the gripper’s position relative to the robot.

3. Defining Registers (R) and Position Registers (PR)

3: R[1]=1 ; Initialize row counter
4: R[2]=1 ; Initialize column counter
5: R[3]=0 ; Box counter
6: R[4]=1 ; Initialize layer counter
  • R[1] → Keeps track of the current row.
  • R[2] → Keeps track of the current column.
  • R[3] → Counts the total number of boxes placed.
  • R[4] → Tracks the current layer.
 
7: PR[10]=P[1] ; Set first pick position
8: PR[20]=P[2] ; Set first place position
9: PR[30]=P[2] ; Store original place position for resetting Z
  • PR[10] → Defines the pick position (where the robot picks up the box).
  • PR[20] → Defines the place position (where the robot places the box).
  • PR[30] → Stores the original place position, used for resetting after each layer.

4. Moving to Home Position

10: J P[10] 100% FINE ; Move to home position
  • J P[10] → Moves the robot to a safe home position.
  • 100% FINE → Uses joint motion at full speed with precise stopping.

5. Start of the Main Palletizing Loop

LBL[1] ; Start Loop
  • LBL[1] → Label for the main loop that repeats for each box.

5.1 Picking Up the Box

11: L PR[10] 500mm/sec FINE ; Move to pick position
12: DO[1]=ON ; Activate vacuum gripper
13: WAIT 0.5 sec ; Ensure gripping
  • L PR[10] → Moves the robot linearly to the pick position.
  • DO[1]=ON → Activates the vacuum gripper.
  • WAIT 0.5 sec → Ensures the gripper has time to securely grip the box.

5.2 Placing the Box

14: L PR[20] 500mm/sec CNT50 ; Move to place position
15: DO[1]=OFF ; Release box
16: WAIT 0.5 sec ; Ensure release
  • L PR[20] → Moves the robot linearly to the place position.
  • CNT50 → Uses 50% blending, allowing smooth transitions.
  • DO[1]=OFF → Turns off the vacuum, releasing the box.
  • WAIT 0.5 sec → Ensures the box is fully placed before moving.

5.3 Updating Counters

17: R[3]=R[3]+1 ; Increment box counter
18: R[2]=R[2]+1 ; Increment column counter
19: IF R[2] <= 4, JMP LBL[2] ; If not last column, move right
  • R[3] = R[3] + 1 → Increases the total box count.
  • R[2] = R[2] + 1 → Moves to the next column in the row.
  • If R[2] ≤ 4, the program jumps to LBL[2] to shift right.

6. Shifting to the Next Column

LBL[2] ; Shift column
27: PR[20,1]=PR[20,1] + 200 ; Shift X-axis by 200mm
28: JMP LBL[1] ; Repeat cycle
  • PR[20,1] = PR[20,1] + 200 → Moves the place position 200mm to the right.
  • Jumps back to LBL[1] to pick and place the next box.

7. Moving to the Next Row

20: R[2]=1 ; Reset column counter
21: R[1]=R[1]+1 ; Increment row counter
22: IF R[1] <= 3, JMP LBL[3] ; If not last row, move up
  • R[1] = R[1] + 1 → Moves to the next row.
  • If R[1] ≤ 3, the program jumps to LBL[3] to move up.
LBL[3] ; Shift row
29: PR[20,1]=P[2,1] ; Reset X-axis to starting column
30: PR[20,2]=PR[20,2] + 150 ; Shift Y-axis by 150mm
31: JMP LBL[1] ; Repeat cycle
  • PR[20,1] = P[2,1] → Resets X to the first column.
  • PR[20,2] = PR[20,2] + 150 → Moves Y up by 150mm.
  • Jumps back to LBL[1] to continue.

8. Moving to the Next Layer

23: R[1]=1 ; Reset row counter
24: R[4]=R[4]+1 ; Increment layer counter
25: IF R[4] <= 3, JMP LBL[5] ; If not last layer, move up
  • R[4] = R[4] + 1 → Moves to the next layer.
  • If R[4] ≤ 3, jumps to LBL[5] to move up.
 
LBL[5] ; Shift layer
32: PR[20]=PR[30] ; Reset X and Y to first position
33: PR[20,3]=PR[20,3] + 100 ; Move up 100mm for next layer
34: JMP LBL[1] ; Repeat cycle
  • PR[20] = PR[30] → Resets X and Y.
  • PR[20,3] = PR[20,3] + 100 → Moves Z up by 100mm.

9. Ending the Program

LBL[4] ; End Program
35: J P[10] 100% FINE ; Return to home position
36: END
  • Moves to home position and ends the program.