11 - 313 11 - 313
MELSEC-Q
11 INSTRUCTIONS AND FUNCTIONS
(2) Program example for a format 2 control table
100 ' A program example that writes the parameters stored in a memory card to the PLC CPU
110 ' (Four network modules are connected. All the modules are control stations. Network parameter
capacity: 16 k bytes)
120 DIM TBL1%(10),A%(150),TBL2%(10),B%(10)
:
'Defines arrays
130 OPEN "0:PROG14.DAT" FOR INPUT AS #1
:
'Opens the file
140 FOR J=&H0 TO &H3F80 STEP 128
150 FOR I=0 TO 127
160 INPUT #1,A%(I)
170 NEXT I
180 TBL1%(0)=256
:
'Specifies a format 2 control table
190 TBL1%(1)=1
:
'Specifies network number 1
200 TBL1%(2)=1
:
'Specifies station number 1
210 TBL1%(4)=14
:
'Specifies to write parameters
220 D!=J
:
'Specifies the starting address of the
parameter data to be written
230 H!=INT(D!/65536!)
240 L!=D!-H!*65536!
250 H$=RIGHT$("0000"+HEX$(H!),4)
:
'Higher byte of the starting address of the
parameter data
260 L$=RIGHT$("0000"+HEX$(L!),4)
:
'Lower byte of the starting address of the
parameter data
270 TBL1%(5)=VAL("&H"+L$)
:
Stores the lower byte in the control table
280 TBL1%(6)=VAL("&H"+H$)
:
'Stores the higher byte in the control table
290 TBL1%(7)=128
:
'Specifies the number of bytes to be written
300 PCWT TBL1%( ),A%( )
:
'Executes the write operation
310 NEXT J
320 CLOSE
:
'Closes the file
330 TBL2%(0)=256
:
'Specifies a format 2 control table
340 TBL2%(1)=1
:
'Specifies network number 1
350 TBL2%(2)=1
:
'Specifies station number 1
360 TBL2%(4)=15
:
'Specifies to analyze the parameter data
370 PCWT TBL2%( ),B%( )
:
'Executes the analysis
380 END