11 - 220 11 - 220
MELSEC-Q
11 INSTRUCTIONS AND FUNCTIONS
(2) Program example for a format 2 control table
100 'A program example that reads parameters from the PLC CPU and saves them on a memory card
110 '(Four network modules are connected. All the modules are control stations. Network parameter
capacity: 16 k bytes)
120 OPEN "0:PROG14.DAT" FOR OUTPUT AS #1
:
'Opens the sequential file
130 DIM TBL%(10),A%(150)
:
'Defines arrays
140 TBL%(0)=256
:
'Specifies a format 2 control table
150 TBL%(1)=1
:
'Specifies network number 1
160 TBL%(2)=1
:
'Specifies station number 1
170 TBL%(4)=14
:
'Specifies to read parameters
180 TBL%(7)128
:
'Specifies the number of bytes to be read
190 FOR J=&H0 TO &H3F80 STEP 128
200 D!=J
:
'Specifies the starting address
210 H!=INT (D!/65536!)
220 L!=D!-H!*65536!
230 H$=RIGHT$("0000"+HEX$(H!), 4)
:
'Upper byte of the starting address
240 L$=RIGHT$("0000"+HEX$(L!), 4)
:
'Lower byte of the starting address
250 TBL%(5)=VAL("&H"+L$)
:
'Stores the lower byte in the control table
260 TBL%(6)=VAL("&H"+L$)
:
'Stores the upper byte in the control table
270 PRINT H$,L$
280 PCRD TBL%( ),A%( )
:
'Executes the read operation
290 FOR I=0 TO 127
300 PRINT #1,A%(I)
:
'Writes to the file
300 NEXT I
310 NEXT J
320 CLOSE #1
:
'Closes the file
330 END