21 Appendix
(2) C1.Prg
1 '## Ver.A3 ##########################################
2 '# Conveyer 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) Register a model number in the X coordinate of the "PRM1" variable/
8 '(2) Register an encoder number in the Y coordinate of the "PRM1" variable/
9 '(3) Register the number of the sensor that monitors workpieces in the Z coordinate of the "PRM1"
variable /
10 'Check the conditions set in the "PRM1" variable
11 MWKMAX=10 'The maximum model number value (for
checking)
12 MECMAX=8 'The maximum encoder number value (for
checking)
13 MWKNO=PRM1.X 'Acquire a model number
14 MENCNO=PRM1.Y 'Acquire an encoder number
15 If MWKNO<1 Or MWKNO>MWKMAX Then Error 9102 'Model number out of range
16 If MENCNO<1 Or MENCNO>MECMAX Then Error 9101 'Encoder number out of range
17 For M1=1 To 10 'Clear the information
18 P_100(M1)=P_Zero 'A variable that stores workpiece positions
19 P_102(M1)=P_Zero 'A variable that stores operation conditions
20 M_101#(M1)=0 'A variable that stores encoder value differences
21 Next M1
22 '(4) Move a workpiece to the position where the photoelectronic sensor is activated/
23 ME1#=M_Enc(MENCNO) 'Acquire encoder data (first time)
24 '(5) Move a workpiece on the conveyer into the robot operation area/
25 '(6) Move the robot to the suction position/
26 ME2#=M_Enc(MENCNO) 'Acquire encoder data (second time)
27 P_100(MWKNO)=P_Fbc(1) 'Acquire the workpiece suction position
(current position)
28 '(7) Perform step operation until END/
29 MED#=ME2#-ME1# 'Calculate the difference of the encoder value.
30 If MED# > 800000000.0# Then MED# = MED#-1000000000.0#
31 If MED# < -800000000.0# Then MED# = MED#+1000000000.0#
32 '
33 M_101#(MWKNO)=MED# 'Store the amount of encoder movement in
a global variable
34 P_102(MWKNO).X=PRM1.Y 'Store encoder numbers in a global variable
35 P_102(MWKNO).Y=PRM1.Z 'Store the sensor number in a global variable
36 End
37 '
38 'This program is "the relation between the position at which the sensor is reacted and the position at
which
39 'the robot absorbs workpieces.
PRM1=(+1.00,+1.00,+810.00,+0.00,+0.00,+0.00,+0.00,+0.00)(,)
21-126 Sample Programs