11 - 240 11 - 240
MELSEC-Q
11 INSTRUCTIONS AND FUNCTIONS
Program Example
(1) Program example for a format 1 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)=255
:
'Specifies the station number to
communicate with to the local station
130 TBL%(1)=516
:
'Specifies to read random devices of the
Q/QnA series PLC CPU
140 TBL%(2)=&H101
:
'Reads one bit device point or one word
device point
150 TBL%(3)=&H1
:
'Reads one double-word device point
160 TBL%(4)=0
:
'Fixed value
170 TBL%(5)=168
:
'Specifies data registers (D)
180 D!=0
:
'Specifies device number 0
190 GOSUB 400
200 TBL%(6)=L%
:
'Stores the lower digit of the device number
210 TBL%(7)=H%
:
'Stores the higher digit of the device
number
220 TBL%(8)=0
:
'Specifies word units as processing unit
230 TBL%(9)=0
:
'Fixed value
240 TBL%(10)=144
:
'Specifies internal relays (M)
250 D!=0
:
'Specifies device number 0
260 GOSUB 400
270 TBL%(11)=L%
:
'Stores the lower digit of the device number
280 TBL%(12)=H%
:
'Stores the higher digit of the device
number
290 TBL%(13)=0
:
'Specifies bit units as processing unit
300 TBL%(14)=0
:
'Fixed value
310 TBL%(15)=168
:
'Specifies data registers (D)
320 D!=8000
:
"Specifies device number 8000
330 GOSUB 400
340 TBL%(16)=L%
:
'Stores the lower digit of the device number
350 TBL%(17)=H%
:
'Stores the higher digit of the device
number
360 TBL%(18)=0
:
'Specifies double-word units as processing
unit
370 TBL%(19)=0
:
'Fixed value
380 PCRD TBL%(),A%()
:
'Executes the read operation
390 END