21 Appendix
(4) 1.Prg
The same program as the conveyer tracking.
(5) CM1.Prg
1 '### Ver.A3 ###################################
2 '# Conveyer tracking, communication processing between robot and vision sensor
3 '# Program type : VS communication program
4 '# Date of creation/version : 2012.07.31 A3
5 '# COPYRIGHT : MITSUBISHI ELECTRIC CORPORATION.
6 '##############################################
7 Dim MX(4),MY(4),MT(4),PVS(4) 'X/Y/C/buffer
8 '
9 '##### Main processing #####
10 *S00MAIN
11 GoSub *S10DTGET 'Data acquisition processing
12 GoSub *S20VSINI 'VS initialization processing
13 GoSub *S30CONST 'Condition setting
14 '
15 MEP# = M_Enc(MENCNO)+MEI#+100
16 GoSub *S70VOPEN 'Vision sensor line open + vision program load processing
17 *L00_00
18 GoSub *S40CHKS 'VS recognition check processing
19 GoTo *L00_00
20 End
21 '
22 '##### Data acquisition processing #####
23 *S10DTGET
24 MWKNO=M_09# 'Model number
25 MENCNO=P_102(MWKNO).Y 'Encoder number
26 MVSL=P_103(MWKNO).X 'VS screen size longitudinal distance
27 MWKL=P_103(MWKNO).Y 'Workpiece size longitudinal distance
28 '
29 PTEACH=P_100(MWKNO) 'Position taught to the robot
30 PVSWRK=P_101(MWKNO) 'Position recognized by VS
31 CCOM$=C_100$(MWKNO) 'COM port number
32 CPRG$=C_101$(MWKNO) 'Vision program name
33 Return
34 '
35 '##### Opening communication line #####
36 *S70VOPEN
37 NVClose 'Close communication line
38 NVOpen CCOM$ As #1 'Open communication line and log on
39 Wait M_NvOpen(1)=1 'Wait for line connection
40 NVLoad #1,CPRG$ 'Load the vision program
41 Return
42 '
43 '##### VS initialization processing #####
44 *S20VSINI
45 'Move from the robot coordinate axis (P_ZERO position) to the robot origin when the vision sensor
recognizes workpieces
46 MED1#=M_100#(MENCNO) 'Amount of conveyer movement at calibration between
vision sensor and robot
47 PRBORG=P_EncDlt(MENCNO)*MED1# 'Robot origin when the vision sensor recognizes
workpieces
48 'Return a workpiece recognized by the vision sensor to the position taught to the robot
49 MED2#=M_101#(MWKNO) 'Amount of conveyer movement from vision sensor
recognition to workpiece teaching
50 PBACK=P_EncDlt(MENCNO)*MED2#
51 'Calculate the position of the workpiece that the vision sensor in the robot area recognized.
52 PWKPOS=PRBORG+PVSWRK+PBACK 'Workpiece position recognized by the vision
21-136 Sample Programs