11 - 466 11 - 466
MELSEC-Q
11 INSTRUCTIONS AND FUNCTIONS
Program Example (Executed in BASIC on the AD51H)
10 ' This program sends data to the LM7000 (AD51H is the transmission side)
20 ON ERROR GOTO 330
:
' Branches to line 330 if an error occurs
30 '
40 '***** RS-232C CH.OPEN *****
50 DIM T%(10)
:
' Defines an array
60 CH%=1
:
' 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
:
' and stop bit
100 ZOPEN #A%,T%( )
:
' Opens the communication channel
110 '
120 '***** PORT CNTL *****
130 DIM CNTL%(10)
:
' Defines an array
140 CNTL%(0)=32
:
' Controls by the RS/ER signals
150 CNTL%(1)=&H1
:
' Controls by the RS signal
160 ZCNTL #CH%,0,CNTL%( )
:
' Controls by signals
170 '
180 '***** DATA SENO *****
190 DIM TBL%(10)
:
' Defines an array
200 TBL%(0)=30
:
' Sets the number of bytes requested to be
sent
210 TBL%(1)=0
:
' Assigns the number of bytes transmitted
to TBL%(1)
220 TBL%(2)=100
:
' Sets the timeout value
230 SD$="SOUSIN DATA :ABCDEFGH 12345678"
:
' Defines the data to be transmitted
240 ZSEND #CH%,0,TBL%( ),SD$
:
' Executes the transmission
250 PRINT "SEND CHARACTER =";TBL%(1)
:
' Displays the number of characters
transmitted
260 PRINT "SEND DATA =";SD$
:
' Displays the data transmitted
270 '
280 '***** RS-232C CH.CLOSE *****
290 ZCLOSE #CH%
:
' Closes the communication channel
300 END
:
' Ends the execution
310 '
320 '***** ERROR ROUTINE *****
330 ERTYPE%=ERR:ERLINE%=ERL
:
' Stores the error occurred and the line in
which it occurred
340 IF ERTYPE%=17 THEN PRINT "ZOPEN ERROR!!"
: ' Displays the error if it is Z related
350 PRINT "ERROR CODE =";ERTYPE%
:
' Displays the error code
360 PRINT "ERROR LINE =";ERTYPE%
:
' Displays the line where the error occurred
370 RESUME 290
:
' Returns the processing to line 290
Содержание A1SD51S
Страница 183: ...11 13 11 13 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS RUN Before swap A 0 H924 A 1 H1159 After swap A 0 H1159 A 1 H924 OK...
Страница 331: ...11 161 11 161 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS REMARK See the CON ON OFF STOP and ZOPEN functions and Section 7 4...
Страница 557: ...11 387 11 387 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS REMARK See the CHR SPACE and SPC functions...
Страница 629: ...11 459 11 459 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS REMARK See the ZOPEN ZSEND and ZCNTL instructions and Section 7 3 4...
Страница 645: ...11 475 11 475 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS REMARK See the ZEVENT ZSIGNAL and DEF ZEVENT instructions...