11 - 421 11 - 421
MELSEC-Q
11 INSTRUCTIONS AND FUNCTIONS
Program Example
10 ' This program reads the ON/OFF status of the CS, DR, RS, ER, and CD control signals
20 DIM TBL1%(2),TBL2%(3)
:
' Defines arrays
30 CH%=1
:
' Specifies the communication channel
40 TBL1%(0)=9600
50 TBL1%(1)=&H108
60 TBL1%(2)=&H1
70 ZOPEN #CH%,TBL1%( )
:
' Opens the communication channel
80 TBL2%(0)=33
:
' Specifies to read the status
90 ZCNTL #CH%,0,TBL2%( )
:
' Executes the read operation
100 A=RDSET(0,TBL2%(1))
:
' Reads the bit
110 B=RDSET(8,TBL2%(1))
120 C=RDSET(0,TBL2%(2))
130 D=RDSET(8,TBL2%(2))
140 E=RDSET(0,TBL2%(3))
150 PRINT "CS control signal: ";
:
' Displays the status
160 IF A=1 THEN PRINT "ON" ELSE PRINT "OFF"
170 PRINT "DR control signal: ";
180 IF B=1 THEN PRINT "ON" ELSE PRINT "OFF"
190 PRINT "RS control signal: ";
200 IF C=1 THEN PRINT "ON" ELSE PRINT "OFF"
210 PRINT "ER control signal: ";
220 IF D=1 THEN PRINT "ON" ELSE PRINT "OFF"
230 PRINT "CD control signal: ";
240 IF E=1 THEN PRINT "ON" ELSE PRINT "OFF"
250 ZCLOSE #CH%
:
' Closes the communication channel
260 END