21 Appendix
(3) C1.Prg
1 '### Ver.A3 #########################################
2 '# Network vision tracking, workpiece suction position registration program
3 '# Program type : C1.prg
4 '# Date of creation/version : 2012.07.31 A3
5 '# COPYRIGHT : MITSUBISHI ELECTRIC CORPORATION.
6 '####################################################
7 '(1) Store a model number in the X coordinate of the "PRM1" variable/
8 '(2) Store an encoder number in the Y coordinate of the "PRM1" variable/
9 '(3) Check live images and register the length in the movement direction to the X coordinate of the "PRM2"
variable/
10 '(4) Store the workpiece length in the Y coordinate of the "PRM2" variable/
11 '(5) Enter the COM port number to be opened for communication after "CCOM$=" in the following line/
12 CCOM$="COM2:" 'Set the number of the port to be opened
13 '(6) Enter the vision program name after "CPRG$=" in the following line/
14 CPRG$="TRK.JOB" 'Set the vision program name
15 '(7) Place workpieces to be tracked in locations recognizable by the vision sensor/
16 '(8) Place the vision sensor in the "online" status/
17 '(9) When the program stops, open program C1 with T/B/
18 MWKNO=PRM1.X 'Acquire the model number
19 MENCNO=PRM1.Y 'Acquire the encoder number
20 'Establish a communication line with the vision sensor via the opened port
21 NVClose 'Close communication line
22 NVOpen CCOM$ As #1 'Open communication line and log on
23 Wait M_NvOpen(1)=1 'Wait to log on to the vision sensor
24 EBRead #1,"",MNUM,PVS1,PVS2,PVS3,PVS4 'Acquire data of one recognized workpiece
25 P_101(MWKNO)=PVS1 'Acquire data of the first recognized workpiece
26 ME1#=M_Enc(MENCNO) 'Acquire encoder data 1
27 NVClose #1
28 Hlt
29 '(10) Move a workpiece on the conveyer until it gets within the robot operation area/
30 '(11) Move the robot to the suction position/
31 ME2#=M_Enc(MENCNO) 'Acquire encoder data 2
32 P_100(MWKNO)=P_Fbc(1) 'Acquire position 1
33 '(12) Perform step operation until END/
34 MED#=ME2#-ME1# 'Calculate the amount of encoder movement
35 If MED# > 800000000.0# Then MED# = MED#-1000000000.0#
36 If MED# < -800000000.0# Then MED# = MED#+1000000000.0#
37 M_101#(MWKNO)=MED# 'Amount of encoder movement
38 P_102(MWKNO)=PRM1 'Encoder number
39 P_103(MWKNO)=PRM2 'Image size and workpiece size
40 C_100$(MWKNO)=CCOM$ 'COM port number
41 C_101$(MWKNO)=CPRG$ 'Vision program name
42 End
43 '
44 'This program is "the relation between the workpiece position recognized by the network vision sensor and
45 ' the position at which the robot suctions workpieces.
PRM1=(+1.00,+1.00,+0.00,+0.00,+0.00,+0.00,+0.00,+0.00)(0,0)
PVS1=(+0.00,+0.00,+0.00,+0.00,+0.00,+0.00,+0.00,+0.00)(0,0)
PVS2=(+0.00,+0.00,+0.00,+0.00,+0.00,+0.00,+0.00,+0.00)(0,0)
PVS3=(+0.00,+0.00,+0.00,+0.00,+0.00,+0.00,+0.00,+0.00)(0,0)
PVS4=(+0.00,+0.00,+0.00,+0.00,+0.00,+0.00,+0.00,+0.00)(0,0)
PRM2=(+170.00,+30.00,+0.00,+0.00,+0.00,+0.00,+0.00,+0.00)(0,0)
Sample Programs 21-135