11 - 334 11 - 334
MELSEC-Q
11 INSTRUCTIONS AND FUNCTIONS
(3) Program example for a format 3 control table
100 'A program example that writes data nonsequentially to devices in a Q/QnA series PLC CPU’s
device memory
110 DIM TBL%(20),A%(10)
:
'Defines arrays
120 TBL%(0)=257
:
'Specifies a format 3 control table
130 TBL%(1)=1
:
'Specifies network number 1
140 TBL%(2)=1
:
'Specifies station number 1
150 TBL%(4)=516
:
'Specifies to write data to individual devices
of the Q/QnA series PLC CPU
160 TBL%(5)=&H3E3
:
'Specifies the requested CPU (fourth CPU)
170 TBL%(6)=&H101
:
'Writes to one bit device point and one
word device point
180 TBL%(7)=&H1
:
'Writes to one double-word device point
190 TBL%(8)=168
:
'Specifies data registers (D)
200 D!=0
:
'Specifies device number 0
210 GOSUB 430
220 TBL%(9)=l%
:
'Stores the lower digit of the device number
230 TBL%(10)=H%
:
'Stores the higher digit of the device
number
240 TBL%(11)=0
:
'Specifies word units as processing unit
250 TBL%(12)=0
:
'Fixed value
260 TBL%(13)=144
:
'Specifies internal relays (M)
270 D!=0
:
'Specifies device number 0
280 GOSUB 430
290 TBL%(14)=L%
:
'Stores the lower digit of the device number
300 TBL%(15)=H%
:
'Stores the higher digit of the device
number
310 TBL%(16)=0
:
'Specifies bit units as processing unit
320 TBL%(17)=0
:
'Fixed value
330 TBL%(18)=168
:
'Specifies data registers (D)
340 D!=8000
:
'Specifies device number 8000
GOSUB 430
360 TBL%(19)=L%
:
'Stores the lower digit of the device number
370 TBL%(20)=H%
:
'Stores the higher digit of the device
number
380 TBL%(21)=0
:
'Specifies double-word units as processing
unit
390 TBL%(22)=0
:
'Fixed value
400 A%(0)=100:A%(1)=200:A%(2)=300
:
'Specifies the values to write
410 PCRD TBL%( ),A%( )
:
'Executes the write operation
420 END
430 H!=INT(D!/65536!)
:
’Splits into lower and higher digits
440 L!=D!-H!*65536!
450 H$=RIGHT$(“0000”+HEX$(H!),4)
460 L$=RIGHT$(“0000”+HEX$(L!),4)
470 L%=VAL(“&H”+L$)
480 H%=VAL(“&H”+H$)
490 RETURN