11 - 415 11 - 415
MELSEC-Q
11 INSTRUCTIONS AND FUNCTIONS
If a character equal to one of the set break characters is detected during the
execution of the ZRECEIVE instruction, the reception data until the break
character is stored in the input element of the receive request, after which the
execution of the receive request is ended.
Since the break characters require to be specified in the lower and higher bytes
of different elements of <control table>, it is convenient to use hexadecimal
as shown below.
%(2 to 4)=&H
Express the lower byte as
a 2-digit hexadecimal number.
Express the higher byte as
a 2-digit hexadecimal number.
Program Example
10 ' This program sets and reads break characters
20 DIM TBL1&(2),TBL2%(4),TBL3%(4)
:
' Defines arrays
30 A%=1
:
' Communication channel CH1 (RS-232C)
40 TBL1%(0)=9600
:
' Sets the baud rate
50 TBL1%(1)=&H107
:
' Sets the character length and parity bit
60 TBL1%(2)=&H1
:
' Sets the stop bit
70 ZOPEN #A%,TBL1%( )
:
' Opens the communication channel
80 TBL2%(0)=22
:
' Specifies to set break characters
90 TBL2%(1)=2
:
' Specifies the number of break characters
100 TBL2%(2)=&H30D
:
' Defines break characters
110 ZCNTL #A%,0,TBL2%( )
:
' Executes the setting of the break
characters
120 TBL3%(0)=23
:
' Specifies to read the break characters
130 ZCNTL #A%,0,TBL3%( )
:
' Executes the reading of the break
characters
140 PRINT "Number of break characters=";TBL3%(1)
:
' Displays the result
150 PRINT "Break character=&H";HEX$(TBL3%(2))
160 ZCLOSE #A%
:
' Closes the communication channel
170 END