Mitsubishi QD51 Programming Manual page 402

Logic controller
Hide thumbs Also See for QD51:
Table of Contents

Advertisement

11 INSTRUCTIONS AND FUNCTIONS
Program Example
(1) Program example for a format 1 control table
100 'A program example that reads the device memory of the Q/QnA series CPU
110 DIM TBL%(10),A%(100)
120 TBL%(0)=255
130 TBL%(1)=515
140 TBL%(2)=144
150 D!=0
160 H!=INT(D!/65536!)
170 L!=D!-H!*65536!
180 H$=RIGHT$("0000"+HEX$(H!),4)
190 L$=RIGHT$("0000"+HEX$(L!),4)
200 TBL%(3)=VAL("&H"+L$)
210 TBL%(4)=VAL("&H"+H$)
220 TBL%(5)=10
230 PCRD TBL%(),A%()
240 I=0
250 FOR I=0 TO 100
260 PRINT HEX$(A%(I))
270 NEXT I
280 END
11 - 232
• Assign values to %(3) and %(4) ( %(6) and %(7) in case of a format 2 control
table, %(7) and %(8) in case of a format 3 control table) in the following manner.
D!
• • • •
Device number of the device to be read
H!
L!
• • • •
Used as work area.
H$
L$
to
100 H!=INT(D!/65536!)
110 L!=D!-H! 65536!
120 H$=RIGHT$("0000"+HEX$(H!),4)
130 L$=RIGHT$("0000"+HEX$(L!),4)
140 %(3)=VAL("&H"+L$)
150 %(4)=VAL("&H"+H$)
to
In case of a format 2 control table
• • • •
%(6)=VAL("&H"+L$)
• • • •
%(7)=VAL("&H"+H$)
:
'Defines the arrays
:
'Specifies the station number to
communicate with to the local station
:
'Specifies to read device memory of the
Q/QnA series CP
:
'Specifies internal relays M
:
'Specifies device number 0
:
'Splits into lower and higher digits
:
'Stores the lower digit of the device number
:
'Stores the higher digit of the device
number
:
'Specifies the number of points to be read
:
'Executes the read operation
MELSEC-Q
11 - 232

Advertisement

Table of Contents
loading

This manual is also suitable for:

Ad51h-s3Qd51-r24A1sd51s

Table of Contents