21 Appendix
(4) CM1.Prg
1 '## Ver.A3 ####################################
2 '# Conveyer tracking, sensor monitoring program
3 '# Program type : CM1.prg
4 '# Date of creation/version : 2012.07.31 A3
5 '# COPYRIGHT : MITSUBISHI ELECTRIC CORPORATION.
6 '##############################################
7 '
8 '##### Main processing #####
9 *S00MAIN
10 GoSub *S10DTGET 'Processing for acquiring required data
11 *LOOP
12 GoSub *S20WRITE 'Workpiece position writing processing
13 GoTo *LOOP
14 End
15 '##### Data acquisition processing #####
16 *S10DTGET
17 'Acquire the suction position, amount of encoder movement and encoder number set with program C
18 MWKNO=M_09# 'Acquire model number
19 M10ED#=M_101#(MWKNO) 'Amount of encoder movement
20 MENCNO=P_102(MWKNO).X 'Encoder number
21 MSNS=P_102(MWKNO).Y 'Sensor number
22 'Calculate the workpiece position (X,Y) when the sensor is activated
23 PWPOS=P_100(MWKNO)-P_EncDlt(MENCNO)*M10ED#
24 Return
25 '##### Position data writing processing #####
26 *S20WRITE
27 If M_In(MSNS)=0 Then GoTo *S20WRITE 'Wait for a workpiece to activate the photoelectronic sensor
28 MENC#=M_EncL(MENCNO) 'Encoder number
28 MENC#=M_Enc(MENCNO) 'Encoder number
29 TrWrt PWPOS,MENC#,MWKNO,1,MENCNO 'Write data (workpiece position and encoder value) to the
tracking buffer
30 *L20WAIT
31 If M_In(MSNS)=1 Then GoTo *L20WAIT
32 Return
CR750-Q/CR751-Q series, CRnQ-700 series controller
CR750-D/CR751-D series, CRnD-700 series controller
(
)
The command is deferent between iQ
Platform controller (CR750-Q/CR751-Q
series, CRnQ-700 series) and stand alone
type controller (CR750-D/CR751-D series,
CRnD-700 series).
In the CR750-Q/CR751-Q series,
CRnQ-700 series series, it is necessary to
use the latch encoder data (M_ENCL)
after confirmation with an input signal.
Sample Programs 21-133