Mitsubishi QD51 Programming Manual page 627

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

Advertisement

11 INSTRUCTIONS AND FUNCTIONS
Program Example
10 ' This program receives data from the LM7000 (AD51H is the reception side)
20 ON ERROR GOTO 360
30 '
40 '***** RS-232C CH.OPEN *****
50 DIM TBL1%(2)
60 CH%=1
70 TBL1%(0)=4800
80 TBL1%(1)=&H8
90 TBL1%(2)=&H1
100 ZOPEN #CH%,TBL1%( )
110 '
120 '***** PORT CNTL *****
130 DIM CNT%(10)
140 CNT%(0)=32
150 CNT%(1)=&H1
160 ZCNTL #CH%,CNT%( )
170 '
180 '***** DATA RECEIVE *****
190 DIM TBL2%(2)
200 TBL2%(0)=12
210 TBL2%(1)=0
220 TBL2%(2)=300
230 WOR%=TBL2%(0)/2
240 DIM CTBL%(WOR%-1)
250 ZRECEIVE #CH%,0,TBL2%( ),CTBL%( )
260 PRINT "RECEIVE CHARACTER =";TBL2%(1)
270 FOR I%=0 TO WOR%-1
280 PRINT "RECEIVE DATA =&H";HEX$(CTBL%(I%)) :
290 NEXT I%
300 '
310 '***** RS-232C CH.CLOSE *****
320 ZCLOSE #CH%
330 END
340 '
350 '***** ERROR ROUTINE *****
360 ERTYPE%=ERR:ERLINE%=ERL
370 IF ERTYPE%=17 THEN PRINT "ZOPEN ERROR!!"
380 PRINT "ERROR CODE =";ERTYPE%
390 PRINT "ERROR LINE =";ERTYPE%
400 RESUME 320
11 - 457
(Executed in BASIC on the AD51H)
:
' Branches to line 360 if an error occurs
:
' Defines an array
:
' Defines a communication channel
:
' Sets the baud rate
:
' Sets the character length, parity bit,
:
' and stop bit
:
' Opens the communication channel
:
' Defines an array
:
' Control by the RS/ER signals W
:
' Control by the RS control signal NM
:
' Control by signals S
:
' Defines an array
:
' Sets the number of bytes requested to be
received
:
' Stores the number of bytes received
:
' Sets the timeout value
:
' Reads 2 bytes
:
' Defines an array
:
' Executes the reception
:
' Displays the number of characters
received
' Displays the data received
:
' Closes the communication channel
:
' Ends the execution
:
' Stores the error that occurred and the line
in which it occurred
: ' Displays the error if it is Z related
:
' Displays the error code
:
' Displays the line where the error occurred
:
' Returns the processing to line 310
MELSEC-Q
11 - 457

Advertisement

Table of Contents
loading

This manual is also suitable for:

Ad51h-s3Qd51-r24A1sd51s

Table of Contents