Example of FANUC TP program
Here is an example of a simple pick and place using the registers listed in Table 2.
Register number |
Register type |
Description |
---|---|---|
R[1] |
Registers |
For loop counter |
R[21] |
Registers |
Last plugin error raised by EYE_CHECK_LAST_ERROR |
PR[19] |
Position Reg |
Robot position to place the part |
PR[20] |
Position Reg |
Last part position found (EYEPos) |
PR[21] |
Position Reg |
Last part position with z-offset (EYEPosDz) |
PR[22] |
Position Reg |
Robot position out of field of view (out_of_view) |
1: ! Configure the communication using client C1: and C2:
2: CALL EYE_CONFIGURE(1,2)
3: CALL EYE_CHECK_LAST_ERROR
4: IF (R[21]<>0) THEN
5: ! Not well configured
6: ABORT
7: ENDIF
8:
9: ! Initialize the robot
10: UTOOL_NUM=2
11: UFRAME_NUM=0
12: CALL VENTURI_OFF
13:
14: ! Move out of field of view
15: J PR[22:out_of_view] 100% FINE
16:
17: ! Start EYE+ in production state
18: CALL EYE_START_PRODUCTION(12345)
19: CALL EYE_CHECK_LAST_ERROR
20: IF (R[21]<>0) THEN
21: ABORT
22: ENDIF
23:
24: ! Loop to pick and place
25: IF (R[21]=0) THEN
26: FOR R[1]=1 TO 50
27: ! Get 1 part coord. in PR[20]
28: CALL EYE_GET_PART
29: CALL EYE_CHECK_LAST_ERROR
30:
31: ! If no error, pick the part
32: IF (R[21]=0) THEN
33: ! Change to Asycube frame
34: UFRAME_NUM=3
35:
36: ! Set EYEPos component Z. W, P
37: PR[20, 3]=0
38: PR[20, 4]=(-180)
39: PR[20, 5]=0
40:
41: ! Calculate position EYEPosDz
42: PR[21]=PR[20]
43: PR[21, 3]=15
44:
45: ! Move to position EYEPosDz
46: J PR[21] 100% FINE
47:
48: ! Move to position EYEPos
49: J PR[20] 100% FINE
50:
51: ! Pick the part
52: CALL VENTURI_ON
53:
54: ! Move to position EYEPosDz
55: J PR[21] 100% FINE
56:
57: ! Change to "place" frame
58: UFRAME_NUM=0
59:
60: ! Place the part
61: J PR[19] 100% FINE
62: CALL VENTURI_OFF
63: ENDIF
64: ENDFOR
65: ! End of the loop
66: ENDIF
67:
68: ! Stop the EYE+ production state
69: CALL EYE_STOP("production")
70: CALL EYE_CHECK_LAST_ERROR
71: IF (R[21]<>0) THEN
72: ABORT
73: ENDIF
[End]