11 - 219 11 - 219
MELSEC-Q
11 INSTRUCTIONS AND FUNCTIONS
Program Example
(1) Program example for a format 1 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)=255
:
' Specifies the station number to
communicate with to the local station
150 TBL%(1)=14
:
' Specifies to read parameters
160 TBL%(4)=128
:
' Specifies the number of bytes to be read
170 FOR J=&H0 TO &H3F80 STEP 128
180 D!=J
:
' Specifies the starting address
190 H!=INT (D!/65536!)
200 L!=D!-H!*65536!
210 H$=RIGHT$("0000"+HEX$(H!), 4)
:
' Upper byte of the starting address
220 L$=RIGHT$("0000" +HEX$(H!), 4)
:
' Lower byte of the starting address
230 TBL%(2)=VAL("&H"+L$)
:
' Stores the lower byte in the control table
240 TBL%(3)=VAL("&H"+L$)
:
' Stores the upper byte in the control table
250 PRINT H$,L$
260 PCRD TBL%( ),A%( )
:
' Executes the read operation
270 FOR I=0 TO 127
280 PRINT #1,A%(I)
:
' Writes to the file
290 NEXT I
300 NEXT J
310 CLOSE #1
:
' Closes the file
320 END