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