11 - 244 11 - 244
MELSEC-Q
11 INSTRUCTIONS AND FUNCTIONS
(3) Program example for a format 3 control table
100 'A program example that reads the device memory of the Q/QnA series PLC CPU
110 DIM TBL%(20),A%(10)
:
'Defines the arrays
120 TBL%(0)=256
:
'Specifies a format 2 control table
130 TBL%(1)=1
:
'Specifies network number 1
140 TBL%(2)=1
:
'Specifies station number 1
150 TBL%(4)=516
:
'Specifies to read random devices of a
Q/QnA series PLC CPU
160 TBL%(5)=&H3E3
:
'Specifies the requested CPU (PLC No.4)
170 TBL%(6)=&H101
:
'Reads one bit device point or one word
device point
180 TBL%(7)=&H1
:
'Reads one double-word device point
190 TBL%(8)=0
:
'Fixed value
200 TBL%(9)=168
:
'Specifies data registers (D)
210 D!=0
:
'Specifies device number 0
220 GOSUB 430
230 TBL%(10)=L%
:
'Stores the lower digit of the device number
240 TBL%(11)=H%
:
'Stores the higher digit of the device
number
250 TBL%(12)=0
:
'Specifies word units as processing unit
260 TBL%(13)=0
:
'Fixed value
270 TBL%(14)=144
:
'Specifies internal relays (M)
280 D!=0
:
'Specifies device number 0
290 GOSUB 430
300 TBL%(15)=L%
:
'Stores the lower digit of the device number
310 TBL%(16)=H%
:
'Stores the higher digit of the device
number
320 TBL%(17)=0
:
'Specifies bit units as processing unit
330 TBL%(18)=0
:
'Fixed value
340 TBL%(19)=168
:
'Specifies data registers (D)
350 D!=8000
:
"Specifies device number 8000
360 GOSUB 430
370 TBL%(20)=L%
:
'Stores the lower digit of the device number
380 TBL%(21)=H%
:
'Stores the higher digit of the device
number
390 TBL%(22)=0
:
'Specifies double-word units as processing
unit