11 - 458 11 - 458
MELSEC-Q
11 INSTRUCTIONS AND FUNCTIONS
(Executed in BASIC on the LM7000)
10 ' This program sends data to a console (LM7000 is the transmission side)
20 ON ERROR GOTO 380
:
' Branches to line 360 when an error occurs
30 '
40 '***** RS-232C CH.OPEN *****
50 DIM T%(8)
:
' Defines an array
60 CH%=18
:
' Defines a channel number
70 T%(0)=4800
:
' Sets the baud rate
80 T%(1)=&H8
:
' Sets the character length, parity bit,
90 T%(2)=&H1
:
' stop bit, and DC control
100 T%(3)=0
:
' Sets control by signals
110 T%(5)=0
:
' Sets DC1 code and DC code
120 T%(4)=0
:
' Sets the receive buffer
130 T%(6)=0
:
' Sets DC3 code and DC2 code
140 T%(7)=0
:
' Sets DC4 code
150 ZOPEN #CH%,T%( )
:
' Opens the communication channel
160 '
170 '***** RS CNTL *****
180 DIM CNTL%(1)
:
' Defines an array
190 CNTL%(0)=32
:
' Specifies control by the RS/ER control
signals
200 CNTL%(1)=&H1
:
' Turns ON the RS control
210 ZCNTL #CH%,0,CNTL%( )
:
' Executes the control by signals
220 '
230 '***** DATA SEND *****
240 DIM TBL%(2)
:
' Defines an array
250 TBL%(0)=12
:
' Sets the requested characters
260 TBL%(1)=0
:
' Stores the number of bytes transmitted to
TBL%(1)
270 TBL%(2)=100
:
' Sets the timeout value
280 SD$="AD51H-BASIC "
:
' Defines transmission data
290 ZSEND #CH%,0,TBL%( ).SD$
:
' Executes the transmission
300 PRINT "SEND CHARACTER =":TBL%(1)
:
' Displays the number of characters
transmitted
310 PRINT "SEND DATA =";SD$
:
' Displays the data transmitted
320 '
330 '***** RS-232C CH.CLOSE *****
340 ZCLOSE #CH%
:
' Closes the communication channel
350 END
:
' Ends the execution
360 '
370 '***** ERROR ROUTINE *****
380 ERTYPE%=ERR:ERLINE%=ERL
:
' Stores the error that occurred and the line
in which it occurred
390 IF ERTYPE%=94 THEN ERTYPE%=ZERROR(1) :
' Displays the error if it is Z related
400 PRINT "ERROR CODE =";ERTYPE%
:
' Displays the error code
410 PRINT "ERROR LINE =";ERTYPE%
:
' Displays the line where the error occurred
420 RESUME 340
:
' Returns the processing to line 320