11 - 302 11 - 302
MELSEC-Q
11 INSTRUCTIONS AND FUNCTIONS
Program Example
(1) Program example for a format 1 control table
100 ' A program example that writes the extension comment data stored in a memory card to the PLC
CPU
110 ' (Extension comment capacity: 3 k bytes)
120 DIM TBL%(10),A%(150)
:
'Defines arrays
130 OPEN "0:PROG9.DAT" FOR INPUT AS #1
:
'Opens the file
140 FOR J=&H0 TO &HB80 STEP 128
150 FOR I=0 TO 127
160 INPUT #1,A%(1)
:
'Reads from the file
170 NEXT I
180 TBL%(0)=255
:
'Specifies the station number to
communicate with to the local station
190 TBL%(1)=11
:
'Specifies to write extension comment data
200 TBL%(2)=J
:
'Specifies the head address of the
extension comment data to be written
210 TBL%(3)=128
:
'Specifies the number of bytes to be written
220 PCWT TBL%( ),A%( )
:
'Executes the write operation
230 NEXT J
240 CLOSE
:
'Closes the file
250 END
(2) Program example for a format 2 control table
100 ' A program example that writes the extension comment data stored in a memory card to the PLC
CPU
110 ' (Extension comment capacity: 3 k bytes)
120 DIM TBL%(10),A%(150)
:
'Defines arrays
130 OPEN "0:PROG9.DAT" FOR INPUT AS #1
:
'Opens the file
140 FOR J=&H0 TO &H1F80 STEP 128
150 FOR I=0 TO 127
160 INPUT #1,A%(I)
:
'Reads from the file
170 NEXT I
180 TBL%(0)=256
:
'Specifies a format 2 control table
190 TBL%(1)=1
:
'Specifies network number 1
200 TBL%(2)=1
:
'Specifies station number 1
210 TBL%(4)=11
:
'Specifies to write extension comment data
220 TBL%(5)=J
:
'Specifies the head address of the
extension comment data to be written
230 TBL%(6)=128
:
'Specifies the number of bytes to be written
240 PCWT TBL%( ),A%( )
:
'Executes the write operation
250 NEXT J
260 CLOSE
:
'Closes the file
270 END